# How does \fontsize{}{} work?

With the package anyfontsize I can use the command \fontsize{}{}. But the second argument seems to be without any effect. I read there that it is related to the line space. It doesn't work.

\documentclass{article}
\usepackage{anyfontsize}
\begin{document}

{\fontsize{1cm}{1cm}\selectfont First test : I need to put some text here.}

\bigskip

{\fontsize{1cm}{2cm}\selectfont Second test : I need to put some text here --- does it work?}

\end{document}


Any clue?

• Add a \par after does it work? inside the braces and you'll see the effect Dec 5, 2013 at 14:00
• It works! I never use this \par... Dec 5, 2013 at 14:23
• \par ends a paragraph (the same what an empty line does). In your case the font changes are forgotten when the paragraph is ends so when it is typeset the new baselineskip also is forgotten. \par ensures that the paragraph is ended and typeset before the closing brace. Dec 5, 2013 at 14:28
• Note that loading fontspec for Xelatex of Lualatex, you do not need to explicitly load anyfontsize. Apr 21, 2017 at 8:15

You need to end the paragraph before you close the group. While the fontsize is updated when you issue \selectfont the new leading only is updated when the paragraph is ended. In your case the group ends (with }) before the paragraph ends (the empty line after the line end). Either write

{\fontsize{1cm}{2cm}\selectfont Second test : I need to put some text here ---
does it work?

}


or use \par at the end:

{\fontsize{1cm}{2cm}\selectfont Second test : I need to put some text here ---
does it work?\par}

\documentclass{article}
\usepackage{anyfontsize}
\begin{document}

{\fontsize{1cm}{1cm}\selectfont First test : I need to put some text here.\par}

\bigskip

{\fontsize{1cm}{2cm}\selectfont Second test : I need to put some text here ---
does it work?\par}

\end{document}