6

This is a follow-up to this question.

Here is an exemple of the code I wrote to add a light gray background to important equations:

\documentclass{article}

\usepackage[fleqn]{amsmath}
% \usepackage[frenchb]{babel}

% Coloured background
\usepackage{xcolor}
\usepackage{mdframed}
\newmdenv[backgroundcolor=black!3!white,
          linewidth=0pt,
          innerleftmargin=0pt,
          innerrightmargin=0pt,
          innertopmargin=0.2\baselineskip,
          innerbottommargin=0.2\baselineskip]{graybck}


\newcommand{\highlighteq}[1]{#1}
\newenvironment{highlighteqenv}{%
\noindent
\vspace{0.2\baselineskip}
\begin{graybck}
}
{\end{graybck}}

\begin{document}
He said : ` you must defeat Sheng Long to stand a chance' which more or less amounted to
\begin{highlighteqenv}
  \begin{equation}
      \frac{\partial \langle \alpha K \rangle}{\partial t} + \frac{\partial \lambda}{\partial z} =0
  \end{equation}
\end{highlighteqenv}

\end{document}

Quite strangely, it produces a wrong spacing before the equation, as displayed on the following picture:

Spacing problem

Removing either the fleqn option of amsmath of the loading of babel with the frenchb option solves the problem :

Good spacing

I would expect frencb to cause such issue with something regarding paragraph indentation but why does it interact with fleqn?

Do you have any idea to prevent this additional space from appearing while keeping these two options?

1 Answer 1

6

This shows a problem which is not related to mdframed, but appears with the french module in babel whenever you start a math environment in vertical mode together with the fleqn option; the space would be added also with the input

He said : `you must defeat Sheng Long to stand a chance' which more or less amounted to

  \begin{equation}
      \frac{\partial \langle \alpha K \rangle}{\partial t} + \frac{\partial \lambda}{\partial z} =0
  \end{equation}

(notice the blank line)

A paragraph is started anyway, so a "solution" (which is more of a hack) is to backup manually:

\newenvironment{highlighteqenv}
  {\par\vspace{0.2\baselineskip}
   \begin{graybck}
   \leavevmode\vspace{-\baselineskip}\ignorespaces}
  {\end{graybck}}

You don't need the \noindent anyway; better, though, adding a \par.

However, I'd suggest to use the standard spacing used for math displays:

\newenvironment{highlighteqenv}
  {\par\vspace{\abovedisplayskip}
   \begin{graybck}
   \leavevmode\vspace{-\baselineskip}\ignorespaces}
  {\end{graybck}\vspace\belowdisplayskip}
0

You must log in to answer this question.

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