3

I have this simple latex code:

\documentclass{article}
\usepackage{color}
\usepackage{breqn}
\begin{document}
\begin{dmath}[background={red}]
1+1=2
\end{dmath}
\end{document}

However using background option for dmath seems not to work at all, the background stays white.

I compiled with MiKTeX 2.9.4533 without any warnings.

I have also tried

\begin{dmath}[background=red]
\begin{dmath}[color={blue}]
\begin{dmath}[color=blue]

And some more combinations but none of them works.

Why is that?

1
  • 1
    I'm not sure color is really implemented: the option background defines \eq@background which is used nowhere. The same holds for the color option that defines \eq@foreground, but also this command is used nowhere.
    – egreg
    Commented May 11, 2013 at 14:34

2 Answers 2

2

This kind of works.

\documentclass{article}
\usepackage{xcolor}
\usepackage{breqn}

\makeatletter
%%% Fix the `color` option
\define@key{breqn}{color}{\color{#1}}
%%% redefine \eqframe to use the background color
\renewcommand{\eqframe}[2]{%
  \begingroup
  \fboxrule=\eq@framewd\relax\fboxsep=\eq@framesep\relax
  \fcolorbox{\eq@background}{\eq@background}{%
    \z@rule\@height#2\kern#1}%
  \endgroup}
\def\eq@background{white}
\makeatother

\begin{document}
\begin{dmath}[frame,background=red!20,color=blue!80]
1+1=2
\end{dmath}
\end{document}

enter image description here

3

If you seach for background in the breqn source you find (only)

\define@key{breqn}{background}{\def\eq@background{#1}%

That is the background key saves the colour in an internal macro which is never used.

Perhaps this instead:

\documentclass{article}
\usepackage{color}
\usepackage{breqn}
\begin{document}

\noindent{\fboxsep=0pt
\colorbox{red}{\begin{minipage}{\textwidth}
\begin{dmath}
\color{yellow} 1+1=2
\end{dmath}
\end{minipage}}}

\end{document}

You must log in to answer this question.

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