14

I would like to get this WITHOUT using tables, because in my real equations there are fractions included that are scaled down in tables

a+b+c=1
y    =2

My code looks as follows:

\begin{align*}
&a+b+c&=1\\
&y    &=2
\end{align*}

But it doesn't work. I tried thousands of things such as flalign and so on. But nothing works. I am really frustrated. Any ideas?

2
  • @HagenBrenner - I get the equations aligned as you wanted (at = and start of line) using your code and pdflatex.
    – mathematical.coffee
    Commented Jan 13, 2012 at 2:21
  • This is because your setting are set up so that all your equations are aligned left (start of line). My equations are all centered. But I want this particular one to be left aligned. Commented Jan 13, 2012 at 9:09

4 Answers 4

8

You can use "big fractions" also inside array; using the array package helps, so say

\usepackage{array}

in your preamble. Then you can use

\begin{array}{@{}>{\displaystyle}l@{}>{\displaystyle{}}l@{}}
a+b+c &= y           \\
y     &= \frac{2}{3}
\end{array}

just as a single (math) object that you can put anywhere you like. Adding \vphantom{\frac{2}{3}} before the \\ in the first row can help spacing.

enter image description here

For example, with

\begin{flalign*}
\begin{array}{@{}>{\displaystyle}l@{}>{\displaystyle{}}l@{}}
    a+b+c &= y           \vphantom{\frac{2}{3}}\\
    y     &= \frac{2}{3}
\end{array}
&&
\end{flalign*}

you'll get the object flush with the left margin.

2
  • Hi egreg, this solutions is brilliant! thank you so much! there is just one thing that disturbs me. the space between the lines of the array is to small. I put in brackts the space in cm behind \\. Is there a more generic way to do this? Commented Jan 13, 2012 at 13:12
  • @HagenBrenner You might set \arraystretch to a different value: for example \renewcommand{\arraystretch}{1.2} just after \begin{flalign*} or, in any case, before the array environment.
    – egreg
    Commented Jan 13, 2012 at 13:27
11

You can use \phantom to apply the appropriate spacing within the align environment to ensure that the y is aligned with the a and the = signs are also aligned. If you want this entire equation adjacent to the left margin you can use flalign.

enter image description here

Note:

  • Note the trailing & which is needed to get equation all the way to the left margin.

Code:

\documentclass{article}
\usepackage{amsmath}
%\usepackage[showframe]{geometry}% Uncomment to see margins

\begin{document}
\begin{flalign*}
                 a+b+c&=1 &\\% Need this trailing alignment char to get all the way left
    y\phantom{{}+b+c} &=2 &
\end{flalign*}
\end{document}
2
  • Thanks for your reply! But this answere does not left-align the formulas. My formulas are all centered. Again, my question is: How can write formulas like this but in addition to that left align them? I want the left alignment only for this single formula, not for all formulas. Commented Jan 13, 2012 at 8:55
  • @HagenBrenner: Sorry, I misunderstood your question. Have updated solution. Commented Jan 13, 2012 at 18:44
5

Here's your answer

\begin{alignat*}{2}‎
&a+b+c&&=1\\‎‎
&y&&=2
\end{alignat*}

Explanation: align is an environment for shifting between left-aligned columns and right-aligned ones, so if you want your equation to be shown as a totally left-aligned one, you need to add an extra column between the left-aligned columns. In the above example, first & in each line makes a left-aligned column, if you delete this ones you'll get a right-aligned column. The second ampersands in each line make a right-aligned column but we don't need this column so we add a third column by adding an & after the last ampersands in each line. flalign is a variation of align that increases the space between columns so as to cover the line completely. alignat omits unnecessary spaces between the columns (the other difference between alignat and align is that the first one takes an argument which shows the number of the columns). Note that adding a * after each of these three, makes them untaged.

3
  • 2
    Is there a reason this isn't higher up, as it seems like it solves OP's problem exactly. Is there a reason to avoid alignat* ?
    – alecbz
    Commented Oct 30, 2013 at 3:25
  • 1
    Excellent solution, far simpler. User's Guide for ams math Package presents both alignat and flalign as standard alignment environments for displayed equations.
    – oLas
    Commented May 6, 2014 at 20:56
  • Perfect, this was exactly what I was looking for. This should be the accepted answer. I didn't know that align shifts between left and right alignment, nor why code snippets I found around the web used && instead of &. Now I understand.
    – J.Galt
    Commented May 18, 2022 at 19:32
1

In order to use big fractions inline, use \dfrac{}{} instead of \frac{}{}.
flalign needs an extra ampersand at the end to really align left.
Here is a not-really-minimal example:

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

\begin{document}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, 
sed diam nonumy eirmod tempor invidunt e magna aliquyam erat, sed diam voluptua. 
At vero eos et accusam et justo duo dolores et ea rebum.
%
In order for \verb+flalign+ to align left, 
you need to put an ampersand at the end of the line.
I cannot really explain why, but it works.
\begin{flalign}
a   &=3         & \\
b   &=4         & \\
c   &=a+b       & 
\end{flalign}
%
To have several equation columns side-by-side, 
use extra ampersands to separate the columns:
\begin{flalign}
x       &=y         & X         &=Y         &\\
x'      &=y'        & X'        &=Y'        &\\
x+x'    &=y+y'      & X+X'      &=Y+Y'      &
\end{flalign}
%
Line-by-line annotations on an equation can be done by judicious application of
\verb+\text{}+ inside an align environment.
Out of the two \verb+&&+ the first one creates a new column 
and the second one is for alingment.
\begin{flalign}
 x& = y_1-y_2+y_3-y_5+y_8-\dots     && \text{by Axiom 1.}   &\\
  & = y’\circ y^*                   && \text{by Axiom 2.}   &\\
  & = y(0) y’                       && \text {by Axiom 3.}  &
\end{flalign}
%
To have big fractions inline in text or tables/tabulars, 
use \verb+\dfrac{}{}+ instead of \verb+\frac{}{}+. 
It will result in a big fraction like $\dfrac{3}{4}$ instead of $\frac{3}{4}$.
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .