# catchfilebetweentags error with multicol

I am using the catchfilebetweentags library to store equations in an external file and then import them into my document. This is useful when you need to use the same equation in multiple documents. This works for simple equations, but introduces an offset error when used with the multicols package. Does anyone know of a solution to this problem?

## MWE

### main.tex

\documentclass{article}
\usepackage{amsmath}
\usepackage{catchfilebetweentags}
\usepackage{multicol}

}

\begin{document}

Local equations:
\begin{multicols}{2}
$$\label{equ:X2} X = \begin{bmatrix} X_0 \\ X_1 \\ X_2 \\ X_3 \end{bmatrix}$$

$$\label{equ:Y2} Y = \begin{bmatrix} Y_0 \\ Y_1 \\ Y_2 \\ Y_3 \end{bmatrix}$$
\end{multicols}

\end{document}


### equations.tex

\documentclass{article}
\begin{document}

%<*eq001>
\begin{multicols}{2}
$$\label{equ:X} X = \begin{bmatrix} X_0 \\ X_1 \\ X_2 \\ X_3 \end{bmatrix}$$

$$\label{equ:Y} Y = \begin{bmatrix} Y_0 \\ Y_1 \\ Y_2 \\ Y_3 \end{bmatrix}$$
\end{multicols}
%</eq001>

\end{document}


• Welcome to TeX.SX! Very nicely laid out example! – egreg Jul 15 '15 at 13:17
• @egreg Thanks; do you know how to embed the latex output? – Napthali Jul 15 '15 at 13:17
• Just add a screen shot, I'll do it for you. – egreg Jul 15 '15 at 13:20
• @egreg Thanks. Looks like you got the same output. – Napthali Jul 15 '15 at 13:22

The problem is that catchfilebetweentags ignores blank lines. If you remove the blank line in the “local” part, you get exactly the same.

Solution: use \par in the auxiliary file instead of a blank line.

\documentclass{article}
\begin{document}

%<*eq001>
\begin{multicols}{2}
$$\label{equ:X} X = \begin{bmatrix} X_0 \\ X_1 \\ X_2 \\ X_3 \end{bmatrix}$$
\par
$$\label{equ:Y} Y = \begin{bmatrix} Y_0 \\ Y_1 \\ Y_2 \\ Y_3 \end{bmatrix}$$
\end{multicols}
%</eq001>

\end{document}


However, using multicol to show equations side by side is not the best method, I'd go for two minipages.

• Why do a I need a space between the equations? I see that it makes a difference, but don't understand why. – Napthali Jul 15 '15 at 13:40
• @Napthali Actually, one should never have an equation environment immediately following a blank line or just after \begin{multicols}. That's why I suggest minipage. – egreg Jul 15 '15 at 13:41