I would like to use a foreach loop to create a list of acronyms in a LaTeX document. I expect the code should look something like this but it does not work (it nearly works):
\documentclass{article}
\usepackage{pgffor}
\usepackage[acronym]{glossaries}
\makeglossaries
\foreach \x/\y in {
DOC/document,
ACR/acronym,
VV/very very,
}
{\newacronym{\x}{\x}{\y}}
\begin{document}
\section{Document Body}
A \gls{DOC} with lots of unexplained \glspl{ACR} is \gls{VV} annoying.
\printglossary[type=\acronymtype]
\end{document}
For reference, here is an example of a working foreach loop and acronym glossary:
\documentclass{article}
\usepackage{pgffor}
\usepackage[acronym]{glossaries}
\makeglossaries
\newacronym{DOC}{DOC}{document}
\newacronym{ACR}{ACR}{acronym}
\newacronym{VV}{VV}{very very}
\begin{document}
\section{Document Body}
A \gls{DOC} with lots of unexplained \glspl{ACR} is \gls{VV} annoying.
\section{Foreach Loop}
\foreach \x/\y in {
DOC/document,
ACR/acronym,
VV/very very,
}
{\textbf{\x} \y\}
\printglossary[type=\acronymtype]
\end{document}

\newacronym{}{}{}and maybe even CCs the first to the second argument. That said, you could just do\newcommand*\myNewAcronym[3][]{\newacronym[#1]{#2}{#2}{#3}and then you only have to use\myNewAcronym{DOC}{document}without having to repeatDOC. – Qrrbrbirlbel Dec 01 '22 at 11:41