ノード内のラベルを強調表示します

ノード内のラベルを強調表示します

私は tikz の初心者で、手動で画像を作成しています。この図では、色付きの部分がラベルを強調表示しています。tikz でこれをどのように行うかを示します。ラベルには次のコードを使用していますが、このコードを変更する方法を教えてください。

    \documentclass[a3paper]{article}
\usepackage{
            calc,
            graphicx,
            eso-pic,
            tikz,
            }



\begin{document}
\begin{tikzpicture}
  \begin{scope}[local bounding box=scope1]
    \draw (2.1,8) rectangle (6,4);
    \node [transform shape] (Label) at (1.5,4)[rotate=0,color=black] {label-1};
    \node [transform shape] (Label) at (1.5,5)[rotate=0,color=black] {label-2};
    \node [transform shape] (Label) at (1.5,6)[rotate=0,color=black] {label-3};
    \node [transform shape] (Label) at (1.5,7)[rotate=0,color=black] {label-4};
    \node [transform shape] (Label) at (1.5,8)[rotate=0,color=black] {label-5};
  \end{scope}
\end{tikzpicture}
\end{document}

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

答え1

オプションを削除しcolor=black、次のように各ノードにスタイルを適用しますevery node/.style=

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

コード:

\documentclass[a3paper]{article}
\usepackage{calc,graphicx,eso-pic,tikz,}

\tikzset{My Node Style/.style={draw=pink, fill=pink, fill opacity=0.50, text opacity=1}}

\begin{document}
\begin{tikzpicture}
  \begin{scope}[local bounding box=scope1,
  every node/.style={My Node Style}
  ]
    \draw (2.1,8) rectangle (6,4);
    \node [transform shape] (Label) at (1.5,4) {label-1};
    \node [transform shape] (Label) at (1.5,5) {label-2};
    \node [transform shape] (Label) at (1.5,6) {label-3};
    \node [transform shape] (Label) at (1.5,7) {label-4};
    \node [transform shape] (Label) at (1.5,8) {label-5};
  \end{scope}
\end{tikzpicture}
\end{document}

関連情報