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}
  • 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 Dec 6 '17 at 18:15
  • @cfr I added something that can compile (though it does not really provide lots of added value imho). – Matthias Dec 6 '17 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 Dec 6 '17 at 18:48
  • 1
    You don't want \makeatletter inside. Put it outside with \makeatother afterwards. – cfr Dec 6 '17 at 23:08
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

  • 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 Dec 6 '17 at 20:03
  • 1
    @Matthias Yes of course. – user91669 Dec 6 '17 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.

  • 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 Dec 7 '17 at 9:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.