I have a macro that prints exactly what I want, but I can't use it nested in another one. As far as I understand it is because the fist one is not completely executed and commands from first macro mixt together with those from the second one.
How to proceed ?
\documentclass{article}
\usepackage{tikz,pgfplots}
\usetikzlibrary{calc}
\pgfplotsset{compat=1.9}
\makeatletter
\def\L@ste#1#2{
\count255 = 1
\loop
\def\n{\the\count255}%
#1%
\advance\count255 by 1
\ifnum\count255>#2
\else
,%
\repeat
}
\def\Liste#1#2{\L@ste{#1}{#2}}
\makeatother
\begin{document}
\verb+\Liste{\n-\n/(6-\n)*x}{5}+
Prints exactly what I need :
\Liste{\n-\n/(6-\n)*x}{5}
\bigskip
But I can't use it directly :
\verb+max(\Liste{\n-\n/(6-\n)*x}{5})+
produces errors ...
\bigskip
\begin{tikzpicture}
\begin{axis}[xmin=0,xmax=5,ymax=7]
\addplot[color=black,smooth,samples=400]
{
% can't use it here, Why ?
%max(\Liste{\n-\n/(6-\n)*x}{5})
max(1-1/(6-1)*x,2-2/(6-2)*x,3-3/(6-3)*x,4-4/(6-4)*x,5-5/(6-5)*x)
};
\end{axis}
\end{tikzpicture}
\end{document}
\else
is not legal in\loop
, but it's perhaps the least.Loop
seems to ignore that as it works well, the result is correct. I don't understand then what you mean. By the way, how to testcount255<=#2
as<=
is forbiden and doesn't work ?\loop
macro.\Liste
macro produces the instruction for printing what you'd like to feed tomax
; but you can't use it in the argument ofmax
, because this wants the functions, not the instructions for printing them.