171

I wanted to type an equation in LaTeX. But it is too long to fit into one line. It involves big arrays with many columns so I cannot split it. I wanted to reduce the font size so that it can fit in one line. However, \small doesn't work in the equation environment.

3
  • 7
    Can we see the actual equation? Perhaps we could then suggest some alternatives. Commented Jun 19, 2012 at 20:31
  • 7
    as a last resort, just pack the whole thing into a \scalebox and shrink as much as necessary. rewriting as much as possible would be advisable first. Commented Jun 19, 2012 at 20:38
  • 1
    I agree with Gonzalo, don't scale unless nothing else can be done. If the equation is so large that scaling is needed, chances are that scaling the equation will not make it be more understandable for the reader. In most cases a rewrite is a better option.
    – daleif
    Commented Jun 20, 2012 at 14:49

6 Answers 6

160

The following illustrates font size alterations in mathmode:

\documentclass[letterpaper]{article}
\usepackage{graphicx}               % Necessary to use \scalebox
\usepackage{amsmath,amssymb}
\begin{document}
\noindent 
normal: $ x^2 + 2xy + y^2 $\\
displaystyle: $ {\displaystyle x^2 + 2xy + y^2} $\\
scriptstyle: $ {\scriptstyle x^2 + 2xy + y^2} $\\
scriptscriptstyle: $ {\scriptscriptstyle x^2 + 2xy + y^2} $\\
textstyle: $ {\textstyle x^2 + 2xy + y^2} $

\noindent
\scalebox{0.5}{%
normal: $ x^2 + 2xy + y^2$}
\end{document}

This yields:

enter image description here

Note that:

  • \displaystyle gives the command to switch the math font size to normal size for displayed formulas.
  • \textstyle is used to go back to normal size font for inline formulas.
  • \scriptstyle is used to set the math font to a size used for subscripted and superscripted symbols.
  • \scriptscriptstyle provides the normal size for doubly subscripted and superscripted symbols.

When using the \scalebox command from the graphicx package one can specify the width (or height) and the other dimension will be scaled proportionally. In a similar manner you can specify both dimensions, but in this case it is all about aesthetics. Therefore we have the following under the \scalebox command:

  • \scalebox{h-dimension}{v-dimension}{content to be scaled}: both dimension stated.
  • \scalebox{h-dimension}{content}: both arguments (h-dim and v-dim) scaled with respect to the stated dimension.
7
  • 2
    $\scriptstyle$ etc. not only changes the font size. It also affects how lines are broken. Commented Jun 23, 2018 at 22:18
  • 2
    When you use fractions within display math mode, the font size is automatically reduced... ...to what size?
    – Matsmath
    Commented Oct 5, 2019 at 12:08
  • The command \scriptstyle worked so well, it can be applied to only part of the equation and it only decrease the font size, doing nothing else. Thanks!
    – zyy
    Commented May 1, 2020 at 2:40
  • somehow \scriptstyle reduces the font of only the first symbol following it inside an align, is that behavior expected?
    – xealits
    Commented Oct 27, 2020 at 11:59
  • @xealits Without the code I cannot say what is the issue.
    – azetina
    Commented Oct 27, 2020 at 14:16
83

Just put \small before the equation and \normalsize after it if you want to shrink the font, but it's usually better to use an ams multi-line equation environment than to change font size.

It's actually easier to only do the part of a size change command that affects math without changing the baseline to avoid the problems @barabara-beeton mentions. This is a \tiny (5pt) equation in a \large paragraph text, to highlight the differences, and to show that the above and below display skips are not altered.

enter image description here

\documentclass{article}

\showoutput
\showboxdepth3

\begin{document}
\large

hghghga hghghga hghghga hghghga hghghga hghghga hghghga 
hghghga hghghga hghghga hghghga hghghga hghghga hghghga 
$$abc+xyz=44$$
bbbbbb bbbbbb bbbbbb bbbbbb bbbbbb bbbbbb bbbbbb bbbbbb 
bbbbbb bbbbbb bbbbbb bbbbbb bbbbbb bbbbbb bbbbbb bbbbbb 

hghghga hghghga hghghga hghghga hghghga hghghga hghghga 
hghghga hghghga hghghga hghghga hghghga hghghga hghghga 
\begingroup\makeatletter\def\f@size{5}\check@mathfonts
$$abc+xyz=44$$\endgroup
bbbbbb bbbbbb bbbbbb bbbbbb bbbbbb bbbbbb bbbbbb bbbbbb 
bbbbbb bbbbbb bbbbbb bbbbbb bbbbbb bbbbbb bbbbbb bbbbbb 


\end{document}

with AMS align this would produce: enter image description here

\documentclass{article}
\usepackage{amsmath}

\showoutput
\showboxdepth3

\begin{document}
\large

hghghga hghghga hghghga hghghga hghghga hghghga hghghga 
hghghga hghghga hghghga hghghga hghghga hghghga hghghga 
\begin{align}
abc&+xyz&&=44\\
x&-y&&=2\\
a&+b&&=77
\end{align}
bbbbbb bbbbbb bbbbbb bbbbbb bbbbbb bbbbbb bbbbbb bbbbbb 
bbbbbb bbbbbb bbbbbb bbbbbb bbbbbb bbbbbb bbbbbb bbbbbb 

