5

I have two consecutive lists of equations, the second of which is quite long (16 lines with no reasonable way to shorten it apparent). Because the center alignment of gather looks ugly in this case, I've nested an align environment in order to align the various equations in a sensible way.

Unfortunately, the second list is long enough that I would like to allow it to break over two pages to avoid the massive white space that results when the entire list floats to the next page. I'd like to let TeX handle it automatically rather than forcing the break with \displaybreak.

The super simplified MWE (without alignment characters since only the length of the environment, and not the specific alignment, seems to matter):

\documentclass[12pt]{article}
\usepackage{amsmath}
\allowdisplaybreaks
\usepackage[bottom]{footmisc} % Needed to avoid strange behavior of the footnote
\linespread{1.55}
\begin{document}

Here is my first gather with nested align
\begin{gather}
    \begin{align}
    1\\
    2\\
    3\\
    4\\
    5\\
    6\\
    7\footnotemark
    \end{align}
\end{gather}
\footnotetext{Footnote text.} 

Here is my second gather with nested align:
\begin{gather}
    \begin{align}
        1\\
        2\\
        3\\
        4\\
        5\\
        6\\
        7\\
        8\\
        9\\
        10\\
        11\\
        12\\
        13\\
        14\\
        15\\
        16
    \end{align}
\end{gather}

\end{document}

Now, there's at least one problem with this attempt that I'm aware of:

I shouldn't use align: as explained in this answer to "How to use \displaybreak" align environments are unbreakable and so \allowdisplaybreaks and \displaybreak have no effect. The suggestion there is to use align*.

Unfortunately, the same problem arises with a simple substitution of align* for align in the preceding MWE (also it's quite annoying to not have automatic numbering).

How can I achieve an aligned list of numbered equations (that are easy to cross-reference and, if possible, automatically tagged) that will break across pages when length and context requires?

Edit 1

As juanuni points out in the comments, the gather environment is unnecessary here. The reason it is there is somewhat idiosyncratic. In the document this problem arose in I have custom gather and equation environments with distinct counters and tag formats. Being a bit lazy, I just used the custom gather environment to pass the relevant counter (not equation's counter) and tag format to the nested align.

Edit 2 (Now with puzzlement!)

Well, a combination of shame and insomnia prompted me to stop being lazy and just create the custom align environment. Interestingly, when I use my custom align without nesting it in the custom gather, I get the desired result: the long align environment breaks across the page.

But this confuses me. My custom align (along with the new counter) is defined as follows:

\newcounter{defcounter}
\makeatletter
\newenvironment{defalign}{%
  \let\c@equation\c@defcounter% switches to defcounter
  \renewcommand\theequation{D.\arabic{equation}}
  \align}
  {\endalign}
\makeatother

But the the answer linked above suggests that what I just did shouldn't work. Why does it?

  • 1
    Without gather environment you can obtain the same result. From the other hand, I don't know what equations have you, but maybe you could decrease the vertical space between equations making \\[0.5cm] (or what you want) instead just \\, to adjust the vertical space ... – juanuni Jul 25 '15 at 4:47
  • @juanuni Good call with gather being unnecessary. I was using a modified gather environment (with a counter distinct from equation's) in the non-MWE, but has no effect on the problematic behavior here. Essentially, I was just using the gather to provide the relevant counter (not equation's counter) for the nested align. Probably a less hack-ish way to do it, but I was lazy. I'll mention this in the question since the fact that these environments are nested might be relevant to page breaking behavior in the non-MWE (though I really don't know) and they'll be nested there. – Dennis Jul 25 '15 at 5:02
  • :O I understand. – juanuni Jul 25 '15 at 5:30
  • @Dennis Based on your comment, this is an XY question: you think that abusing gather has solved your problem with the counter, but, as you clearly see, it hasn't. So, please, accept the given answer and ask a new question stating your real problem, that is, changing the counter used by align (which is surely solvable without abusing gather). – egreg Jul 25 '15 at 7:22
9

\allowdisplaybreaks doesn't work simply because you are nesting an align inside a gather environment. This causes the align to be wrapped in an unbreakable box. The solution is obvious: remove the gather environment, which is unneeded.

But the align itself isn't generally wrapped in an unbreakable box. This is always true for the following amsmath's environments:

  • split
  • aligned
  • gathered
  • alignedat

Note that the first three are meant to be used inside another math environment like equation.

In regards of your latest question, the answer you refer to states that aligned inside equation* is unbreakable and the suggestion is to use align* instead. Nowhere is stated that align is unbreakable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.