
Para configurar el interlineado de un nodo para texto de varias líneas, me veo obligado a anteponer el texto \baselineskip=2.5ex
y agregar uno adicional \par
después dentro de cada nodo. ¿Hay alguna manera de evitar hacer esto repetidamente?
\documentclass{report}
\usepackage{tikz}
\usetikzlibrary{calc,fit,positioning}
\begin{document}
\begin{tikzpicture}[
remember picture, overlay,
every node/.style={fill=green, font=\large}
]
\node (N0)
at (0,0)
{Start}; % <- That's what I want for multi-line text: Only the text
\node[right=of N0, text width=3cm, align=center] (N1)
{\baselineskip=2.5ex Looooooooooong multi-line text.\par}; % <- That's what's required
\node[right=of N1, text width=3cm, align=center] (N2)
{\baselineskip=2.5ex Another looooooooooong multi-line text.\par};
\end{tikzpicture}
\end{document}
¿Existen parámetros de estilo de nodo para definir dichos comandos previos y posteriores?Allí existe postaction
y preactions
parámetros que no me ayudan. El siguiente código no produce un espacio entre líneas correcto ( \par
parece ignorarse).
%...
every node/.style={fill=green, font=\large, postaction={\par}}
%...
\node[right=of N1, text width=3cm, align=center] (N2)
{\baselineskip=2.5ex Another looooooooooong multi-line text.};
%...
¿Algunas ideas?
Respuesta1
No veo ninguna necesidad de \par
, pero puedes usar /tikz/execute at begin node
y /tikz/execute at end node
:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[
every node/.style={fill=green, font=\large},
execute at begin node={\baselineskip=5ex\relax},
% execute at end node={\endgraf}% not needed, as far as I can see
]
\node (N0) at (0,0) {Start};
\node[right=of N0, text width=3.2cm, align=center] (N1)
{Looooooooooong multi-line text.};
\node[right=of N1, text width=3.2cm, align=center] (N2)
{Another looooooooooong multi-line text.};
\end{tikzpicture}
\end{document}
Eliminé lo innecesario remember picture, overlay
, aumenté los 3 cm a 3,2 cm para evitar un exceso \hbox
en el segundo nodo y aumenté el \baselineskip=2.5ex
de \baselineskip=5ex
para que su efecto fuera más visible. Esto \relax
garantiza que TeX no intente expandir los tokens después de 5ex
leer el valor asignado a \baselineskip
.
Respuesta2
Puedes usar font
. Vea si esto funciona para usted. Yo suelo \baselineskip=5ex
enfatizar la diferencia.
\documentclass{report}
\usepackage{tikz}
\usetikzlibrary{calc,fit,positioning}
\begin{document}
\begin{tikzpicture}[
remember picture, overlay,
every node/.style={fill=green, font=\large},
baselineskip/.style={font={\large\baselineskip=#1}}
]
\node (N0)
at (0,0)
{Start}; % <- That's what I want for multi-line text: Only the text
\node[right=of N0, text width=3cm, align=center,baselineskip=5ex] (N1)
{Looooooooooong multi-line text.}; % <- That's what's required
\node[right=of N1, text width=3cm, align=center,baselineskip=5ex] (N2)
{Another looooooooooong multi-line text.};
\end{tikzpicture}
\end{document}