Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have the following code snippet. In that i define the node (B) with the coordinate operation. Unfortunately i can't access the node later on. LuaLatex exits with the error message:

Package pgf Error: No shape named B is known.

\documentclass{standalone}

\usepackage{tikz}

\usetikzlibrary{calc}

\begin{document}

    \begin{tikzpicture}[>=latex]

        \tikzset{%
            auto/.pic={%
                \draw[fill=black!20] (0,10pt)
                    node[fill=black!20,anchor=south,
                            draw,rectangle,
                            minimum width=3cm,
                            minimum height=0.75cm] (-A) {};

                \draw[fill=black]
                    ($(-A.south west)!0.2!(-A.south east)$) circle (10pt);
                \draw[fill=black] 
                    ($(-A.south west)!0.8!(-A.south east)$) circle (10pt);
            }
        }

        % define node (B)
        \draw[rotate=30,every node/.style={rotate=30}] 
            (0,0) coordinate (A) -- 
            (4,0) pic (Auto) {auto} -- 
            (8,0) coordinate (B);

        \draw[->, line width=1pt] 
            (Auto-A.center) -- +(0,-2) node[midway,right]{$\vec F$};

        % can't access (B)
        \draw (A) -- (B);

    \end{tikzpicture}

\end{document}
share|improve this question
2  
Keep the pic inside braces; {pic (Auto) {auto}}. It turns on the picture syntax but doesn't turn off so braces limit the scope. –  percusse Feb 18 at 21:53

1 Answer 1

up vote 4 down vote accepted

Use a pair of braces around the Auto pic:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}

    \begin{tikzpicture}[>=latex,]

        \tikzset{%
            auto/.pic={%
                \draw[fill=black!20] (0,10pt)
                    node[fill=black!20,anchor=south,
                            draw,rectangle,
                            minimum width=3cm,
                            minimum height=0.75cm] (-A) {};
                \draw[fill=black]
                    ($(-A.south west)!0.2!(-A.south east)$) circle (10pt);
                \draw[fill=black] 
                    ($(-A.south west)!0.8!(-A.south east)$) circle (10pt);
            }
        }

        % define node (B)
        \draw[rotate=30,every node/.style={rotate=30}] 
            (0,0) coordinate (A) -- 
            (4,0) {pic (Auto) {auto}} -- 
            (8,0) coordinate (B);

        \draw[->, line width=1pt] 
            (Auto-A.center) -- +(0,-2) node[midway,right]{$\vec F$};

        % can access (B)
        \draw (A) -- (B);

    \end{tikzpicture}

\end{document}

enter image description here

share|improve this answer
1  
Ok we need a photo finish for this :) –  percusse Feb 18 at 21:54
1  
@percusse Indeed! :) –  Gonzalo Medina Feb 18 at 21:55
    
Thanks a lot guys for your super fast answers! –  user1146332 Feb 18 at 22:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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