TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am fairly new to TeX and need to create my math assignment with TeX.

I have succeeded aligning all my calculations with the use of \begin{align*} and \intertext{}, however in my document i have sections and subsections and if I \end{align*} and begin after the sections or subsections the alignment is off.

I have gone through google but all I can find is about \begin{equation} and has no mentioning of sections nor graphics.

How do I (if it is possible) make the alignment through the entire document?


\section{Opgave 1}

\subsection{a) Beregn arealet, der begrænses af kurven for $f(x) = x^{3}$, x-aksen og
linjerne $x = -1$ og $x = 1$.}
\begin{align*} % This
\intertext{Først beregnes det bestemte integrale imellem $x = 0$ og $x = 1$:}
\int_0^1 x^{3}\ dx &= 0.25\\
\intertext{Da den er symetrisk omkring 0 kan vi tage det dobbelte areal:}
0.25 \cdot 2 &= 0.50\\

Opg. 1, a)


\subsection{b) Bestem arealet af den lukkede figur, der dannes af parablen med regneforskriften $f(x) = -x^2 + 2x + 1$ og den rette linje med regneforskriften $g(x) = -0,5x + 1$}
\begin{align*} % Is not aligned with this
\intertext{Først findes de punkter hvor $g(x)$ afgrænser $f(x)$:}
f(x) &= g(x) \\
-x^2 + 2\cdot x + 1 &= -0.5\cdot x + 1 \\
solve(-x^2 + 2\cdot x + 1 &= -0.5\cdot x + 1,x) \\
x &= 0\\
x &= 2.5\\
\intertext{Så tager vi det bestemte integrale imellem $x = 0$ og $x = 2.5$:}
\int_0^{2.5} -x^2 + 2x + 1\ dx &= 3.54167
\intertext{Og det bestemte integrale for $g(x)$, for at fjerne arealet under linjen:}
\int_0^{2.5} -0.5\cdot x + 1 dx &= 0.9375
\intertext{Nu trækkes arealet under linjen fra:}
3.54167 - 0.9375 &= 2.60417\\
share|improve this question
Equation alignment is a local matter, the sizes of the right hand side and left hand side of equations a couple of lines apart (and thus their alignment) normally varies wildly. I haven't felt any urge for this at all, ever. I do use fleqn all the time, I hate centered equations. But that's just me. (Yes, I did write a set of math-heavy lecture notes, and I've read my fill of math books too; it's not just the opinion of a random passerby.) – vonbrand Apr 5 '13 at 14:49
Welcome to TeX.sx! Usually, we don't put 'hello' or 'thank you' in our posts; this isn't perceived as rude, but merely an attempt to keep everything very concise. Now, it may be possible (but horrible practice) to have text interjecting an array environment, but it may not turn out how you like. Margins might die. It bothers the OCD in me too, but I would steer clear of trying to implement this out in the wild. – Sean Allred Apr 5 '13 at 14:51
All right, so it seems I have to stick with aligning sections at a time, a bit of a shame though. Thanks for your answer :-) – Evilunclebill Apr 5 '13 at 14:51
@SvendMortensen Tak :-) I will keep my future examples as minimal as possible. – Evilunclebill Apr 5 '13 at 14:55
I guess the easiest workaround would be to use fleqn and manually make sure that the left-hand side of each equation has the same width. This could be done with \hrule and \rlap. On the other hand, a likely explanation for why this isn't easy is that it may not be desirable. Having every single equation aligned on its equals sign may imply relations where they don't exist. – Matthew Leingang Apr 5 '13 at 15:47
up vote 4 down vote accepted

I agree with the comments to the questions that usually it's not desirable to have one fixed alignment throughout the whole document, but it can be done quite easily:


One possibility is to add a suitable \fixedalign command to each align environment you use:

\newcommand\fixedalign{\hspace{0.5\linewidth} &
                       \hspace{0.5\linewidth} \nonumber \\[-\baselineskip]}
First alignment:
a &= b + c
Second alignment:
d + e &= f

This adds an empty line at the beginning of the alignment that fixes the alignment tab. You can adjust the 0.5\linewidth to your needs, just make sure that the two numbers add up to 1. Note that I added \nonumber so that no additional number is added if the command can be used in align instead of align*.

If you want to define a new environment that adds this empty line automatically, you have to use \NewEnviron from the environ package since align is somewhat special.

\hspace{0.5\linewidth} & \hspace{0.5\linewidth} \nonumber \\[-\baselineskip]
First alignment:
a &= b + c
Second alignment:
d + e &= f
share|improve this answer
This is awesome, thanks! – Evilunclebill Apr 6 '13 at 12:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.