8

I would like to have some math not centered but left aligned. So I found on this site various answers that pointed me to this:

\documentclass{article}
\usepackage{showframe}
\usepackage{amsmath}
\begin{document}
\begin{flalign*}
1+1=2  &&
\end{flalign*}
\end{document}

However I also would like the left aligned math to be indented by \parindent, how could I do that without loading fleqn as a general option?

11
  • Is there any reason for not using the option fleqn?
    – Ch'en Meng
    Dec 7, 2013 at 13:31
  • @Ch'enMeng because only some math should be left aligned, not all.
    – BeeGirl
    Dec 7, 2013 at 13:37
  • @BeeGirl Well, try $ ... $ with \displaystyle (if really need)?
    – Ch'en Meng
    Dec 7, 2013 at 13:45
  • 3
    @HenriMenke that is not the same issue since the OP is using fleqn, while I said I don't want to
    – BeeGirl
    Dec 7, 2013 at 13:54
  • 2
    @Closers this question is different from the one linked as a duplicate since here the OP wants both centered and left-aligned equations. Dec 7, 2013 at 15:41

2 Answers 2

7

Remarks

You can indent your flalign by using the definition of flalignfrom amsmath.sty and modifiying it to your liking, e.g. inserting \hskip\parindent.

Implementation

\documentclass{article}
\pagestyle{empty} % for cropping
\newcommand\shortlipsum{
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit,
    vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida
    mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna.\par
} % Filltext
\usepackage{amsmath}
\makeatletter
\newenvironment{shiftedflalign}{%
    \start@align\tw@\st@rredfalse\m@ne%
    \hskip\parindent
}{%
    \endalign
}
\newenvironment{shiftedflalign*}{%
    \start@align\tw@\st@rredtrue\m@ne
    \hskip\parindent
}{%
    \endalign
}
\makeatother
\begin{document}

\shortlipsum
\begin{flalign}
    1+1=2  &&
\end{flalign}
\shortlipsum
\moveright\parindent\vbox{%
\begin{flalign}
    1+1=2  &&
\end{flalign}
}
\shortlipsum
\begin{shiftedflalign}
    1+1=2  &&
\end{shiftedflalign}
\shortlipsum

\begin{flalign*}
    1+1=2  &&
\end{flalign*}
\shortlipsum
\begin{shiftedflalign*}
    1+1=2  &&
\end{shiftedflalign*}
\shortlipsum

\end{document}

Output

enter image description here

4
  • ok, this is it. Could you point out to a question that describes the differences between the various math environments? Also a resource online, not necessarily on this site. Thanks
    – BeeGirl
    Dec 7, 2013 at 15:14
  • 2
    @BeeGirl The mathmode manual by Herbert Voß describes all the important things. Dec 7, 2013 at 16:08
  • @HenriMenke Can you remove the superfluous % in \newenvironment{shiftedflalign}? It caused me to question why that was not in \newenvironment{shiftedflalign*}. Jun 25, 2014 at 9:23
  • As an aside, you can use \mathindent (see LaTeX/Advanced Mathematics) instead of \parindent to get the normal indentation used by fleqn. Jun 25, 2014 at 9:26
12

A very simple method.

We define a new command

\newcommand{\mathleft}{\@fleqntrue\@mathmargin\parindent}

to simulate the option fleqn with \parindent indenting, and a new command to restore the normal behavior

\newcommand{\mathcenter}{\@fleqnfalse}

So, add the following lines in the preamble

\makeatletter
\newcommand{\mathleft}{\@fleqntrue\@mathmargin\parindent}
\newcommand{\mathcenter}{\@fleqnfalse}
\makeatother

and issue \mathleft before and \mathcenter after the math stuff you want left aligned with \parindent.

You can use this solution with all math environments without redefining any of them.

MWE

\documentclass{article}
\usepackage{showframe}
\usepackage{amsmath}

\makeatletter
\newcommand{\mathleft}{\@fleqntrue\@mathmargin\parindent}
\newcommand{\mathcenter}{\@fleqnfalse}
\makeatother

\begin{document}

\mathleft
\begin{equation}
1+1=2
\end{equation}
\mathcenter

Indented paragraph

\begin{equation}
1+1=2
\end{equation}

Indented paragraph

\end{document} 

Output

enter image description here

1
  • this is not really safe, the fleqn option is a mixture of load-time and run-time changes and changing the value of the boolean flag after the package is loaded leaves amsmath in a broken state, see for example tex.stackexchange.com/a/462885 Dec 3, 2018 at 0:14

This site is temporarily in read-only mode and not accepting new answers.

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