Math & ScienceHorizontal Spacing within aligned Equations

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

Horizontal Spacing within aligned Equations

Post by Cham »

I'm having a spacing problem with the following minimal working code. The first four items aren't horizontally spaced enough and I don't know why.

Code: Select all

\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage{mathtools}

\begin{document}
Test

  \begin{equation}
    \begin{gathered}
      \begin{aligned}
        \tilde{A} &= {\Omega}^{2} \, A,
        &\tilde{B} &= {\Omega}^{- 2} \, B, \\[12pt]
        \tilde{\Phi} &= {\Omega}^{w} \, \Phi,
        &\tilde{\Psi} &= {\Omega}^{w} \, \Psi,
      \end{aligned} \\[12pt]
      \tilde{A}_{\mu_1 \, \ldots \, \mu_q}^{\lambda_1 \, \ldots \, \lambda_p} = {\Omega}^{w} \, A_{\mu_1 \, \ldots \, \mu_q}^{\lambda_1 \, \ldots \, \lambda_p}.
    \end{gathered}
  \end{equation}
\end{document}
The aligned items should be spaced like in the align environment.

Any idea what is going on here?

Recommended reading 2024:

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

NEW: TikZ book now 40% off at Amazon.com for a short time.

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Re: Horizontal Spacing within aligned Equations

Post by Johannes_B »

Would you be able to clarify what isn't aligned properly? Maybe by inserting comments directly inside the code or uploading a screen shot of the resulting PDF with little marks (done by Gimp or something similar).

Best regards
Johannes



PS: Remember to click on "Open in writeLaTeX" to see the same output that we see.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Horizontal Spacing within aligned Equations

Post by Cham »

When you click on the "Open in writeLaTeX" button, you get a well compiled code. Except that the "A", "B", 'Phi" and "Psi" items are too close from each other (horizontally), compared to what we get in the usual align environment.

I think that the aligned environment should output the same horizontal spacing as the align environment.

Here's the output from the code above :
aligned.jpg
aligned.jpg (11.78 KiB) Viewed 40357 times
And here's the output from the code below (I'm not sure it's the proper way to do this, since I want a single equ. number for all the set of equations) :
align.jpg
align.jpg (11.82 KiB) Viewed 40357 times

Code: Select all

\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage{mathtools}

\begin{document}
Test
  \begin{align}
    \tilde{A} &= {\Omega}^{2} \, A,
    &\tilde{B} &= {\Omega}^{- 2} \, B, \nonumber \\[12pt]
    \tilde{\Phi} &= {\Omega}^{w} \, \Phi,
    &\tilde{\Psi} &= {\Omega}^{w} \, \Psi,
  \end{align}
  \begin{equation*}
    \tilde{A}_{\mu_1 \, \ldots \, \mu_q}^{\lambda_1 \, \ldots \, \lambda_p} = {\Omega}^{w} \, A_{\mu_1 \, \ldots \, \mu_q}^{\lambda_1 \, \ldots \, \lambda_p}.
  \end{equation*}
\end{document}
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Horizontal Spacing within aligned Equations

Post by cgnieder »

Cham wrote:the "A", "B", 'Phi" and "Psi" items are too close from each other (horizontally), compared to what we get in the usual align environment.
Why don't you just use align then? (Probably because of the equation numbers?) You could also simply add horizontal spacing by inserting a \quad (inserts 1em of space), \qquad (inserts 2em of space) or \hspace{<dim>} in one of the lines.
Cham wrote:I think that the aligned environment should output the same horizontal spacing as the align environment.
Well, the AMS which is maintaining amsmath seems to have a different opinion. The {aligned} environment is certainly not going to change since that would break lots of documents that rely upon its current behavior.

Regards
site moderator & package author
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Horizontal Spacing within aligned Equations

Post by Cham »

Well, I already tried the \qquad spacing trick, but the equal signs aren't properly aligned anymore (within a gather environment). And apparently, the align environment can't be used inside a gather environment, or can it ?

Edit: I'm an incredibly stupid idiot! Adding the \qquad spacing in the items, inside the aligned environment solves the issue! :oops:
Post Reply