8

I'm trying to include a few lines of text in a Tikz drawing, using a custom font size. However, when defining a font size, the baselineskip is only respected for the first line. See the minimal working example, below.

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
    \node[text width=4cm] {\fontsize{14pt}{20pt}\selectfont Foo\\Bar\\Baz};
\end{tikzpicture}

\end{document}

This results in:

Foo\Bar\Baz

I would like to have the lines evenly spaced out. Should I approach this differently?

2
  • 1
    Give an option [,font=\fontsize{14pt}{20pt}\selectfont] instead
    – percusse
    Commented Mar 1, 2015 at 11:49
  • That's not an option, really. I'm switching multiple font sizes in some of the nodes.
    – Joost
    Commented Mar 1, 2015 at 16:39

1 Answer 1

8

Hmm Tikz ought to fix that, but meanwhile make sure you have a \par or blank line in the scope of any font size change,

enter image description here

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
    \node[text width=4cm] {\fontsize{14pt}{20pt}\selectfont Foo\\Bar\\Baz\par};
\end{tikzpicture}

\end{document}
7
  • Hmm, additionaly context is relevant here; it's taking place inside a fancyhf header element, and that does not accept ending paragraphs. Anything I can do in that case?
    – Joost
    Commented Mar 1, 2015 at 11:56
  • @Joost use \endgraf instead of \par (but Tikz ought to have done it for you:-) Commented Mar 1, 2015 at 11:58
  • TikZ does it if you provide the option in the appropriate option.
    – percusse
    Commented Mar 1, 2015 at 12:14
  • @percusse it should do it anyway I think. a node with a width is in all other respects a \parbox and parboxes (or even a primitive \vbox) always have an implied end of para at the end. Tikz nodes not doing that is mightily odd, if not absolutely a bug. Commented Mar 1, 2015 at 12:16
  • 1
    @percusse sure but I can see no case where putting the users text in vmode without ending the paragraph is ever the right thing to do. Certainly no standard latex command ever does that. Picture mode never does that (I knew there was a reason I stuck with that:-) Commented Mar 1, 2015 at 12:23

You must log in to answer this question.

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