0

It is easy to see that the following code will automatically change the line spacing for the line with {\huge test} but leave the other part of this paragraph untouched.

\documentclass{book}
\usepackage{blindtext}
\begin{document}
    \blindtext {\huge test} \blindtext
\end{document}

So, my question is how to realize this functionality manually. I've tried to change the \baselineskip by hand but to my experience it seems that this will change all the line spacing in this paragraph. (Of course, I will have to change it back after the current paragraph to keep the text afterwards untouched.)

  • \vspace{3cm} if used mid-paragraph will add 3cm of space after just one line. – David Carlisle Apr 25 '22 at 16:02
  • @DavidCarlisle Just like that {\huge test} only increases the upper spacing, this \vspace{3cm} method only increases the lower spacing, how can one realize the increase of spacing symmetrically? – Qi Tianluo Apr 25 '22 at 17:48
  • 2
    You can use \rule[-1ex]{0pt}{3ex} (play with the values until they fit your liking). – Skillmon Apr 25 '22 at 20:07
  • Note that \baselineskip=\ht\strutbox+\dp\strutbox if you want to maintain proportionality. There is also \vphantom{\huge test}. – John Kormylo Apr 26 '22 at 13:07

1 Answers1

1

It requires some writing, but a minipage will do the job without guesses

\begin{minipage}[c][3\baselineskip][c]{5em}\strut \centering \huge test\end{minipage}

It will define a box 3 baselineskip high, slightly wider than its content and have it centered.

c

\documentclass{book}
\usepackage{blindtext}
\begin{document}

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam lobortis facilisis sem.\begin{minipage}[c][3\baselineskip][c]{5em} \strut\centering \huge test\end{minipage} \blindtext

\end{document}

\begin{minipage}[position][height][inner-pos]{width} ... \end{minipage}

The first optional argument position governs how the minipage vertically aligns with the surrounding material. (c,t, b)

The second optional argument height sets the height of the minipage.

The final optional argument inner-pos controls the vertical placement of contents inside the box.

The solution is not exact. The strut helps to mitigate the extra vertical space added by the minipage.

For a detailed explanation see constant-baselineskip-when-using-minipages

To check the horizontal alignment try \begin{minipage}[c][1\baselineskip][c]{2em} \strut \centering test\end{minipage}

Simon Dispa
  • 39,141
  • The baseline is just a bit different for the text in the minipage. Ideally, it should be the same as for the main text on the same line. – barbara beeton Apr 26 '22 at 18:09