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.
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:
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
andv-dim
) scaled with respect to the stated dimension.
-
1$\scriptstyle$ etc. not only changes the font size. It also affects how lines are broken. – BlenderBender Jun 23 '18 at 22:18
-
1When you use fractions within display math mode, the font size is automatically reduced... ...to what size? – Matsmath Oct 5 '19 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 May 1 '20 at 2:40 -
somehow
\scriptstyle
reduces the font of only the first symbol following it inside analign
, is that behavior expected? – xealits Oct 27 '20 at 11:59 -
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.
\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:
\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}
-
3however, 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. – barbara beeton Jun 19 '12 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. – David Carlisle Jun 19 '12 at 22:15
-
-
-
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}
– David Carlisle Nov 3 '16 at 22:52
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
:
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}
-
3Perhaps you could also mention
\resizebox{\textwidth}{!}{...}
to not have to guess scaling factors. – Gonzalo Medina Jun 19 '12 at 21:00 -
8
-
-
1
-
Why nobody mentions the small
environment?
\begin{small}
\[ x^2 + 2xy + y^2 \]
\end{small}
-
6Because it isn't an environment, it just works because, well. It just does, the internals never test, if
\endsmall
is def'ed. – Johannes_B Nov 12 '14 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. – David Carlisle Nov 12 '14 at 17:35
-
1Your
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 thesmall
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' Nov 12 '14 at 17:36 -
4Nobody 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 withsmall
. – egreg Nov 12 '14 at 17:42 -
1@TonyBetaLambda Did you look at the interline spacing above the equation? – egreg Nov 17 '14 at 15:31
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}
\scriptstyle
and\scriptscriptstyle
work? – azetina Jun 19 '12 at 20:31\scalebox
and shrink as much as necessary. rewriting as much as possible would be advisable first. – barbara beeton Jun 19 '12 at 20:38