Math & ScienceMultiply reference warning from an gather environment

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Multiply reference warning from an gather environment

Post by Cham »

I'm getting a "multiply reference warning" during compilation from the small code below (not a MWE), and I don't understand why. It's the only equation using that label :

Code: Select all

	\begin{gather}
	\begin{align}
		S &= A, \\[12pt]
		T &= B, \label{an unique label !}
	\end{align} \\[12pt]
	\begin{align}
		P &= C,
		& Q &= D.
	\end{align}
	\end{gather}
Apparently, I can't use an align environment inside a gather environment, is that the origin of the problem ? Yet, the document compiles fine, and the reference is still working.

What is happening here ??

For vertical spacement problem on the whole page, I need these equations to be presented that way.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
Stefan Kottwitz
Site Admin
Posts: 10359
Joined: Mon Mar 10, 2008 9:44 pm

Multiply reference warning from an gather environment

Post by Stefan Kottwitz »

Cham wrote:It's the only equation using that label
Actually, there's an align environment with the label and a gather environment with that label. It is in both. Open the .aux file and look into it, there will be two labels.
Cham wrote:Apparently, I can't use an align environment inside a gather environment, is that the origin of the problem ?
Yes, that's not intended this way. Both are for standalone use, not for nesting.
Cham wrote:For vertical spacement problem on the whole page, I need these equations to be presented that way.
I'm sure you don't need the gather around. It's not the only way to adjust vertically, especially since you do it manually anyway by using \\[12pt] at two places.

Stefan
LaTeX.org admin
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Multiply reference warning from an gather environment

Post by Cham »

Thanks for the reply, Stefan.

Then how would you code these four equations, so the vertical space between them remains exactly the same ?

The first two equations should be one on top of the other (with their equal sign aligned), while the last two equations should be on the same line.

EDIT : The problem with the following solution is the vertical space between the two sets of equations ; the vspace is now too big :

Code: Select all

        \begin{align}
                S &= A, \\[12pt]
                T &= B, \label{an unique label !}
        \end{align}
        \begin{align}
                P &= C,
                & Q &= D.
        \end{align}
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Multiply reference warning from an gather environment

Post by Cham »

I could use this instead, but this is approximate (by eye). Is there a better way in doing this ?

Code: Select all

        \begin{align}
                S &= A, \\[12pt]
                T &= B, \label{an unique label !}
        \end{align} \vspace{-16pt}
        \begin{align}
                P &= C,
                & Q &= D.
        \end{align}
User avatar
Stefan Kottwitz
Site Admin
Posts: 10359
Joined: Mon Mar 10, 2008 9:44 pm

Multiply reference warning from an gather environment

Post by Stefan Kottwitz »

When something becomes difficult, it's a good indication that one does something uncommon, unusual, which is not foreseen by design. Here, we got two formula blocks, which are different by design. The first has one column with alignment, the other one has two columns spread out. It's not unusual do separate them visually, noticeable by distances. I would even have some text between formula blocks. Like I put introductory text between headings instead of stacking them, and between two images, before a list, and so on. That's for better reading.

Well, you can imitate a single formula block:
  • subtract the default space below a formula block,
  • add the default space between lines within a formula block,
  • subtract the default space above a formula block.
So, we got between the two align environments:

Code: Select all

\vspace{-\belowdisplayskip}
\vspace{\jot}
\vspace{-\abovedisplayskip}
Stefan
LaTeX.org admin
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Multiply reference warning from an gather environment

Post by Cham »

Ah ! Some new commands ! Thanks.

I found that using \medskip instead of \vspace{\jot} gives a very nice result. Is there any "against-indication" in using \medskip there ?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10359
Joined: Mon Mar 10, 2008 9:44 pm

Multiply reference warning from an gather environment

Post by Stefan Kottwitz »

Yes, it is. They are logically different. \jot is the distance between consecutive lines in math mode, \medskip is a medium distance between consecutive paragraphs in text mode.

Classes, packages or templates may adjust them independently, even if they look similar in the current setup.

Stefan
LaTeX.org admin
Post Reply