[Tex/LaTex] Linespacing changes randomly

appendicesline-spacing

In my latex document I'm using a linespacing of 1.5. For the appendix I set it to 1.1 with the linespread command:

\begin{appendix}
    \clearpage
    \pagenumbering{roman}

    \setdefaultleftmargin{1em}{}{}{}{}{}
    \linespread{1.1}\selectfont
    \section{Appendix}
      \subsection{Test 1}
      Lorem ipsum ...
      \subsection{Test 2}
      Lorem ipsum ...
\end{appendix}

This works for the whole appendix, except for the last subsection, no matter how many subsections there are. There it just randomly switches back to a linespacing of 1.5 again. Even if I put the linespread command in this last subsection it wont have the linespacing. Any clues how I could apply the linespacing to the whole appendix?

Best Answer

If \appendix had been designed as an environment, then \endappendix would have been defined to add \par which is equivalent to a blank line and avoided the problem. As it is \end{appendix} is just \endgroup as such you have something equivalent to

\begingroup
\linespread{1.1}\selectfont
a paragraph of text
\endgroup

..

The linespacing is a paragraph parameter and the value used is the value at the end of the paragraph. The paragraph ends at the blank line after the group ends, at which point the values have reset to the values they had before the group. If instead you have

\begingroup
\linespread{1.1}\selectfont
a paragraph of text

\endgroup

..

Then the paragraph ends at the blank line before the group ends and so is set with the local paragraph settings.

Related Question