# Undefined control sequence \pgfmath@ in \node with text height or text depth

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 own depth("$\sum …$"). Also: Don't use \tikzstyle, use \tikzset instead. Related: Q107227 amongst others. May 11, 2016 at 18:24
• May 11, 2016 at 18:30
• If you post your solution as an answer, I will accept. Appreciate the additional info, too.
– Sam
May 12, 2016 at 12:01

calc's macros are not expandable, though PGF expects a mathematical value.

PGF does provide its own measurement functions:

• depth("…"),
• width("…") and
• height("…").

The " are needed because they escape the evaluation to text.

If you have ,, = or ] in your text, you have to enclose the value in braces.

For example:

\tikzset{
text vert/.style={
text height={height("#1")},
text depth={depth("#1")}},
type/.style={draw, text vert={$\sum_{i=1}^{n-1} m_i$}}
}
{"ft_lang_label":"__label__en","ft_lang_prob":0.58849925,"math_prob":0.96508974,"size":1722,"snap":"2023-40-2023-50","text_gpt3_token_len":615,"char_repetition_ratio":0.14260769,"word_repetition_ratio":0.03960396,"special_character_ratio":0.3292683,"punctuation_ratio":0.16814159,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9994461,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-12-05T13:06:46Z\",\"WARC-Record-ID\":\"<urn:uuid:15cecad4-e281-43f4-9c07-5325984295ad>\",\"Content-Length\":\"148233\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:e6e67742-fb70-42bf-a455-21f55f9f4464>\",\"WARC-Concurrent-To\":\"<urn:uuid:b36eea91-aadd-40bf-8d89-e0e8dfca83bb>\",\"WARC-IP-Address\":\"172.64.144.30\",\"WARC-Target-URI\":\"https://tex.stackexchange.com/questions/309130/undefined-control-sequence-pgfmath-in-node-with-text-height-or-text-depth\",\"WARC-Payload-Digest\":\"sha1:YR4EOX3IN2W5DUYYRJCU4FATFD572NS6\",\"WARC-Block-Digest\":\"sha1:I43BGGB4QDHCYG3RGTHM446UBHOHWPHJ\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-50/CC-MAIN-2023-50_segments_1700679100551.17_warc_CC-MAIN-20231205105136-20231205135136-00897.warc.gz\"}"}