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?

BeeGirl
  • 259

2 Answers2

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

karlkoeller
  • 124,410
  • 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 https://tex.stackexchange.com/a/462885 – David Carlisle Dec 03 '18 at 00:14
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

Henri Menke
  • 109,596