我认为“etoolbox”包中的命令\apptocmd
在表中不起作用。我应该怎么做?
梅威瑟:
\documentclass{article}
\usepackage{etoolbox}
\newcommand{\mycmd}[1]{%
#1\apptocmd{\saveMyNotes}{#1}{}{}%
}
\newcommand{\saveMyNotes}{}
\begin{document}
\begin{table}
\begin{tabular}{c}
\mycmd{Hi} \\
\mycmd{Hello}
\end{tabular}
\end{table}
\saveMyNotes % <--- This command doesn't execute!!!
\end{document}
答案1
我找到了解决方案。我应该使用\gappto
。
\documentclass{article}
\usepackage{etoolbox}
\newcommand{\mycmd}[1]{%
#1\gappto{\saveMyNotes}{#1}{}{}%
}
\newcommand{\saveMyNotes}{}
\begin{document}
\begin{table}
\begin{tabular}{c}
\mycmd{Hi} \\
\mycmd{Hello}
\end{tabular}
\end{table}
\saveMyNotes % <--- This command doesn't execute!!!
\end{document}