tikz: prefijo y posfijo para el texto de cada nodo

tikz: prefijo y posfijo para el texto de cada nodo

Para configurar el interlineado de un nodo para texto de varias líneas, me veo obligado a anteponer el texto \baselineskip=2.5exy agregar uno adicional \pardespué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 postactiony preactionsparámetros que no me ayudan. El siguiente código no produce un espacio entre líneas correcto ( \parparece 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 nodey /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}

ingrese la descripción de la imagen aquí

Eliminé lo innecesario remember picture, overlay, aumenté los 3 cm a 3,2 cm para evitar un exceso \hboxen el segundo nodo y aumenté el \baselineskip=2.5exde \baselineskip=5expara que su efecto fuera más visible. Esto \relaxgarantiza que TeX no intente expandir los tokens después de 5exleer el valor asignado a \baselineskip.

Respuesta2

Puedes usar font. Vea si esto funciona para usted. Yo suelo \baselineskip=5exenfatizar 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}

ingrese la descripción de la imagen aquí

información relacionada