Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
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 May 11 '13 at 14:34

2 Answers 2

up vote 2 down vote accepted

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

share|improve this answer

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}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.