7

When I try to set the font size for a tikz node that contains a line break ("\\ ") the font size is only set for the first line:

\documentclass{article}
\usepackage{tikz}
\usepackage{fontspec}
\setmainfont{Arial}

\begin{document}
    \begin{tikzpicture}
        \begin{scope}
            \node[align=left] at (0,0) {\fontsize{5pt}{5pt}\selectfont first line\\ second line};
        \end{scope}
    \end{tikzpicture}
\end{document}

example

How can I set the font size for the whole node?

1
  • Thanks for this question. I made a feature out of this bug. :)
    – Dirk
    Mar 22, 2023 at 13:57

1 Answer 1

6

Use font=\fontsize{5pt}{5pt}\selectfont in the node options.

output of code

\documentclass{article}
\usepackage{tikz}
%\usepackage{fontspec} %commented because it's not really relevant
%\setmainfont{Arial}

\begin{document}
    \begin{tikzpicture}
        \begin{scope}
            \node[align=left,font=\fontsize{5pt}{5pt}\selectfont] at (0,0) {first line\\ second line};
        \end{scope}
    \end{tikzpicture}
\end{document}

(\fontsize{size}{baselineskip})

You must log in to answer this question.

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