# LaTeX, etoolbox and counters

I'm having a new issue with the etoolbox package.

In fact, I would like in a LaTeX document to numberize my figures, tables, etc...

But, when I add the value of the counter to the list, it doesn't add the current value (that is increasing) but it's adding the final value. As if etoolbox is executing the commands at the end of the document.

Do you please have any solution ?

Cordially,

Thomas Fauchet

PS : Using expl3 doesn't solve the problem.

\documentclass{minimal}
\usepackage{etoolbox}

%COMMAND FOUND ON INTERNET AND WORKS
% \printlist[<sep>]{<list macro>}
\newcommand{\printlist}[2][,]{{% Print list
% http://tex.stackexchange.com/a/89187/5764
\def\listsep{\def\listsep{#1}}% Delayed execution of list separator
\renewcommand{\do}[1]{\listsep##1'}%
[\dolistloop\languagelist]
}}

\newcounter{test}
\stepcounter{test}

\begin{document}

\stepcounter{test}

%Expected result : ['1','2']
%Result : ['2','2']
\printlist{\languagelist}

\end{document}

• Instead of asking a new question for every attempt, wouldn't it be easier to ask the real question with all the details? – egreg Jan 19 at 22:55
• OK, but my problem is so fat that I didn't want to take your time... – Thomas Jan 20 at 19:29

Use \listxadd to expand the value:

\documentclass{minimal}
\usepackage{etoolbox}

%COMMAND FOUND ON INTERNET AND WORKS
% \printlist[<sep>]{<list macro>}
\newcommand{\printlist}[2][,]{{% Print list
% http://tex.stackexchange.com/a/89187/5764
\def\listsep{\def\listsep{#1}}% Delayed execution of list separator
\renewcommand{\do}[1]{\listsep##1'}%
[\dolistloop\languagelist]
}}

\newcounter{test}
\stepcounter{test}

\begin{document}