# Why align environement does not work with “extract ”package?

I'm using the package extract and I'm facing the following problem:

I try to extract only equation in align environnement (only A and not B, see the code), but it does not work. I have read the extract documentation but didn't find any answer. I would appreciate your help.

P.S. The code works well when there is no align* environement (but unfortunately I need it).

\documentclass[a4paper]{report}

\usepackage[active,
generate=test,
extract-env={align}]{extract}
\usepackage{amsthm}
\usepackage{amsmath}

\begin{document}

% % % %    A
\begin{align}
x^2 + y^2 &= 1
\\ y &= \sqrt{1 - x^2}.
\end{align}

% % % % B
\begin{align*}
x^2 + y^2 &= 1
\\ y &= \sqrt{1 - x^2}.
\end{align*}
\end{document}


In the error log I got this message:

\begin{align*} on input line 23 ended by \end{XTRalign}. \end{align*}

P.S. I'm wondering if it is maybe a limitation because with the equation environment the following code works:

\documentclass[a4paper]{report}
\usepackage[active,
generate=test,
extract-env={equation}]{extract}
\usepackage{amsthm}
\usepackage{amsmath}

\begin{document}

% % % %    A
$$x^2 + y^2$$

% % % % B
\begin{equation*}
x^2 + y^2
\end{equation*}
\end{document}

-
Welcome to TeX.SX! It seems to be a limitation of the extract package. –  karlkoeller Jan 17 at 6:33
First of all I;ve never heard for the extract package before, so I have no idea what it does, but the align construction is rather special in that AFAIR it explicitly looks for the string \end{align} to end it, so what ever extract is doing may mess this up. –  daleif Jan 17 at 9:12

i finally find a way to overcome this limitation.

To recall the problem was the following : -impossible to extract align environment using the extract package when there are some align* environment in the original file. --> so impossible to extract only numbered aligned equation.

Solution :

• Replace all align environment by equation environment then add aligned environment ,

Concretely:

1-Search and replace all: \begin{align} with \begin{aligned}

2-Search and replace all: \end{align} with \end{aligned}

And the "extract" package will works like a charm :) hope this can help,

Below the code to compare with question's code :

        \documentclass[a4paper]{report}

\usepackage[
active,
generate=test,
extract-env={equation},
]{extract}

\begin{document}

% % % %    A
\begin{aligned} x^2 + y^2 &= 1 \\ y &= \sqrt{1 - x^2}. \end{aligned}

% % % % B
\begin{equation*}\begin{aligned} x^2 + y^2 &= 1 \\ y &= \sqrt{1 - x^2}. \end{aligned}\end{equation*}

\end{document}
`
-