Math & ScienceHorizontal Spacing in aligned Equations

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
Pratt_G
Posts: 3
Joined: Mon Sep 02, 2013 5:41 pm

Horizontal Spacing in aligned Equations

Post by Pratt_G »

Hi,

can anyone please help me understand the following two issues?
  1. Why do I get non-uniform and inordinate spacing between the columns? The first summation is very close to "min" and the second summation is way too from the first summation.
  2. Is there any way to left-align the columns? I want the third columns to be aligned left.

Code: Select all

\documentclass[11 pt]{article}
\usepackage {amsmath}

\begin{document}
  \begin{subequations}
    \begin{align}
      \min\limits_{\lambda} & \sum\limits_{k \in R} & (\sum\limits_{i=1}^{M} a_i \quad +\\
      & & \sum \limits_{j=1}^N b_j \quad + \quad \sum       \limits_{j=1}^N c_j \quad +  \\
    \end{align}					 
  \end{subequations}
\end{document}
Thanks,
P
Last edited by localghost on Mon Sep 02, 2013 6:12 pm, edited 1 time in total.

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Horizontal Spacing in aligned Equations

Post by localghost »

The alignat environment is your friend.

Code: Select all

\documentclass[11pt]{article}
\usepackage{mathtools}  % loads »amsmath«

\begin{document}
  \begin{subequations}
    \begin{alignat}{2}
      \min\limits_{\lambda} & \sum\limits_{k\in R} & \Big(\sum\limits_{i=1}^{M} a_i \quad + \\
     & \sum \limits_{j=1}^N b_j \quad + \quad &\sum\limits_{j=1}^N c_j \quad +
    \end{alignat}                                      
  \end{subequations}
\end{document}
Since there seem to be going more elements into the equations, you might need to choose another number as parameter for the environment.


Further reading:

Best regards and welcome to the board
Thorsten
Pratt_G
Posts: 3
Joined: Mon Sep 02, 2013 5:41 pm

Re: Horizontal Spacing in aligned Equations

Post by Pratt_G »

Thanks. That worked. But in my general experience align and alignat have been very painful to use especially because their preset horizontal alignments. I prefer to use array instead, as it allows me to flexibly choose the alignment of individual columns. Now only if there was a way to use array under subequations environment.
Post Reply