1

How do I redefine the equation and align environment to use a font size of 9.0pt? I found this nice solution (apart from starting a new paragraph after applying it), allowing me to define the font size of a single equation or align environment:

\begingroup\makeatletter\def\f@size{9.0}\check@mathfonts
\def\maketag@@@#1{\hbox{\m@th\normalsize\normalfont#1}}
\begin{equation}
...
\end{equation}\endgroup

or without adjusting the equation number is fine as well:

\begingroup\makeatletter\def\f@size{9.0}\check@mathfonts
\begin{equation}
...
\end{equation}\endgroup

I like to apply this globally without using different environment names.

Edit: some compilable example (though I have to use a different document class):

\documentclass[10pt,a4paper]{scrartcl}
\usepackage{amsmath}
\begin{document}
This is some text.
\begingroup\makeatletter\def\f@size{5.0}\check@mathfonts
\def\maketag@@@#1{\hbox{\m@th\normalsize\normalfont#1}}
\begin{equation}
P = NP
\end{equation}\endgroup
\end{document}
4
  • Please provide a complete example we can compile. Look at etoolbox, it has macros such as \AtBeginEnvironment and \AtEndEnvironment which you can use for this. Better, though, to use \fontsize{}{}\selectfont, I think.
    – cfr
    Commented Dec 6, 2017 at 18:15
  • @cfr I added something that can compile (though it does not really provide lots of added value imho).
    – Matthias
    Commented Dec 6, 2017 at 18:22
  • @cfr I tried \AtBeginEnvironment{equation}{\begingroup\makeatletter\def\f@size{5.0}\check@mathfonts} \AtEndEnvironment{equation}{\endgroup}, but it doesn't compile: \check only allowed in math mode, missing $, you can't use \eqno in horizontal mode, etc. ?
    – Matthias
    Commented Dec 6, 2017 at 18:48
  • 1
    You don't want \makeatletter inside. Put it outside with \makeatother afterwards.
    – cfr
    Commented Dec 6, 2017 at 23:08

2 Answers 2

1
\documentclass{scrartcl}
\usepackage{lmodern,amsmath}
\makeatletter
\def\maketag@@@#1{\hbox{\m@th\normalsize\normalfont#1}}
\let\oldequation\equation
\def\equation{\def\f@size{5.0}\check@mathfonts\oldequation}
\makeatother
\begin{document}
This is some text.
\begin{equation}
P = NP
\end{equation}
\end{document}

enter image description here

2
  • Works like a charm! Can I just add align and alignat in the same makeatletter/makeatother pair or do I need three of these blocks?
    – Matthias
    Commented Dec 6, 2017 at 20:03
  • 1
    @Matthias Yes of course.
    – user91669
    Commented Dec 6, 2017 at 20:16
1

You can add code at the beginning of an environment using etoolbox. For example,

\documentclass[10pt,a4paper]{scrartcl}
\usepackage{amsmath,etoolbox}
\AtBeginEnvironment{align}{%
  \fontsize{5}{6}%
}
\AtBeginEnvironment{equation}{%
  \fontsize{5}{6}%
}
\begin{document}
This is some text.
\begin{equation}
P = NP
\end{equation}
\begin{align}
  P = NP
\end{align}
Here is some more text.
\end{document}

small maths

Note that the use of hard-coded font sizes is not recommended. In this case, it would be better to replace \fontsize{5}{6} by, say, \tiny, which is equivalent for a document with 10pt as the default size. This helps ensure consistency and makes your code more flexible.

1
  • I know it is not the most clean solution, but I need to use a certain template for a paper. Most of my equation numbers do not fit the same line, therefore, I want to slightly reduce the font size. This improves readability as well since the text and formulas have a slightly different size.
    – Matthias
    Commented Dec 7, 2017 at 9:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .