3

When I use the begin{align*} the equation starts in the red part. How can I start it in the blue part?

enter image description here

\documentclass[a4paper]{article}
\usepackage[margin=1.5cm]{geometry}
\usepackage{amsmath}
\usepackage{xcolor}

\begin{document}
Tex\\
My text
        \begin{align*}
        \color{red}x^2+2x
        \end{align*}
        \begin{align*}
        \hspace{-9cm}\color{blue}x^2+2x
        \end{align*}
My text
\end{document}
1
  • 1
    Do I interpret your question correctly as not wanting to center a displayed equation? If that's correct, do you want to left-align all displayed equations? Please advise.
    – Mico
    Sep 19 at 22:43
4

The answer provided by @MarcelKrüger shows you how to go about having all displayed equation left-aligned. If what you need to achieve is to left-align just this particular pair of equations, I suggest you employ an flalign* environment, as follows:

enter image description here

\documentclass{article}
\usepackage[a4paper,margin=1.5cm]{geometry}
\usepackage{amsmath}
\usepackage{xcolor}

\begin{document}
Text\\
My text
\begin{flalign*} % <-- observe: 'flalign*', not 'align*'
  &\color{red} x^2+2x  & \\
  &\color{blue}x^2+2x  &
\end{flalign*}
My text
\end{document}
4

You can request amsmath to align equations on the left by setting the fleqn (flush left equations) option: Replace \usepackage{amsmath} with \usepackage[fleqn]{amsmath}.

This will still indent the equations by a fixed amount which can be changed by setting \mathindent. You could set this to zero to move the equations completely to the left, but I would recommend against this to make the equations easier to differentiate from regular text.

\documentclass[a4paper]{article}
\usepackage[margin=1.5cm]{geometry}
\usepackage[fleqn]{amsmath}
\usepackage{xcolor}
% \setlength{\mathindent}{0pt} % Uncomment this line to get equations completely aligned on the left.

\begin{document}
Text\\
My text
\begin{align*}
  &\color{red}  x^2+2x \\
  &\color{blue} x^2+2x
\end{align*}
My text
\end{document}
1
  • +1. I've taken the liberty of editing your code to employ a single two-line rather than two consecutiy one-line align* environments.
    – Mico
    Sep 19 at 22:54
4

By use of the nccmath you can some align math environments locally align at left border by inserting it in fleqn environment:

\documentclass{article}
\usepackage{geometry}
\usepackage{nccmath}
\usepackage{xcolor}

\usepackage{lipsum}

\begin{document}
\lipsum[66]
    {\color{red}
    \begin{align*}
    y & = x^2+2x    \\
    z & = 2y
    \end{align*}
    }
\lipsum[1][1-3]
  \begin{fleqn}\color{blue}
    \begin{align*}
    y & = x^2+2x    \\
    z & = 2y
    \end{align*}
\lipsum[1][4-5]
    \begin{align*}
    y & = x^2+2x    \\
    z & = 2y
    \end{align*}
  \end{fleqn}
\lipsum[1][5-6]
    {\color{red}
    \begin{align*}
    y & = x^2+2x    \\
    z & = 2y
    \end{align*}
    }
\lipsum[66]
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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