3

Changing the default tip for arrows produces a lot of "missing character" messages in the log file. Is this a bug or is something wrong with the MWE?

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{arrows.meta}

\begin{document}

\begin{tikzpicture}[>=Triangle]
    \draw[->] (0,0) -- (0,1);
\end{tikzpicture}

\end{document}

Log file :

[... snip ...]
Missing character: There is no p in font nullfont!
Missing character: There is no t in font nullfont!
Missing character: There is no p in font nullfont!
Missing character: There is no t in font nullfont!
Missing character: There is no p in font nullfont!
Missing character: There is no t in font nullfont!
Missing character: There is no p in font nullfont!
Missing character: There is no t in font nullfont!
Missing character: There is no p in font nullfont!
Missing character: There is no t in font nullfont!
Missing character: There is no p in font nullfont!
Missing character: There is no t in font nullfont!
Missing character: There is no p in font nullfont!
Missing character: There is no t in font nullfont!
Missing character: There is no p in font nullfont!
Missing character: There is no t in font nullfont!
Missing character: There is no p in font nullfont!
Missing character: There is no t in font nullfont!
Missing character: There is no p in font nullfont!
Missing character: There is no t in font nullfont!
[... snip ...]

Edit: File list:

 *File List*
standalone.cls    2012/09/15 v1.1b Class to compile TeX sub-files standalone
ifluatex.sty    2010/03/01 v1.3 Provides the ifluatex switch (HO)
   ifpdf.sty    2011/01/30 v2.3 Provides the ifpdf switch (HO)
 ifxetex.sty    2010/09/12 v0.6 Provides ifxetex conditional
 xkeyval.sty    2012/10/14 v2.6b package option processing (HA)
 xkeyval.tex    2012/10/14 v2.6b key=value parser (HA)
standalone.cfg    2012/09/15 v1.1b Default configuration file for 'standalone' 
class
 article.cls    2007/10/19 v1.4h Standard LaTeX document class
  size10.clo    2007/10/19 v1.4h Standard LaTeX file (size option)
    tikz.sty    2013/12/13 v3.0.0 (rcs-revision 1.142)
     pgf.sty    2013/12/18 v3.0.0 (rcs-revision 1.14)
  pgfrcs.sty    2013/12/20 v3.0.0 (rcs-revision 1.28)
everyshi.sty    2001/05/15 v3.00 EveryShipout Package (MS)
  pgfrcs.code.tex
 pgfcore.sty    2010/04/11 v3.0.0 (rcs-revision 1.7)
graphicx.sty    1999/02/16 v1.0f Enhanced LaTeX Graphics (DPC,SPQR)
graphics.sty    2009/02/05 v1.0o Standard LaTeX Graphics (DPC,SPQR)
    trig.sty    1999/03/16 v1.09 sin cos tan (DPC)
graphics.cfg    2007/01/18 v1.5 graphics configuration of teTeX/TeXLive
  pdftex.def    2011/05/27 v0.06d Graphics/color for pdfTeX
infwarerr.sty    2010/04/08 v1.3 Providing info/warning/error messages (HO)
 ltxcmds.sty    2011/11/09 v1.22 LaTeX kernel commands for general use (HO)
  pgfsys.sty    2013/11/30 v3.0.0 (rcs-revision 1.47)
  pgfsys.code.tex
pgfsyssoftpath.code.tex    2013/09/09  (rcs-revision 1.9)
pgfsysprotocol.code.tex    2006/10/16  (rcs-revision 1.4)
  xcolor.sty    2007/01/21 v2.11 LaTeX color extensions (UK)
   color.cfg    2007/01/18 v1.5 color configuration of teTeX/TeXLive
 pgfcore.code.tex
pgfcomp-version-0-65.sty    2007/07/03 v3.0.0 (rcs-revision 1.7)
pgfcomp-version-1-18.sty    2007/07/23 v3.0.0 (rcs-revision 1.1)
  pgffor.sty    2013/12/13 v3.0.0 (rcs-revision 1.25)
 pgfkeys.sty    
 pgfkeys.code.tex
 pgfmath.sty    
 pgfmath.code.tex
  pgffor.code.tex
    tikz.code.tex
supp-pdf.mkii
 ***********
  • I think this is a duplicate, e.g. 1, 2, 3, 4. – Pouya May 20 '14 at 14:04
  • I'm not sure if this is a duplicate because the other questions are concerned with line breaking in styles or other characters entered in the tikzpicture environment ... – Bloops May 20 '14 at 14:11
  • 3
    Looks as if the library has somewhere a "pt" which shouldn't be there. – Ulrike Fischer May 20 '14 at 14:11
  • @PaulGaborit: You must look in the log-file. – Ulrike Fischer May 20 '14 at 14:13
  • In the definition of \pgfmathdivide@ there is \pgfmath@x =#1pt and #1, in this case, is \pgfarrowlength; so the pt gets typeset; it wouldn't if #1 were a number. This appears also for #2. Similarly in \pgfmathsqrt@, \pgfmathcos@, \pgfmathsin@. – egreg May 20 '14 at 14:34
7

TikZ sets the font to \nullfont inside environment tikzpicture to remove garbage, from the description of tikzpicture in the PGF manual:

Next, the contents of the environment is processed and the graphic commands therein are put into a box. Non-graphic text is suppressed as well as possible, but non-pgf commands inside a {tikzpicture} environment should not produce any "output" since this may totally scramble the positioning system of the backend drivers. The suppressing of normal text, by the way, is done by temporarily switching the font to \nullfont. You can, however, "escape back" to normal TEX typesetting. This happens, for example, when you specify a node.

