PierreSenellart / apxproof

LaTeX package for automatically putting proof environments in appendix
LaTeX Project Public License v1.3c
23 stars 8 forks source link

Error with a command with @ in xypic #34

Closed komorin95 closed 4 years ago

komorin95 commented 4 years ago

I used apxproof.sty for a recent joint paper. Thanks to this package, our time is saved a lot. I appreciate the developers.

During writing the paper, we have faced an unexpected compile error. The following example cannot be compiled:

\documentclass{article}
\usepackage[all]{xy}
\usepackage{apxproof}
\begin{document}
\section{First Section}
\begin{toappendix}
\begin{displaymath}
  \xymatrix{A\ar@{.>}[r]_f & B}
\end{displaymath}
\end{toappendix}
\end{document}

Indeed, if I save this as bad.tex and try to compile it by pdflatex -halt-on-error bad.tex then I get the following error:

! Argument of \next@ has an extra }.
<inserted text> 
                \par 
l.5   \xymatrix{A\ar@{.>}[r]_f & B}

!  ==> Fatal error occurred, no output PDF file produced!

I'm using the latest apxproof.sty v1.20, pdfTeX Version 3.14159265-2.6-1.40.20 (TeX Live 2019), and Xy-pic version 3.8.9.

The use of \xymatrix should be correct, since the following example can be compiled successfully:

\documentclass{article}
\usepackage[all]{xy}
\usepackage{apxproof}
\begin{document}
\section{First Section}
\begin{displaymath}
  \xymatrix{A\ar@{.>}[r]_f & B}
\end{displaymath}
\end{document}

If there is no @, then the error is not caused. The following example can be successfully compiled:

\documentclass{article}
\usepackage[all]{xy}
\usepackage{apxproof}
\begin{document}
\section{First Section}
\begin{toappendix}
\begin{displaymath}
  \xymatrix{A\ar[r]_f & B}
\end{displaymath}
\end{toappendix}
\end{document}

Actually, we have found a workaround of this. Any @ inside an expanded macro does not seem to cause an error. The following example can be successfully compiled:

\documentclass{article}
\usepackage[all]{xy}
\usepackage{apxproof}
\newcommand{\dottedarrowr}{\ar@{.>}[r]}
\begin{document}
\section{First Section}
\begin{toappendix}
\begin{displaymath}
  \xymatrix{A\dottedarrowr_f & B}
\end{displaymath}
\end{toappendix}
\end{document}

We used this in the recent paper, but it was a bit tiring to do. Could you solve this?

komorin95 commented 4 years ago

I've just found another workaround. The following is successfully compiled:

\documentclass{article}
\usepackage[all]{xy}
\usepackage{apxproof}
\begin{document}
\section{First Section}
\begin{toappendix}
\makeatother
\begin{displaymath}
  \xymatrix{A\ar@{.>}[r]_f & B}
\end{displaymath}
\makeatletter
\end{toappendix}
\end{document}
komorin95 commented 4 years ago

I guess I've managed to solve this. Please see the pull request.

PierreSenellart commented 4 years ago

Fixed by #37. Thanks again for the bug report, and for the solution.