The below file gives this error when compiled with pdflatex (from TeX Live 2015). How do I fix it, and what have I done wrong?
Error
\pgfmath@dimen@ ...men@@ #1=0.0pt\relax \pgfmath@
l.27 ...e,draw=none] (idx) {index:\hspace*{10pt}};
It seems that using either text height=...
or text depth=...
induces the error (see commented lines below). This was compiling fine some time ago, but I believe between then and now I have done a tlmgr update --all
.
MWE
\documentclass{article}
\usepackage{tikz}
\usepackage{calc}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\usetikzlibrary{chains}
% Errors
\tikzstyle{tape}=[draw,
text height=\heightof{$\sum_{i=1}^{n-1} m_i$},
text depth=\depthof{$\sum_{i=1}^{n-1} m_i$}]
% Errors
% \tikzstyle{tape}=[draw,text height=\heightof{$\sum_{i=1}^{n-1} m_i$}]
% Errors
% \tikzstyle{tape}=[draw,text depth=\depthof{$\sum_{i=1}^{n-1} m_i$}]
% No error
% \tikzstyle{tape}=[draw]
\begin{scope}[start chain=0 going right,node distance=0mm]
\node [on chain=0,tape,draw=none] (idx) {index:\hspace*{10pt}};
\node [on chain=0,tape] {$k_1$};
\node [on chain=0,tape] {$\ldots$};
\node [on chain=0,tape] {$k_n$};
\node [on chain=0,tape,draw=none] {$=$};
\node [on chain=0,tape] {$0$};
\node [on chain=0,tape] {$\ldots$};
\node [on chain=0,tape] {$\sum_{i=1}^{n-1} m_i$};
\end{scope}
\end{tikzpicture}
\end{figure}
\end{document}
I have found several questions with similar errors here, but was not able to convert any of the answers to fixes for this situation.
\depthof
and similar are not expandable, Tikz (too be precise PGFmath) expects a mathematical value here. Just use PGF's owndepth("$\sum … $")
. Also: Don't use\tikzstyle
, use\tikzset
instead. Related: Q107227 amongst others.