0

The Problem: I want to compile the figure below with TeXLive2016 compatibility. I know this is kind of outdated, but apparently it is used by arxiv. The MWE compiles with TeXLive2019, but not when I switch to TeXLive2016 (e.g. on Overleaf, where you can easily change the TeXLive version). I have located the error to be caused by the xtick definition in the axis environment. Somehow, the macros are not correctly parsed here, while they are perfectly well parsed everywhere else.

The error that is thrown is:

! Package PGF Math Error: Could not parse input '0.7+1.0' as a floating point n umber, sorry. The unreadable part was near '+1.0'.. See the PGF Math package documentation for explanation. Type H for immediate help. ...
l.49 \end{axis}

What I've tried:

  • use xfp package -> compatibility issues
  • use fp package -> did not work to construct an evaluated list with \FPeval
  • create a style for the right x-tick positions -> didn't solve the problem
  • use /.expanded on xtick-> didn't solve the problem
  • use \pgfmathparse in combination with \pgfmathresult-> not available in TeXLive2016

Related Questions: Here is, what I think are related questions to my problem, although I have not been able to distill an answer from that.

MWE:

\documentclass[preview]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{graphics}
%
\usepackage{tikz}%drawings like geometries
\usetikzlibrary{calc,matrix,positioning}
\usetikzlibrary{decorations.pathmorphing}
%
\usepackage{pgfplots}
\pgfplotsset{
    ,compat=1.12
    }
%----------------------------------------
\begin{document}
%
\begin{figure}[ht]
    \centering
    \begin{tikzpicture}
    %Define Parameters
    \newcommand\tmin{0.7}
    \newcommand{\dtmax}{\dtstart}
    \newcommand{\dtstart}{1.0}
    \newcommand{\T}{2.0}
    \newcommand{\zmin}{3.0}
    \newcommand{\dvstart}{0.8}
    \newcommand{\vstart}{1.0}
    \newcommand{\zmax}{9.0}
    \newcommand{\g}{0.6}
    \newcommand{\keff}{1.0}
    %
    \begin{axis}[
        xlabel={t}, xlabel style={at={(1,0)}, anchor=west},
        ylabel={z (m)}, ylabel style={rotate=-90,at={(0,1)}, anchor=south},
        xmin=0.0, xmax=\tmin+\dtstart+2*\T+2*\dtmax,
        xtick={0,\tmin,\tmin+\dtstart,\tmin+\dtstart+\T,\tmin+\dtstart+\T+\T,\tmin+\dtstart+\T+\T+\dtmax},%
        xticklabels={$0$,$t_{start}$,$t_0$,$t_0+T$,$t_0+2T$,$t_{end}$},%
        ymin=0, ymax=\zmax,
        axis lines = left,
        y=1.cm,
        x=1.cm,
        ytick={0,1,...,12},
        legend pos=north west,
        %grid=both,
        ymajorgrids=true,
        grid style=dashed,
        ]
    \end{axis}
        %Laserbeams
        \draw[decorate, decoration = snake, very thick, red, opacity=0.5]
        ({\tmin + \dtstart},0) to ({\tmin + \dtstart},{.9*\zmax}) node[above] {$\pi/2$};
        \draw[decorate, decoration = snake, very thick, red, opacity=0.5,] 
        ({\tmin + \dtstart+\T},0) to ({\tmin + \dtstart + \T},{.9*\zmax}) node[above] {$\pi$};
        \draw[decorate, decoration = snake, very thick, red, opacity=0.5,] 
        ({\tmin + \dtstart + 2*\T},0) to ({\tmin + \dtstart + 2*\T},{.9*\zmax}) node[above] {$\pi/2$};
    \end{tikzpicture}
\end{figure}
\end{document}
Stefan Pinnow
  • 29,535
  • This simply wasn't possible in PGFPlots v1.15. As you can see from the Changelog this feature was added in 2017 and released with PGFPlots v1.16 in 2018 ... – Stefan Pinnow Sep 07 '20 at 18:01
  • Thanks, but is there any way to create a list from the macros, maybe outside the tikz-picture and then use it inside for the xticks? – Thomas Hensel Sep 08 '20 at 08:12
  • Instead of running the images in compilation on TL2016, why not put them in separate documents using the standalone class. This then produces PDF versions of the images which can when be used in any version of TeXLive. – daleif Sep 08 '20 at 09:54
  • This approach is less flexible. Say I have some constants stored in the \newcommand and want to plot/calculate things from that throughout the document. I then do not want to change all figures independently, but be compiled according to the changes. It is frustrating that this works with the actual version of TeXLive, but not with the one provided by arxiv... – Thomas Hensel Sep 09 '20 at 09:49

0 Answers0