I'm aware of possibilities to frame an "important" equation in Latex as the one suggested in mathmode for instance but I thought it would be nice to have a dedicated environment instead of putting frames or boxes around equations on the fly. So I came up with what follows by just adapting the existing equation environment:
\documentclass[fleqn,12pt]{book}
\usepackage{microtype}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{kpfonts}
\usepackage{xcolor}
\usepackage{amsmath}
\usepackage{framed}
\renewcommand*\FrameCommand{\fcolorbox{red!80}{red!20}}%
\makeatletter
\newenvironment{fequation}{%
%\setlength\abovedisplayskip{3pt}
%\setlength\belowdisplayskip{3pt}
\incr@eqnum%
\mathdisplay@push%
\st@rredfalse \global\@eqnswtrue%
\MakeFramed{%
\vspace*{-\baselineskip}%
\FrameRestore}%
\mathdisplay{equation}%
}{%
\endmathdisplay{equation}%
\mathdisplay@pop%
\ignorespacesafterend%
\vspace*{-\baselineskip}
\endMakeFramed\noindent%
}%
\makeatother
\begin{document}
Suspendisse lectus tortor, dignissim sit amet, adipiscing nec
\begin{equation}
\cos t=\pi
\end{equation}
porttitor, orci nec nonummy molestie, enim est eleifend mi, non
\begin{fequation}
\cos t=\pi
\end{fequation}
vitae, consequat in, pretium a, enim. Pellentesque congue.
\begin{fequation}
\begin{aligned}
&\cos t=\pi\\
&\sin t=-\pi
\end{aligned}
\end{fequation}
vitae, consequat in, pretium a, enim. Pellentesque congue.
\begin{fequation}
\biggl(\int_\Omega \frac{t^2}{t+1}\D{t}\biggr)=1
\end{fequation}
\end{document}
I've been playing around the \vspace*
as well as \abovedisplayskip
and \belowdisplayskip
commands for tuning but I am wondering how to control the vertical white space between main text and framed equations? Also, any improvement that you find interesting is welcome.
empheq
, it has it already\abovedisplayskip
and\belowdisplayskip
control the vertical space inside the box? Why not outside?