2

When I compile the following code

\documentclass[tikz]{standalone}

\usepackage{luatex85}
\usetikzlibrary{positioning}
\usetikzlibrary{calc}
\usetikzlibrary{quotes}
\usetikzlibrary{shadows}

\begin{document}
\begin{tikzpicture}[
  rect/.style={rectangle},
  sum/.style={draw,circle,minimum width=0.2cm,minimum height=0.2cm,fill=white,drop shadow={shadow xshift=.3ex,shadow yshift=-.3ex}},
  dot/.style={fill,circle,inner sep=1pt,outer sep=0pt}, 
  pics/integrator/.style args={#1 and #2}{
    code={
      \node[sum] (-in) {};
      \node[dot,right=1.5*\a of -in.center,"above:#2"] (-out) {};
      \node[rect,below=0.5*\a of $(-in.center)!0.5!(-out.center)$,
        "left:#1"{font=\scriptsize,yshift=-0.25cm}] (-int) {$z^{-1}$};
      \draw (-in.center) -- (-out.center);
      \draw[-latex] (-int.center) -| (-in.center);
      \draw[-latex] (-out.center) |- (-int.center);
    }
  }
]  
  \def\a{1cm}
  \pic (int) {integrator=$x_1(k)$ and $B_{coil}$}; 
  \end{tikzpicture}
\end{document}

with the lualatex compiler I get a strange error message:

! Package pgf Error: No shape named intcurrent path bounding box is known.
l.29 ...c (int) {integrator=$x_1(k)$ and $B_{coil}$};

When I remove the name prefix everything compiles fine.

Edit: I tried the workaround from the linked questions, by adding .center to every node, but that gives me the same error message as before. I also tested the passing of the name to the pic and resetting the name prefix inside the draw command. Also the same error persists.

Reza
  • 1,798
  • It's a known bug and reported to the PGF/TikZ bug tracker. You can check the duplicate for a workaround – percusse Aug 10 '17 at 11:18
  • I did try your workaround, but the error persists. I'm pretty sure this is another problem, possibly related to the mentioned one – Reza Aug 10 '17 at 11:35
  • 2
    Don't do this: \def\a{1cm} outside the picture! – cfr Aug 10 '17 at 13:24
  • @cfr what is the reason for doing this inside the picture environment? – Reza Aug 10 '17 at 13:42
  • 1
    If you say \def\a outside the picture, you will overwrite any existing macro \a with no warning. If you want it to be global, use \newcommand or, better, \newlength and \setlength. If you want to set \a regardless, do it in the tikzpicture so it doesn't affect your entire document. \def\<single letter> is very, very likely to be overwriting something LaTeX or TeX has already defined and \def does no checking whatsoever. Stuff will just break. – cfr Aug 10 '17 at 23:16
  • Can you edit your question to show how you tried to apply the workaround and which workaround you used? Right now, it is not obvious why this isn't a duplicate. If you can show that the workarounds in the linked question don't work, then it will be clearer why it isn't a duplicate. – cfr Aug 10 '17 at 23:19
  • You probably need e.g. 1.5*\a{} of as the \a will gobble the following space. – cfr Aug 10 '17 at 23:23
  • This does not prevent the error from happening – Reza Aug 11 '17 at 09:00
  • Please read my suggestion above about editing your question. How did you apply whichever workaround you tried? – cfr Aug 11 '17 at 16:01

1 Answers1

2

This is why:

pic
sum
drop shadow
general shadow
(current path bounding box.center)
\pgfpointanchor{intcurrent path bounding box}{center}
intcurrent path bounding box is not a valid name.

See How to give a name to \pic.

Symbol 1
  • 36,855