6

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}

%Add 1
\listgadd{\languagelist}{\thetest}
\stepcounter{test}
%Add 2
\listgadd{\languagelist}{\thetest}

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

\end{document}
  • 1
    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
8

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}

%Add 1
\listxadd{\languagelist}{\thetest}
\stepcounter{test}
%Add 2
\listxadd{\languagelist}{\thetest}

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

\end{document}

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.