![foreach 和 renew 命令](https://linux22.com/image/318646/foreach%20%E5%92%8C%20renew%20%E5%91%BD%E4%BB%A4.png)
我想在 foreach 循环中更新变量,但我的代码不起作用。请帮忙!
\documentclass{article}
\usepackage{pgffor}
\newcommand\tests{
\newcommand\mytext{aaa}
\foreach \i in {bbb,ccc,ddd,eee,fff}{
\renewcommand\mytext\i
}
\mytext
}
\begin{document}
\tests
\end{document}\
它输出字符串“aaa”,而不是“fff”!