5

In the code below, how can I increase line spacing in the node?

\documentclass{book}
\usepackage{lipsum}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[overlay,remember picture]
\node (example-align) [draw,align=left,text width=8cm] at (5,-5) {\lipsum[1]};
\end{tikzpicture}
\end{document}
  • @LaRiFaRi: I saw it before. It doesn't solve my problem. – Sisabe Jan 14 '15 at 8:35
  • if \node (example-align) [draw,align=left,text width=8cm] at (5,-5) {\baselineskip=16pt\lipsum[1]}; does not work for you, you will have to update your system or expand your MWE to the actual problem. Or I do not understand the issue you are having. Please clarify. – LaRiFaRi Jan 14 '15 at 8:40
  • @LaRiFaRi: Wow, it does! Thanks. please post your comment as an answer so that I can accept it. – Sisabe Jan 14 '15 at 8:50
8

You can define the \baselineskip in the inner of your node:

% arara: pdflatex

\documentclass{book}
\usepackage{lipsum}
\usepackage{tikz}

\begin{document}
    \begin{tikzpicture}[overlay,remember picture]
    \node (1) [draw,align=left,text width=2cm, anchor=north] at (1,0) {\baselineskip=10pt\lipsum[1]};
    \node (2) [draw,align=left,text width=2cm, anchor=north] at (4,0) {\baselineskip=12.5pt\lipsum[1]};
    \node (3) [draw,align=left,text width=2cm, anchor=north] at (7,0) {\baselineskip=15pt\lipsum[1]};
    \end{tikzpicture}
\end{document}

enter image description here

  • 7
    And a tip: If one wants to replace \lipsum[1] with real text, he/she must enter a \par after the end of the real text. – Sisabe Jan 14 '15 at 9:09
  • 2
    If text width is not set, then the \baselineskip setting only works if it is set in the tikz style of the node: \tikz \node[align=left, execute at begin node=\setlength{\baselineskip}{5ex}] {foo\\bar}; – Thorsten Nov 6 '19 at 19:10

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