2

I am new in tikz,I am manually create an image,In that figure coloured part shows that highlight the label how I do this by tikz I am using the following code for the label, How alter this code.

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

enter image description here

3
  • 3
    Welcome to TeX.SX!! Can you please post a full minimal working example showing how you got your graph. A MWE should start with a \documentclass command, have a minimal preamble and then \begin{document}...\end{document}. The code should compile and be as small as possible to demonstrate your problem. This makes it much easier for people to help you --- and much more likely that they will! – user30471 Jun 10 '16 at 6:15
  • It's rather hard for me to understand what you actually want to do. Are you after \node [transform shape,rotate=0,color=black,fill=black!10] (Label) at (0,0) {0};, so the background of the node is filled with gray? – Torbjørn T. Jun 10 '16 at 6:33
  • @ Andrew and Torbjørn T. I am crete this figure using photoshop, for understanding purpose I am include this figure and now I am update the code and In that code contains 5 labels I want to highlight labels like in figure – Kevin Jun 10 '16 at 6:56
3

Remove the color=black option, and apply a style to each node via every node/.style=:

enter image description here

Code:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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