\@ifnextchar,
always evaluates to false, which is clearly wrong in the last case. However, the second one (within \punctuationcheck
) works just fine. Why would the same conditional evaluate to False and then True?Code: Select all
\documentclass{article}
\makeatletter
\newcommand{\punctuationcheck}{%
\@ifnextchar){I see a parens\relax}{%
\@ifnextchar]{I see a square bracket\relax}{%
\@ifnextchar.{I see a period\relax}{%
\@ifnextchar,{I see a comma\relax}{I didn' t see anything\ }}}}%
}
\newcommand{\ie}{\textit{i.e.}\@ifnextchar,{I saw a comma\relax}{I didn't see a comma,}\punctuationcheck}
\makeatother
\begin{document}
\ie) test
\ie] test
\ie. test
\ie, test
\end{document}
i.e.I didn’t see a comma,I see a parens) test
i.e.I didn’t see a comma,I see a square bracket] test
i.e.I didn’t see a comma,I see a period. test
i.e.I didn’t see a comma,I see a comma, test