25

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}

enter image description here

Any clue?

  • 3
    Add a \par after does it work? inside the braces and you'll see the effect – clemens Dec 5 '13 at 14:00
  • It works! I never use this \par... – Colas Dec 5 '13 at 14:23
  • 1
    \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. – clemens Dec 5 '13 at 14:28
  • @cgnieder Please make your comments an answer (unless you can find a dupe to link to) – Joseph Wright Jan 11 '14 at 9:18
  • Note that loading fontspec for Xelatex of Lualatex, you do not need to explicitly load anyfontsize. – Jonathan Komar Apr 21 '17 at 8:15
21

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}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.