# How can I change the font size in math equations?

I find that whenever I'm typing some equations into a document, and the equation gets a bit complex (let's say a fraction in a parentheses, squared, inside a square root, inside a fraction), the variables and whatnot that I put inside the "inner" parts of the equation get really, really, tiny. But if I set the font size to something a lot larger, the stuff on the "inside" gets tolerable, but the stuff on the "outside" (e.g., "x = lots of junk", x would be in the "outside") become gigantic!

How can I make it more pretty like my textbooks, where all variables are at the same size regardless of whatever parentheses/fractions/radicals they're under?

-
Matthew Leingang provided you with a good solution, but personally I would recommend fixing this on a case by case. Setting \everymath will also make all in-line math "big", which can make interline spacing very large to accomodate all the large expression. I think that doesn't look very good. –  Willie Wong Nov 9 '10 at 17:58
You can also consider rewording your equations. For example if you have x = \sqrt{ complicated stuff + complicated stuff } you can say x = \sqrt {A + B} where A = complicated stuff and B = complicated stuff. –  Aditya Nov 9 '10 at 18:44
@Willie how would I fix it on a case-by-case basis instead? –  wrongusername Nov 13 '10 at 2:06
Put \displaystyle inside the "group" with the thing you want big. For example, compare the in-line expressions $\frac{1}{x + \frac1x}$ and $\displaystyle \frac{1}{x - \frac1x}$ and $\displaystyle \frac{1}{x - {\displaystyle \frac1x}}$ to see how the scope of the \displaystyle command works. –  Willie Wong Nov 13 '10 at 2:53

## 4 Answers

To get equal sizes, you could use \DeclareMathSizes in your preamble. The syntax is

\DeclareMathSizes{display size}{text size}{script size}{scriptscript size}.


You could simply set all to your default font size. In this example:

\documentclass[10pt]{article}
\begin{document}
$x = \frac{1}{x + \frac{1}{x + \frac{1}{x}}}$
\end{document}


where you firstly get different sizes:

inserting this line

\DeclareMathSizes{10}{10}{10}{10}


changes the output to:

-
I had never heard of \DisplayMathSizes Is it part of "plain" LaTeX or another package? –  Matthew Leingang Nov 9 '10 at 21:12
Thanks! But can you elaborate on what display/text/script/scriptscript sizes are? :P –  wrongusername Nov 9 '10 at 21:33
@Matthew: \DeclareMathSizes is defined in latex.ltx and it is explained in source2e.pdf in section 25. –  Stefan Kottwitz Nov 9 '10 at 22:20
@wrongusername: those sizes are used in the style with the same corresponding name. Thus display size is used for displayed equations, text size for in-line math, script size for subscripts and superscripts (indexes, exponents), scriptscript size for subscripts of subscripts etc. –  Stefan Kottwitz Nov 9 '10 at 22:23
The clearer meta description should be \DeclareMathSizes{<surrounding text size>}{<math text size>}{<math script size>}{<math scriptscript size>}. –  cyanide-based food Feb 17 '13 at 7:17

You can try \dfrac instead of \frac.

-
Note that \dfrac is not defined by default in the standard document classes. You would require a package like amsmath. –  Werner Feb 16 '12 at 6:56
Exactly what I was looking for! –  Vivi Mar 2 '12 at 22:24

Put this in your preamble, but after all \usepackage commands:

\everymath=\expandafter{\the\everymath\displaystyle}


This will effectively add \displaystyle to every (inline) math made environment, making all math look like the math that's displayed.

Edits: Thanks to Charles for pointing out that this can/should be done in a way which doesn't clobber the existing \everymath token list, in case it's already nonempty. And as Willie says the = is optional. I like using it; it just reminds me that there is some assignment going on.

Edit 2: The OP asked for a detailed explanation. I'll try.

First, remember that \everymath is a token list that is inserted in front of every math mode material. So if you type \everymath={\text{Here comes the math: }} you will get that in front of every equation. \everymath={\displaystyle} does something a little more productive by inserting \displaystyle in front of each math mode.

The trouble arises when you or some other package has already modified \everymath. So we need to append \displaystyle to the \everymath token list. In pseudo-TeX you want to say:

\everymath={\currentcontentsof{\everymath}\displaystyle}


The TeX implementation of the pseudo-macro \currentcontentsof is \the. So a closer approximation is this:

\everymath={\the\everymath\displaystyle}


But this is going to be trouble, When TeX reads a token list declaration it just reads the tokens without expanding. That is, the \the will be expanded not here but at the the first encountered math mode. That will cause TeX to try to expand \everymath, which will need an expansion of \everymath inside it. Oops! Infinite loop.

So you need the \the expanded before you save the token list. Hence \expandafter:

\everymath=\expandafter{\the\everymath\displaystyle}


When TeX reads \everymath=, it expects a token list. But instead, it gets \expandafter, which says "hold on to the next token, expand the following token, then put the held token back in place and expand normally." So the { token is deferred while \the is expanded. \the needs another token to work, so the next token \everymath is read. This replaces the two tokens \the\everymath with the tokens currently in \everymath. Now that { is put back in place, and TeX can read a normal token list declaration.

Other TeXnicians may correct that answer, but it's how I understand things.

-
Note that code redefining \everymath will conflict with packages that redefine this, like the {mathdots} package. –  Charles Stewart Nov 9 '10 at 17:59
What's the equals sign for? I've always just used \everymath{blah}... –  Willie Wong Nov 9 '10 at 17:59
The equals sign is optional, both variants are correct and equivalent. –  Philipp Nov 9 '10 at 19:37
Interestingly, adding this made a horizontal line I had placed at the beginning of the document, along with a big skip, make the rest of the page go to the second page. Cutting out both the horizontal line and the big skip returned all text back the way it was. Anyway to fix this? –  wrongusername Nov 9 '10 at 21:47
@wrongusername: Not sure what would cause that, but of course making all math display math will obviously change line heights. TeX has a complicated algorithm for breaking lines into pages, and this could conceivably confuse it. As for explaining the code, I will try with a future edit. \expandafter and other expansion tweaks are in the double-dangerous-bend category (referring to the icons in the TeXBook which indicate stuff to be skipped until one is really ready). This answer I adapted from something in Appendix D, "Dirty Tricks." :-) –  Matthew Leingang Nov 10 '10 at 13:22

You can use \everymath locally by inserting \begingroup and \endgroup as this

\begingroup
\everymath{\scriptstyle}
\scriptsize
%your equation
\endgroup

-
Welcome to tex.sx! A tip: If you indent lines by 4 spaces, then they're marked as a code sample. You can also highlight the code and click the "code" button (with "101010" on it). –  Hendrik Vogt Feb 15 '11 at 19:22