6

I have a question about the \displaystyle command. So every time I write a quiz or test, in order to make a fraction, limit, integral, etc. look decent, I have to do something like,

$\displaystyle\frac{2}{3}$ 

or

$\displaystyle\int_{0}^{\infty} e^{-5x}dx$. 

If I do not input this command, the text is absurdly small. Is there a package or command I can put in my template so that it just automatically assumes to do the \displaystyle command?

I run MiKTeX on a Windows computer. I have decent LaTeX knowledge, but am foggy in templates.

user202729
  • 7,143
Kevin
  • 63

2 Answers2

12

Christian has already shown examples of better markup, but I thought I'd answer your "absurdly small" comment.

$ is designed for inline math, that is, mathematics set within a paragraph of text. It attempts (not always successfully) to fit within the standard baseline spacing of a paragraph.

As the example shows, sometimes even the default settings are not cramped enough and the paragraph baseline is affected, but displaystyle opens up the paragraph with wildly inconsistent spacing making it more or less unreadable as a block of text.

enter image description here

\documentclass{article}

\usepackage{amsmath}


\begin{document}


A paragraph of text with $x^2+y^2=z^2$ some math(s).
Other examples might be $\frac{1}{2}\int_0^nx dx$
and $\sqrt{x}$.
A paragraph of text with $x^2+y^2=z^2$ some math(s).
Other examples might be $\frac{1}{2}\int_0^nx dx$
and $\sqrt{x}$.
A paragraph of text with $x^2+y^2=z^2$ some math(s).
Other examples might be $\frac{1}{2}\int_0^nx dx$
and $\sqrt{x}$.


\bigskip

\hrule
\bigskip

\everymath{\displaystyle}

A paragraph of text with $x^2+y^2=z^2$ some math(s).
Other examples might be $\frac{1}{2}\int_0^nx dx$
and $\sqrt{x}$.
A paragraph of text with $x^2+y^2=z^2$ some math(s).
Other examples might be $\frac{1}{2}\int_0^nx dx$
and $\sqrt{x}$.
A paragraph of text with $x^2+y^2=z^2$ some math(s).
Other examples might be $\frac{1}{2}\int_0^nx dx$
and $\sqrt{x}$.

\end{document}
David Carlisle
  • 757,742
  • Wow. I had no idea. My way of writing may completely change now. Thanks for explaining why the text is always small. – Kevin Aug 04 '16 at 15:47
  • 1
    I'm a bit confused here. The consensus here seems to be that inline display math is bad. But is the only argument here that the second paragraph is more unreadable than the first in the above example? Personally I don't find the second paragraph any less readable than the first. (In fact I probably prefer the second.) –  May 12 '18 at 08:15
  • 2
    @dtcm840 people can like what they like, but you are in the minority:) a few hundred years of typesetting tradition (and a few decades of scientific testing) show that maintaining a consistent line spacing makes large blocks of text easier to read. The example above isn't good as if there were that much math the linespacing should be larger anyway so it is not so cramped, but the point is to maintain a consistent line spacing. A multi-paragraph example with the second setting would have spacing between lines within one para larger than the space between paragraphs which would be confusing. – David Carlisle May 12 '18 at 08:22
  • 1
    Thanks for clearing it up; so it really is just this. By the way, you mention that there've been "a few decades of scientific testing" --- could you point me to some of the literature on this? –  May 12 '18 at 08:39
  • @dtcm840 I wondered if you would pick me up for making assertions with no reference:-) I have been to a few talks over the years and read a few typesetting books... I'll see if I can find a relevant reference and add a link here, but no promises:-) – David Carlisle May 12 '18 at 09:02
7

I don't really recommend this, but \everymath{\displaystyle} is a way to achieve the display style for math content, i.e. for inline math content as well.

In my opinion the usage of the various align like environments should be preferred or \[...\].

Please consider also \dfrac{2}{3} for example as a 'nicer' way of displaying fractions.

As Zarko stated in comment: Using \displaystyle all the way will increase the spacing between the lines and leaves a disrupted look of the page.

Again: Don't do it.

\documentclass{book}

\usepackage{mathtools}

\begin{document}

$E=mc^2 = \frac{mc^2}{1}$


$\frac{2}{3}$ 

or

$\int_{0}^{\infty} e^{-5x}dx$. 

or

\[ \frac{2}{3} \]

or

\[ \int_{0}^{\infty} e^{-5x}dx \]


\everymath{\displaystyle}

$\frac{2}{3}$ 

or

$\int_{0}^{\infty} e^{-5x}dx$. 

\begin{align*}
\int_{0}^{\infty} e^{-5x}\mathrm{d}x &= \dots
\end{align*}


$\dfrac{2}{3}$


\end{document}
  • It sounds like the consensus here is that the command I have been using for so long is not recommended at all. That is interesting. I self taught myself latex, so I ran with what I could figure out. So the align command you used in your example will get the job done, and do it better? – Kevin Aug 04 '16 at 15:33
  • @Kevin: There are various related environments: align, alignat, equation etc. and the starred variants, that omit numbering of equations. It's up to you to decide which environment is best for your needs. –  Aug 04 '16 at 15:35
  • @Kevin it's not that \displaystyle shouldn't be used, it's that it doesn't really belong here. If, for example, you want a summation in a fraction and you want the full size symbol (actually I wouldn't recommend this at all and it could get very ugly, but if one insists) you'd need to use \displaystyle there. Also for integrals in superscripts (again, you'd be better off just not) – Au101 Aug 04 '16 at 15:38
  • @ChristianHupfer, maybe is worth to mentioned, that sometimes in display equation we use \tfrac{...}{...} for have fraction in \textstyle ... – Zarko Aug 04 '16 at 15:50
  • @Kevin Note also that if you have just a single equation, then you shouldn't use environments intended for displays with multiple lines (e.g. align and gather), as the vertical space inserted before it might be bigger. (align vs equation) One should also avoid having paragraph breaks (empty lines) immediately before displayed equations, again because this can introduce extra vertical space. – Torbjørn T. Aug 04 '16 at 16:23
  • @TorbjørnT. unless you actually intend to end the paragraph there, of course :) – Au101 Aug 04 '16 at 16:27
  • 2
    @Au101 Well, yes. Some would argue that you should never start a paragraph with a displayed equation though. I seem to remember a certain high-rep Italian mathematician saying something like that. – Torbjørn T. Aug 04 '16 at 16:30
  • 1
    @TorbjørnT. -- it isn't only the opinion of the "certain high-rep Italian mathematician". established practice for math composition dictates that displayed math should not begin a paragraph -- or start at the top of a page. – barbara beeton Aug 04 '16 at 18:34
  • @barbarabeeton: Please consider also that there from a teaching point of view there should be a distinction between how math is typeset. University level is not always the measure of typography here! Apparently many are unsatisfied with my 'solution' here :-( –  Aug 04 '16 at 18:37
  • @ChristianHupfer -- my only objection is the blank line before the lines beginning a display environment. (here the \[ ... \].) for pedagogical purposes, the other parts of the examples can be considered separate paragraphs, even if they consist of only the one word "or". – barbara beeton Aug 04 '16 at 18:42
  • @barbarabeeton: But my solution is a suggestion about the displaystyle itself, not about blank lines etc. I think, this discussion about starting/ending started above is off-topic for this specific question, leading to a strong bias in reception of my answer by others. –  Aug 04 '16 at 18:45