# Conflict between catchfilebetweentags and a kind of arrow from xypic: argument of \next@ has an extra }

I'm using the solution from https://tex.stackexchange.com/a/4952/1403 to input a part of file.tex into another file.

But I'm getting this error:

at the line \ExecuteMetaData[file.tex]{tag}.

Here's a MWE. The file to be recalled is:

%<*tag>

$$\xymatrix{A\ar@(ul,ur)^\Sigma }$$

%</tag>


Here is the main file:

\documentclass[a4paper,12pt]{amsbook}
\usepackage{catchfilebetweentags}
\usepackage{xypic}
\begin{document}

\end{document}


The xypic code being recalled does work if I don't recall it, but rather write the line directly on the main file.

• Please provide a minimal example (or see here). That 'solution' is not a self-contained example, so it doesn't really help anyone understand what you are doing (wrong or differently or ...). – jon Apr 4 '17 at 16:03
• @jon: That's very hard to do in this case, because the error message doesn't tell me at which line of file.tex it is conflicting (line 24 is the ExecuteMetaData line). I tried to make a minimal example that recalls only a line using xypic, but that works. And so I don't really know where the problem is (and the file being inputted is not small, so as to make it easy to deal with). What can I do? – Bruno Stonek Apr 5 '17 at 8:43
• The normal approach is to 'halve' the document (between \begin{document} and \end{document}) step by step. If the problem occurs in one half and not the other, then halve that half, and so on. It may be tricky in this case, but I think the principle is likely still sound. Once the document body problem is sorted out, then progressively strip out packages that seem, a priori, are unrelated to the problem (e.g., if the problem is not about tables, then table-related packages can probably go). Ideally, the minimal document is a small amount of document body and only a few packages. – jon Apr 5 '17 at 23:25
• @jon: thanks to your advice I was able to provide a really small MWE (or should I say, MNWE...) – Bruno Stonek Apr 7 '17 at 16:09

catchfilebetweentags reads the file with the catcode of the @ set to letter. This breaks the \ar@ command of xypic as it espect the catcode of @ to be "other".

The problem can be demonstrated without external file (see below). I don't see a good way to avoid the \makeatletter in catchfilebetweentags, it is quite hardcoded and removing it breaks other code. What you can do is to define a command that you use instead of the \ar@ in the xypic:

\documentclass[a4paper,12pt]{amsbook}
\usepackage{catchfilebetweentags}
\usepackage{xypic}

\newcommand\myarat{\ar@}

\begin{document}

\makeatletter %done by catchfilebetweentags
%<*tag>

%$$\xymatrix{A\ar@(ul,ur)^\Sigma }$$ %error

$$\xymatrix{A\myarat(ul,ur)^\Sigma }$$

%</tag>

\end{document}


If you want to keep the \ar@ you can try this:

\documentclass[a4paper,12pt]{amsbook}
\usepackage{catchfilebetweentags}
\usepackage{xypic}

\begin{document}
\CatchFileBetweenTags{\mytemp}{file}{tag}
\scantokens\expandafter{\mytemp}

\end{document}

• Thanks! However, I would very much like to keep my \ar@ intact... – Bruno Stonek Apr 25 '17 at 13:23
• I added a suggestion, could work, but not really tested much. – Ulrike Fischer Apr 25 '17 at 13:33
• @UlrikeFischer: What is mytemp is the second part of your answer? How would it work with the command \ExecuteMetaData[file.tex]{tag}? Thanks – Colas Aug 11 '18 at 14:31