4

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?

2

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}

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.