Commands in TikZ/PGf are often flexible, they accept either numbers (float or integer) or units as arguments. For example, the division is implemented in file pgfmathfunctions.code.tex:

\pgfmathdeclarefunction{divide}{2}{%
  \begingroup
    \pgfmath@x=#1pt\relax
    \pgfmath@y=#2pt\relax
    ...
}

This defines macro \pgfmathdivide@. The arguments #1 and #2 are stored in dimension registers \pgfmath@x and \pgfmath@y. The "default" unit pt is appended for the case #1 and #2 are numbers without unit. But if they contain a unit, then the appended letters pt are garbage. They are only thrown away by the current font \nullfont and you can see the lost char messages in the .log file.

Debugging hints

The lost char messages can also be made visible on the console:

\tracinglostchars=2

The place, where p and t are set can be made visible by \tracingcommands=1. The following lines can be seen in the .log file:

{the letter p}
{the letter t}

(It is also written to the console with \tracingonline=1.)

Now the macros are of interest, that cause the setting of the letters:

\tracingmacros=1

Then the .log file contains:

\pgfmathdivide@ #1#2->\begingroup \pgfmath@x =#1pt\relax \pgfmath@y =#2pt\relax
 \let \pgfmath@sign =\pgfmath@empty \ifdim 0pt=\pgfmath@y \pgfmath@error {You'v
e asked me to divide `#1' by `#2', but I cannot divide any number by `#2'}\fi \
afterassignment \pgfmath@xa \c@pgfmath@counta \the \pgfmath@y \relax \ifdim 0pt
=\pgfmath@xa \divide \pgfmath@x by\c@pgfmath@counta \else \ifdim 0pt>\pgfmath@x
 \def \pgfmath@sign {-}\pgfmath@x =-\pgfmath@x \fi \ifdim 0pt>\pgfmath@y \expan
dafter \def \expandafter \pgfmath@sign \expandafter {\pgfmath@sign -}\pgfmath@y
 =-\pgfmath@y \fi \ifdim 1pt>\pgfmath@y \pgfmathreciprocal@ {\pgfmath@tonumber 
{\pgfmath@y }}\pgfmath@x =\pgfmath@sign \pgfmathresult \pgfmath@x \else \def \p
gfmathresult {0}\pgfmath@divide@periodtrue \c@pgfmath@counta =0\relax \pgfmathd
ivide@@ \pgfmath@x =\pgfmath@sign \pgfmathresult pt\relax \fi \fi \pgfmath@retu
rnone \pgfmath@x \endgroup 
#1<-\pgfarrowlength 
#2<-\pgfarrowwidth 
{\begingroup}
{\dimen107}
{the letter p}

Missing character: There is no p in font nullfont!
{the letter t}
Missing character: There is no t in font nullfont!
{\relax}
{\dimen108}
{the letter p}
Missing character: There is no p in font nullfont!
{the letter t}
Missing character: There is no t in font nullfont!
{\relax}

Thus one "culprit" is found: \pgfmathdivide@. A continued search also reveals \pgfmathsqrt@, \pgfmathcos@, and \pgfmathtan@. That are the commands that outputs garbage pt in this example, but they are many other candidates, which also produces pt.

Workaround

A cleanup macro can be inserted right after the assignment via \afterassignment. Package etoolbox provides \patchcmd for an easier patching of the affected macros:

\tracinglostchars=2
\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{arrows.meta}

\usepackage{etoolbox}
\makeatletter
\def\cleanup@unit#1\@nil{}
\patchcmd{\pgfmathdivide@}{%
  \pgfmath@x=#1pt\relax
  \pgfmath@y=#2pt\relax
}{%
  \afterassignment\cleanup@unit
  \pgfmath@x=#1pt\relax\@nil
  \afterassignment\cleanup@unit
  \pgfmath@y=#2pt\relax\@nil
}{}{%
  \errmessage{Patching \string\pgfmathdivide@\space failed}%
}
\patchcmd{\pgfmathsqrt@}{%
  \expandafter\pgfmath@x#1pt\relax
}{%
  \afterassignment\cleanup@unit
  \expandafter\pgfmath@x#1pt\relax\@nil
}{}{%
  \errmessage{Patching \string\pgfmathsqrt@\space failed}%
}
\patchcmd{\pgfmathcos@}{%
  \expandafter\pgfmath@x#1pt\relax
}{%
  \afterassignment\cleanup@unit
  \expandafter\pgfmath@x#1pt\relax\@nil
}{}{%
  \errmessage{Patching \string\pgfmathcos@\space failed}%
}
\patchcmd{\pgfmathsin@}{%
  \expandafter\pgfmath@x#1pt\relax
}{%
  \afterassignment\cleanup@unit
  \expandafter\pgfmath@x#1pt\relax\@nil
}{}{%
  \errmessage{Patching \string\pgfmathsin@\space failed}%
}
\makeatother

\begin{document}

\begin{tikzpicture}[>=Triangle]
    % \tracingmacros=1
    % \tracingcommands=1
    \draw[->] (0,0) -- (0,1);
\end{tikzpicture}

\end{document}
| improve this answer | |
  • Another way to fix this bug: replace all calls like \pgfmathdivide@\pgfarrowlength\pgfarrowwidth by \pgfmathdivide@{\pgfmath@tonumber{\pgfarrowlength}}{\pgfmath@tonumber{\pgfarrowwidth}} (in pgflibraryarrows.meta.code.tex). – Paul Gaborit May 20 '14 at 15: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.