1

This question is about finding reasons for compile errors when using tikz.

Consider the files compiles.tex, compiles-not1.tex and compiles-not2.tex. Then it is clear that compiles-not1.tex does not compile, because the name C has not been assigned. The file compiles-not2.tex does not compile, because \draw (A) -- (A -| B ); contains a space after the name B. However, this is difficult to see from the error message.

Is it possible to tweak the error messages generated by tikz to perhaps mark tikz-code and names in some way? What I mean is that in the example, an error message ! Package pgf Error: No shape named 'B ' is known. might be more helpful, as the space in the name B\␣ (B with a trailing space) is more clearly delimited from the message.

File compiles.tex compiles without errors.

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
    \node (A) {A};
    \node[above right of=A] (B) {B};
    \draw (A) -- (A -| B);
\end{tikzpicture}
\end{document}

On compilation compiles-not1.tex generates ! Package pgf Error: No shape named C is known.

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
    \node (A) {A};
    \node[above right of=A] (B) {B};
    \draw (A) -- (A -| C);
\end{tikzpicture}
\end{document}

compiles-not2.tex generates ! Package pgf Error: No shape named B is known.

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
    \node (A) {A};
    \node[above right of=A] (B) {B};
    \draw (A) -- (A -| B );
\end{tikzpicture}
\end{document}
3

I suppose it might be useful to make a feature request about this at SourceForge (https://sourceforge.net/p/pgf/feature-requests/?source=navbar), but it seems it's possible to patch a macro to achieve this.

\documentclass{article}
\usepackage{tikz}
\usepackage{etoolbox}
\patchcmd{\pgfpointanchor}{No shape named #1 is known}{No shape named '#1' is known}{}{}
\begin{document}
\begin{tikzpicture}
    \node (A) {A};
    \node[above right of=A] (B) {B};
    \draw (A) -- (A -| B );
\end{tikzpicture}
\end{document}

This will throw the error

! Package pgf Error: No shape named 'B ' is known.

See the pgf package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.9     \draw (A) -- (A -| B )
                              ;
? 
  • I had to do some greping to find exactly where this error message came from. – Torbjørn T. Sep 1 '17 at 15:50

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.