12

I'd like to have a single equation without indentation at all. I know I can set it globally with

\setlength{\mathindent}{0cm}

But I don't know how to return to the default value after the equation.

Here my minimal example:

\documentclass[a4paper,12pt]{article}
\usepackage[fleqn]{amsmath}
\begin{document}

\noindent
Default indentation: 
\begin{equation}
  a+b=42
\end{equation}
%
Now I want no indention for a single equation:
\setlength{\mathindent}{0cm}
\begin{equation}
  a+b=42
\end{equation}
%
Now I'd like to get the default again:
\begin{equation}
  a+b=42
\end{equation}
%
But how?

\end{document}
  • 2
    I think this answer is much better: https://tex.stackexchange.com/a/167926/73767 It does not affect subsequent equations (even center alignment). But if you use [fleqn] option the center alignment is lost and the subsequent equations become left aligned with fixed indent. – Yan King Yin Dec 30 '17 at 06:42

1 Answers1

15
\documentclass[a4paper,12pt]{article}
\usepackage[fleqn]{amsmath}
\begin{document}

\noindent
Default indentation: 
\begin{equation}
  a+b=42
\end{equation}
%
Now I want no indention for a single equation:
{\setlength{\mathindent}{0cm}
\begin{equation}
  a+b=42
\end{equation}}%
%
Now I'd like to get the default again:
\begin{equation}
  a+b=42
\end{equation}
%
But how?

\end{document}

enter image description here

David Carlisle
  • 757,742
  • ...even the basic principles are unknown to me. Thanks! I will accept as soon as possible. – Robert Seifert Aug 11 '14 at 16:18
  • 2
    @thewaywewalk almost all tex assignments are local so any settings are lost at the next } or \end{zzz} – David Carlisle Aug 11 '14 at 16:40
  • I think this answer is much better: https://tex.stackexchange.com/a/167926/73767 It does not affect subsequent equations (even center alignment). But if you use [fleqn] option the center alignment is lost and the subsequent equations become left aligned with fixed indent. – Yan King Yin Dec 30 '17 at 06:44
  • I downvoted this answer since it has unfortunate side-effects: it indents the paragraph right after the equation. – Matthew Nov 29 '20 at 17:44
  • @Matthew you must have copied the code incorrectly. This does not cause any non math text to be indented, I added an image of the output to the answer. – David Carlisle Nov 29 '20 at 17:48
  • @DavidCarlisle Sorry I am not very good with Latex, but I can ensure you that with the particular cls I'm using, I get an indentation for "Now I'd like". That being said, you're right this does not happen in the article class, so I have removed the downvote. – Matthew Nov 29 '20 at 18:22
  • @Matthew that would be a bug in the class file. It happens. Either that or you added a blank line before Now – David Carlisle Nov 29 '20 at 19:23