hghghga hghghga hghghga hghghga hghghga hghghga hghghga 
hghghga hghghga hghghga hghghga hghghga hghghga hghghga 
\begingroup\makeatletter\def\f@size{5}\check@mathfonts
\def\maketag@@@#1{\hbox{\m@th\large\normalfont#1}}%
\begin{align}
abc&+xyz&&=44\\
x&-y&&=2\\
a&+b&&=77
\end{align}\endgroup
bbbbbb bbbbbb bbbbbb bbbbbb bbbbbb bbbbbb bbbbbb bbbbbb 
bbbbbb bbbbbb bbbbbb bbbbbb bbbbbb bbbbbb bbbbbb bbbbbb 


\end{document}
11
  • 3
    however, unless there's a paragraph break before the display, the baselines of the preceding paragraph will be fouled up, and if there is a blank line/pargraph break before the display, the vertical space preceding the display will be fouled up, and a page break would also be allowed because of the paragraph break. there's no good (automatic) mechanism defined for this yes, as far as i know. Commented Jun 19, 2012 at 21:42
  • @barbarabeeton yes I was going to mention that. If there were a MWE I'd have probably shown it with a correction for baselinskip. I suppose I should make one. It can't be that hard can it to insert a par while preserving the predispolay skip. Commented Jun 19, 2012 at 22:15
  • @barbarabeeton something like the code in the updated answer? Commented Jun 19, 2012 at 23:08
  • make it a 3-line display and i'll be happier. Commented Jun 20, 2012 at 13:04
  • 1
    @Clément \documentclass{article} \setlength\textwidth{7cm} \usepackage{amsmath} \begin{document} \Large\sloppy \def\aa{one two three four five six seven eight } \def\bb{\aa blue black red \aa\aa yellow pink black orange \aa} \bb\aa \begin{align} a+b+c &=1=2+3 \\ b+c &= z\\ c&=5 \end{align} \bb\aa % \everydisplay{\fontsize{7pt}{10pt}\selectfont}% % \aa \begin{align} a+b+c &=1=2+3 \\ b+c &= z\\ c&=5 \end{align} \bb \end{document} Commented Nov 3, 2016 at 22:52
36

Similar to How to make math font huge, you can use \scalebox to scale down the equation, or \resizebox the box to a specific width to reduce the size. The first is the normal display mode equation, followed by the scaled version with \scalebox and \resizebox:

enter image description here

Code:

\documentclass{article}
\usepackage{amsmath}
\usepackage{graphicx}
\newcommand*{\Scale}[2][4]{\scalebox{#1}{$#2$}}%
\newcommand*{\Resize}[2]{\resizebox{#1}{!}{$#2$}}%
\begin{document}
\[y = \sin^2 x\]
%
\[\Scale[0.5]{y = \sin^2 x}\]
%
\[ \Resize{1cm}{y = \sin^2 x}\]
\end{document}
1
  • 1
    Best solution among others Commented Apr 29, 2021 at 8:55
17

If you want to change the size in the middle of an equation, you can try to change to text mode, change the size, an them retype in equation mode using $$.

Example:

\begin{equation}
A + B = \text{\footnotesize $C + D$} + E
\end{equation}

enter image description here

1
  • on mathJax one can do $A+B = {\tiny C+ D} + E$
    – Butanium
    Commented May 28, 2023 at 12:24
11

Why nobody mentions the small environment?

\begin{small}
\[ x^2 + 2xy + y^2 \]
\end{small}
9
  • 8
    Because it isn't an environment, it just works because, well. It just does, the internals never test, if \endsmall is def'ed.
    – Johannes_B
    Commented Nov 12, 2014 at 17:33
  • 2
    @Johannes_B Not really:better to say the implementation of environments is explicitly coded to work whether or not the end code is defined. Commented Nov 12, 2014 at 17:35
  • 1
    Your small environment knows to behave in a very strange way, and should not be used. It is a (questionable) design choice that the \small command defined the small environment as well. Notice that you can use \begin{cite}{article123}\end{cite} instead of \cite{article123} and the effect will be almost the same, just it will have some strange consequences.
    – yo'
    Commented Nov 12, 2014 at 17:36
  • 5
    Nobody mentioned it because it's wrong: see this picture for knowing why. I used footnotesize for making the effect more evident, but it's noticeable also with small.
    – egreg
    Commented Nov 12, 2014 at 17:42
  • 3
    @TonyBetaLambda Did you look at the interline spacing above the equation?
    – egreg
    Commented Nov 17, 2014 at 15:31
9

First, put the following code in the preamble:

\newcommand\scalemath[2]{\scalebox{#1}{\mbox{\ensuremath{\displaystyle #2}}}}

Then you can change the size of your equation using \scalemath as follows:

$$\scalemath{2}{sin(x)^2 + cos(x) + x^2}$$
$$\scalemath{1}{sin(x)^2 + cos(x) + x^2}$$
$$\scalemath{0.8}{sin(x)^2 + cos(x) + x^2}$$
$$\scalemath{0.6}{sin(x)^2 + cos(x) + x^2}$$
$$\scalemath{0.4}{sin(x)^2 + cos(x) + x^2}$$
$$\scalemath{0.2}{sin(x)^2 + cos(x) + x^2}$$
\[
\scalemath{0.7}{
sin(x)^2 + cos(x) + x^2
}
\]

enter image description here

0

You must log in to answer this question.

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