tikz: 各ノードのテキストの先頭と末尾に付加する

tikz: 各ノードのテキストの先頭と末尾に付加する

複数行テキストのノードの行間隔を設定するには、各ノード内で テキストの前に を付け\baselineskip=2.5ex、その後に追加する必要があります。これを繰り返し実行しないようにする方法はありますか?\par

\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}

このような接頭コマンドと接尾コマンドを定義するノード スタイル パラメーターはありますか?が存在します postactionおよびpreactionsパラメータは役に立ちません。次のコードでは、正しい行間隔が生成されません (\par無視されるようです)。

%...
    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.};
%...

何か案は?

答え1

の必要性はわかりませんが、と を\par使用できます。/tikz/execute at begin node/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}

ここに画像の説明を入力してください

不要な を削除しremember picture, overlay、 を 3cm から 3.2cm に増やして\hbox2 番目のノードがいっぱいにならないようにし、の効果をより目立たせるために\baselineskip=2.5exを に増やしました。 は、に割り当てられた値を読み取るときに、TeX が の後のトークンを展開しないようにします。\baselineskip=5ex\relax5ex\baselineskip

答え2

を使用できますfont。これが機能するかどうかを確認してください。私は\baselineskip=5ex違いを強調するために を使用します。

\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}

ここに画像の説明を入力してください

関連情報