GeneralA simple problem with extra space in "aligning"

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
aliagha
Posts: 2
Joined: Mon Nov 08, 2010 1:17 am

A simple problem with extra space in "aligning"

Post by aliagha »

I write the following very simple lines, and I just want to left align the equality signs in two lines. But a lot of extra space appear before the second equality sign in each line. How can I align them without having these extra spaces. Thank you very much in advance.

I tried 3 different ways and have the same problem in all:
***********************
\begin{align}
X&=X+W&=f\\
x&=x&=f_2.
\end{align}
************************
\begin{align}
X&=X+W&&=f\\
x&=x&&=f_2.
\end{align}
************************
\begin{align}
X&=X+W&=&f\\
x&=x&=&f_2.
\end{align}
***********************

Recommended reading 2024:

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

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

frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

A simple problem with extra space in "aligning"

Post by frabjous »

Perhaps alignat would be suitable?

Code: Select all

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{alignat}{2}
X&=X+W& &=f\\
x&=x  & &=f_2.
\end{alignat}
\end{document}
If not, then consider some kind of matrix or array environment.
aliagha
Posts: 2
Joined: Mon Nov 08, 2010 1:17 am

Re: A simple problem with extra space in "aligning"

Post by aliagha »

Thank you very much! "alignat" solved the problem.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

A simple problem with extra space in "aligning"

Post by localghost »

Now that the problem is solved, please be so kind and mark the topic (not the last post) accordingly as clearly written in Section 3 of the Board Rules (to be read before posting). Please keep that in mind for the future so that further reminders will not be necessary.


Thorsten
Post Reply