5

I can put display math in the middle of a paragraph of text using \[...\], but I would like the math to use font size small. If I wrap the display block in {\small...} the second half of the paragraph, beginning with the word "centuries", starts with a small amount of unwanted whitespace. This goes away if I remove the {\small...}. enter image description here

\documentclass{article}

\begin{document}
Lorem Ipsum is simply dummy text of the printing and typesetting
industry. Lorem Ipsum has been the industry's standard dummy text ever
since the 1500s, when an unknown printer took a galley of type and
scrambled it to make a type specimen book. It has survived not only five
{\small\[
A / B + C = D
\]}
centuries, but also the leap into electronic typesetting, remaining
essentially unchanged. It was popularised in the 1960s with the release
of Letraset sheets containing Lorem Ipsum passages, and more recently
with desktop publishing software like Aldus PageMaker including versions
of Lorem Ipsum.
\end{document}

I guess I'm going about this in the wrong way. Help?

6
  • 2
    You need to add a % (comment) character immediately after \]}.
    – Mico
    Commented Feb 24, 2016 at 11:34
  • That seems to work - thanks! Out of interest, what's going on here? (Moving \small inside the \[...\] also seems to fix it.)
    – Roly
    Commented Feb 24, 2016 at 11:38
  • 1
    Whitespace is removed after control words (backslash plus one or more alphabetical characters), but not after control symbols (backslash plus a single non-alphabetical character}. Line breaks are treated as whitespace. Thus, from TeX's point of view, \]} forms a control symbol plus }, which ends a group. Thus, the following whitespace character is not discarded. Get rid of it either by providing a comment character or by providing a suitable control word, say, \noindent.
    – Mico
    Commented Feb 24, 2016 at 11:43
  • 1
    @Roly Not really: moving \small inside \[ produces a warning that shouldn't be disregarded.
    – egreg
    Commented Feb 24, 2016 at 11:46
  • 1
    The space is unrelated to \small it is just the space after } (try with just the braces and no font change.) Commented Feb 24, 2016 at 11:49

1 Answer 1

6

You get two spurious spaces: one at the start of the line, which is more evident, but also tighter vertical space above the display than below, because you're using the above skip pertaining to \small, but the below skip pertaining to \normalsize.

You can emulate the standard behavior:

\documentclass{article}

\begin{document}

Lorem Ipsum is simply dummy text of the printing and typesetting
industry. Lorem Ipsum has been the industry's standard dummy text ever
since the 1500s, when an unknown printer took a galley of type and
scrambled it to make a type specimen book. It has survived not only five
{\par\penalty\predisplaypenalty\small\[
A / B + C = D
\]\par}\penalty\postdisplaypenalty\noindent
centuries, but also the leap into electronic typesetting, remaining
essentially unchanged. It was popularised in the 1960s with the release
of Letraset sheets containing Lorem Ipsum passages, and more recently
with desktop publishing software like Aldus PageMaker including versions
of Lorem Ipsum.

\end{document}

enter image description here

You could define a vardisplaymath environment:

\makeatletter
\newenvironment{vardisplaymath}[1][\small]
 {\par\penalty\predisplaypenalty\begingroup#1\begin{displaymath}}
 {\end{displaymath}\par\endgroup\penalty\postdisplaypenalty
  \@endparenv}
\makeatletter

Full example:

\documentclass{article}

\makeatletter
\newenvironment{vardisplaymath}[1][\small]
 {\par\penalty\predisplaypenalty\begingroup#1\begin{displaymath}}
 {\end{displaymath}\par\endgroup\penalty\postdisplaypenalty
  \@endparenv}
\makeatletter

\begin{document}

Lorem Ipsum is simply dummy text of the printing and typesetting
industry. Lorem Ipsum has been the industry's standard dummy text ever
since the 1500s, when an unknown printer took a galley of type and
scrambled it to make a type specimen book. It has survived not only five
\begin{vardisplaymath}
A / B + C = D
\end{vardisplaymath}
centuries, but also the leap into electronic typesetting, remaining
essentially unchanged. It was popularised in the 1960s with the release
of Letraset sheets containing Lorem Ipsum passages, and more recently
with desktop publishing software like Aldus PageMaker including versions
of Lorem Ipsum.
\begin{vardisplaymath}[\footnotesize]
A / B + C = D
\end{vardisplaymath}
centuries, but also the leap into electronic typesetting, remaining
essentially unchanged. It was popularised in the 1960s with the release
of Letraset sheets containing Lorem Ipsum passages, and more recently
with desktop publishing software like Aldus PageMaker including versions
of Lorem Ipsum.

\end{document}

enter image description here

This could be adjusted to always get the parameters from \normalsize.

Thanks to Tobi for suggesting an improvement.

A simpler approach that doesn't require plunging into details such as \penalty\postdisplaypenalty (needed in order to avoid page breaks after the display) and keeping the above and below skips from \normalsize is

\newsavebox{\vardisplaymathbox}
\newenvironment{vardisplaymath}[1][\small]
  {\begin{displaymath}\begin{lrbox}{\vardisplaymathbox}
   #1$\displaystyle}
  {$\end{lrbox}\usebox{\vardisplaymathbox}\end{displaymath}%
   \ignorespacesafterend}

The result with this definition is

enter image description here

14
  • Removing the instructions \penalty\predisplaypenalty and \penalty\postdisplaypenalty doesn't seem to generate a visible effect. Could you explain that they maybe guard against?
    – Mico
    Commented Feb 24, 2016 at 11:39
  • @Mico Without \penalty\postdisplaypenalty you might get a page break after the display.
    – egreg
    Commented Feb 24, 2016 at 11:43
  • Your new environment vardisplaymath would’t work, if the following text actually is a new paragraph, would it? Since the \noindent prevents the indention in this case too.
    – Tobi
    Commented Feb 24, 2016 at 11:48
  • @Tobi Yes, that's true. :(
    – egreg
    Commented Feb 24, 2016 at 11:51
  • Thanks for the detailed answer. Unfortunately your first vardisplaymath macro doesn't work for me - it produces too much space above the math, so that the math is no longer vertically centred between the two halves of the paragraph. I'll experiment some more.
    – Roly
    Commented Feb 24, 2016 at 12:19

You must log in to answer this question.

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