1

The inline calculation exp(\tick) in PGFplots gives me a Could not parse input error when compiling the code

\documentclass[margin=1cm]{standalone}
\usepackage{pgfplots}
\begin{document}
    \begin{tikzpicture}
        \begin{loglogaxis}
        [   
            log number format code/.code={\pgfmathprintnumber[sci,sci zerofill,precision=3]{exp(\tick)}}, % GIVES A 'COULD NOT PARSE INPUT' ERROR!
            xtick={1,100}
        ]
            \addplot[no marks,domain=10^0:10^5] {x};
        \end{loglogaxis}
    \end{tikzpicture}
\end{document}

How do I solve this?

2

Well as the macro name implies it is a pretty-printer not the math parser. You need to do the math outside and supply the result to it. But if you do the regular TikZ parsing the numbers are too big to handle. Hence you need to turn on the fpu of TikZ do the math and turn it off.

log number format code/.code={%
    \pgfkeys{/pgf/fpu}%
    \pgfmathparse{exp(\tick)}%
    \pgfmathprintnumber[sci,sci zerofill,precision=3]{\pgfmathresult}%
    \pgfkeys{/pgf/fpu=false}%
}

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.