I want a command that will create an unevaluated bit of LaTeX/TeX code (to be evaluated at the end of an environment, but this is not necessary information) that has been created using an evaluated command.
Here is an attempt at a working example created from my work:
\newcommand{\myNotes}{\protect\item apple}
\newcounter{noteCnt}
\newcommand{\TblMark}[1]{
\stepcounter{noteCnt}
\alph{noteCnt} %in this example, this is just printing a character at this location
\makeatletter
\g@addto@macro\myNotes{ \protect\item \alph{noteCnt} #1} %creating item list
\makeatother}
%elsewhere in the latex file...
Hello, I am feeling very \TblMark{frustrated} about my lack of \Tex \TblMark{knowledge}.
Here is a list:
\myNotes
The problem is that when myNotes
is expanded, the current value of noteCnt
is used in the item list. I want the item list to use the noteCnt
value at the time when \TblMark
was expanded.
My intention was to create something like:
Hello, I am feeling very a about my lack of TeX b.
Here is a list:
- a frustrated
- b knowledge
Instead, I get something like:
Hello, I am feeling very a about my lack of TeX b.
Here is a list:
- b frustrated
- b knowledge