1

This is what I'm doing:

\documentclass[sigplan,nonacm=true,anonymous=true]{acmart}
\newcommand\anon[1]{%
  \makeatletter\if@ACM@anonymous%
    XXX%
  \else%
    #1%
  \fi\makeatother%
}
\begin{document}
Hello, \anon{Jeff}!
\end{document}

I'm expecting it to print Hello, XXX!, but it prints Hello, Jeff!. What am I doing wrong?

2
  • you have the makeatletter makeatother in the wrong place move them before and after the definition Commented Jun 13, 2021 at 9:17
  • @DavidCarlisle you are right! Make it an answer, please, I will accept it.
    – yegor256
    Commented Jun 13, 2021 at 9:21

1 Answer 1

2

You need @ to be a letter when the definition is made, so

\documentclass[sigplan,nonacm=true,anonymous=true]{acmart}
\makeatletter
\newcommand\anon[1]{%
\if@ACM@anonymous
    XXX%
  \else
    #1%
  \fi
}
\makeatother
\begin{document}
Hello, \anon{Jeff}!
\end{document}

As it was the \makeatletter was doing nothing (as the following characters were already tokenized so \if@ACM@anonymous was interpreted as

\if @A%
  CM@anonymous

compared @ with A so not an error, but always false.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .