6

I am using .pic to use a same picture several times. I noticed a difference of behavior between the same code inside a .pic or outside. In the example below, one can notice that within a .pic, the node on the edge is not at the place it should be.

\documentclass{standalone}
\usepackage{tikz}
\tikzset{thepic/.pic = {\draw (0, 0) edge node {0} (1, 0);}}
\begin{document}
Without \texttt{.pic}: \tikz{\draw (0, 0) edge node {0} (1, 0);}
With \texttt{.pic}: \tikz{\pic{thepic};} 
\end{document}

The result

enter image description here

Is this a (known) bug?

  • 1
    Better picture provided. I also checked with the article class also defining the pic after \begin{document}, just to be sure: the result is the same. – egreg Nov 10 '16 at 13:37
8

I don't know the cause for this problem, it's probably related to the path construction with .pic. But if you explicitly say that the node should be in the path midway it works normally:

\documentclass{standalone}
\usepackage{tikz}
\tikzset{thepic/.pic = {\draw (0, 0) edge node[midway]{0} (1, 0);}}
\begin{document}
Without \texttt{.pic}: \tikz{\draw (0, 0) edge node {0} (1, 0);}
With \texttt{.pic}: \tikz{\pic{thepic};} 
\end{document}

enter image description here

  • You are welcome. The path construction with pics is not very clear to me either. But it does respect the explicit instructions given. =D – Guilherme Zanotelli Nov 10 '16 at 16:43

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.