EDIT: Given the comments I will rewrite my question from scratch and provide a solution for it. It can be useful for some people.
I get an error missing } inserted end{align*} if I use the following code
\documentclass[11pt,openany]{book}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{lipsum}
\newbox\savedeqs %% <- box register that will store your equations
\makeatletter %% <- change @ so that it can be used in command names
\newcommand\saveandprinteq[1]{% %% <- saves equation in a box register, then prints it
\begingroup
\expandafter\let\csname @currenvir\expandafter\endcsname\csname listeq@@currenvir\endcsname
\expandafter\let\csname end@currenvir\expandafter\endcsname\csname listeq@end@currenvir\endcsname
%% ^^ restore original environment definitions
\edef\listeq@temp{% %% <- the full environment, with its original name
\noexpand\begin{@currenvir}%
\unexpanded{#1}%
\noexpand\end{@currenvir}%
}%
\savecounters@ %% <- store counter values
\global\setbox\savedeqs=\vbox{\unvbox\savedeqs\listeq@temp}% %% <- append to \savedeqs
\restorecounters@ %% <- restore them
\listeq@temp %% <- print the environment
\endgroup
}
\newcommand\listeqpatch[1]{% %% <- patches equation environment
\expandafter\let\csname listeq@#1\expandafter\endcsname\csname #1\endcsname
\expandafter\let\csname listeq@end#1\expandafter\endcsname\csname end#1\endcsname
\renewenvironment{#1}{\collect@body\saveandprinteq}{}%
}
\newcommand\listofequations{ %% <- prints the list of equations
\section{List of equations}
\unvbox\savedeqs
}
\makeatother %% <- change @ back
%% Patching equation environments
\listeqpatch{equation}
\listeqpatch{align}
\listeqpatch{gather}
\listeqpatch{multline}
\listeqpatch{flalign}
\begin{document}
\date{}
\frontmatter
\pagenumbering{arabic}
\begin{align}
X:: &\mathcal{F} \rightarrow I \subseteq \mathbb{R} \tag{2.15} \label{eq2.15}\
& E \rightarrow x = X(E) \tag{2.16} \label{eq2.16}
\end{align}
\listofequations
\end{document}
The part after \usepackage{lipsum} is taken from this other thread (Automatically list all equations from document) and allows to provide a list of equations written in the text.
I have noticed that in the part aforementioned there is piece with \listeqpatch{align}. If I replace it with \listeqpatch{align*} then the error disappears.
\documentclassand\usepackagebut it gives no error. Please edit the example so it produces the error. – David Carlisle Jan 24 '23 at 15:23\endand that you only get the error shown after scrolling past 8 other errors, starting with! Paragraph ended before \align* was complete? – David Carlisle Jan 24 '23 at 15:26alignvariant. – alchemist Jan 24 '23 at 15:29\tagis for a strange numbering of your equation. If you're numbering sequentially, then you should be using the default numbering. Otherwise, you're going to rearrange your equations and have to adjust all of the numbering. – Teepeemm Jan 24 '23 at 15:34