framed equations

here is your code with a simple box:

\documentclass[fleqn,12pt]{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{kpfonts}
\usepackage{microtype}
\usepackage{xcolor}
\usepackage{amsmath}
\newsavebox\MBox

\newenvironment{fequation}{%
  \setlength\abovedisplayskip{0pt}%
  \setlength\belowdisplayskip{0pt}%
  \setlength\abovedisplayshortskip{0pt}%
  \setlength\belowdisplayshortskip{0pt}%
  \par\noindent\begin{lrbox}{\MBox}
  
  \minipage{\dimexpr \linewidth-2\fboxsep-2\fboxrule\relax}

  \equation\strut%
}{%
  \endequation%
  \endminipage%
  \end{lrbox}\fcolorbox{red!80}{red!20}{\usebox\MBox}%
  \ignorespacesafterend\par\noindent}%
    
\begin{document}
Suspendisse lectus tortor, dignissim sit amet, adipiscing nec
%
\begin{equation}
\cos t=\pi
\end{equation}
%
por
%
\begin{fequation}
\cos t=\pi
\end{fequation}
%
vitae, 
\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}

enter image description here


With tcolorbox help it's easy to declare your own environments for boxed equations

\documentclass[fleqn,12pt]{book}
\usepackage{microtype}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{kpfonts}
\usepackage{xcolor}
\usepackage{amsmath}
\usepackage[most]{tcolorbox}
\usepackage{lipsum}

\tcbset{colback=red!20, colframe=red!80}

\newtcolorbox{fequation}[1][]{ams equation,size=small,#1}

\begin{document}
\lipsum[4]
\begin{equation}
\cos t=\pi
\end{equation}
\lipsum[4]
\begin{fequation}
\cos t=\pi
\end{fequation}
vitae, consequat in, pretium a, enim. Pellentesque congue.
\begin{fequation}[ams align]
\cos t&=\pi\\
\sin t&=-\pi
\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}

enter image description here


You can use floatto create your own floating environment, with the boxed option:

\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}
\usepackage{float}
\usepackage{lipsum}

\floatstyle{boxed}
\newfloat{frameequation}{hbtp}{feq}[section]
\floatname{frameequation}{Equation}

\newcommand{\freq}[2]{%
\begin{frameequation}%
\ensuremath{\hfill #1 \hfill}%
\caption{#2}
\end{frameequation}%
}


\begin{document}

\section{Some math topic}

\lipsum[1]

\freq{\int\limits^{\infty}_{0}\left(\frac{1}{x}\right)dx=???}{One}

\lipsum[1]

\freq{\int\limits^{\infty}_{0}\left(\frac{1}{x}\right)dx=???}{Two}

\lipsum[1]

\freq{\int\limits^{\infty}_{0}\left(\frac{1}{x}\right)dx=???}{Three}

\lipsum[1]

\end{document}

Which produces:

enter image description here