1

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.

Qrrbrbirlbel
  • 119,821
gatsu
  • 121
  • 1
    Can't reproduce your issue, compiles fine on up-to-date TL – DG' Jan 24 '23 at 15:21
  • Please always provide an example that shows the problem. I have added \documentclass and \usepackage but it gives no error. Please edit the example so it produces the error. – David Carlisle Jan 24 '23 at 15:23
  • 2
    I suspect that you have a blank line before \end and 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:26
  • The question resembles this one: https://tex.stackexchange.com/questions/342562/using-tag-in-align-environment-in . Could there be something similar in this case? Although that would not account for an errorless compiling of the align variant. – alchemist Jan 24 '23 at 15:29
  • Oh and @gatsu There has been some major updates in July - August 2022. I had to revise documents and change the use of several packages too. ;-P – alchemist Jan 24 '23 at 15:33
  • Kind of off-topic, but the point of \tag is 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
  • @Teepeemm I am also using strange numbering in other sections. – gatsu Jan 24 '23 at 15:47
  • sorry your edit does not help, it is just a disconnected fragment of unrelated packages, even if you add them all to the example document in the first code block you get no error. Please edit the example document so you get the error – David Carlisle Jan 24 '23 at 16:03
  • @DavidCarlisle I have edited completely the question now. I answer my own question there. If deemed useless my question can be completely deleted. – gatsu Jan 24 '23 at 17:25
  • 2
    Thanks please post an answer. (as an answer, not as part of the questionn post) Hopefully you see why we always ask for complete examples:-) – David Carlisle Jan 24 '23 at 17:40

1 Answers1

1

The error came from the routine attempting to list all items of certain types.

The align type was referred to via the code \listeqpatch{align} but the way I was using the align environment was via

\begin{align*}

Write equation here

\end{align*}

which was not recognised by the listing routine and caused a compilation error.

The error disappears either if I remove the \listeqpatch{align} line from the code or if I replace it by \listeqpatch{align*}.

It is still a bit mysterious to me why this compilation error occurs though. I note that it did not happen with the equation environment.

gatsu
  • 121