# Scale factor of pgfplot's xtick with mask

A scale factor factor for xticks does not work with ldots mask .... Does the problem have a solution?

\documentclass[tikz]{standalone}
\usepackage{pgfplots}

%===============================================================================
\begin{document}
\noindent
\begin{tikzpicture}[
declare function ={
factor=2;
}
]
\begin{axis}[
%xtick = {-2*factor,2*factor}, % This one work
%xtick = {-2,...,2}, % This one work
xtick = {-2*factor,...,2*factor}, % This one doesn't work
]
\end{axis}
\end{tikzpicture}

\end{document}


You need to set /pgf/foreach/parse=true, see p. 989 of pgfmanual v3.1.4

This works (at least in in this case).

\documentclass[tikz]{standalone}
\usepackage{pgfplots}

%===============================================================================
\begin{document}
\noindent
declare function ={
factor=2;
}
]
\begin{axis}[
%xtick = {-2*factor,2*factor}, % This one work
%xtick = {-2,...,2}, % This one work
xtick={-2*factor,...,2*factor}, % This one works now
]
\end{axis}
\end{tikzpicture}
\end{document}


Let me mention that I recommend not to overdo it with parse=true, there are cases with integers in which I had some difficulties.

Just in case you encounter problems with this proposal because some other, perhaps internal, loop causes problems: you could also use xtickmin and xtickmax, whose values get automatically parsed.

\documentclass[tikz]{standalone}
\usepackage{pgfplots}

%===============================================================================
\begin{document}
\noindent
\begin{tikzpicture}[
declare function ={
factor=2;
}
]
\begin{axis}[
xtickmin=-2*factor,
xtickmax=2*factor,
]