19

My minimum working example:

\documentclass{report}

\usepackage{amsmath}

\begin{document}

\begin{center}
\boxed{K_{k+1}=P_ka_{k+1}^T(a_{k+1}P_ka_{k+1}^T+I_N)^{-1}}
\end{center}

\end{document}

The result:

enter image description here

Now how can I number this equation?

25

Just replace center environment with equation. I think it looks a little better with larger parentheses.

Edit: It might be easier to read as a fraction - except that it seems to be an equation about matrices ...

\documentclass{report}

\usepackage{amsmath}

\begin{document}

\begin{equation}
\boxed{K_{k+1}=P_ka_{k+1}^T\left(a_{k+1}P_ka_{k+1}^T+I_N\right)^{-1}}
\end{equation}

\begin{equation}
\boxed{K_{k+1}=\frac{P_ka_{k+1}^T}{a_{k+1}P_ka_{k+1}^T+I_N}}
\end{equation}

\end{document}

enter image description here

11

With tcolorbox help it's possible to include equation numbers in framed environments. It provides options ams equation, ams gather, ams align and corresponding starred versions. It's also possible to combine tcolorbox with empheq package.

\documentclass{report}

\usepackage{amsmath}
\usepackage[most]{tcolorbox}

\tcbset{colback=yellow!10!white, colframe=red!50!black, 
        highlight math style= {enhanced, %<-- needed for the ’remember’ options
            colframe=red,colback=red!10!white,boxsep=0pt}
        }

\begin{document}

\begin{equation}
\tcboxmath{K_{k+1}=P_ka_{k+1}^T(a_{k+1}P_ka_{k+1}^T+I_N)^{-1}}
\end{equation}

\begin{tcolorbox}[ams equation]
K_{k+1}=P_ka_{k+1}^T(a_{k+1}P_ka_{k+1}^T+I_N)^{-1}
\end{tcolorbox}

\begin{tcolorbox}[ams align]
\sum\limits_{n=1}^{\infty} \frac{1}{n} &= \infty.\\
\int x^2 ~\text{d}x &= \frac13 x^3 + c.
\end{tcolorbox}

\begin{tcolorbox}[ams gather]
\sum\limits_{n=1}^{\infty} \frac{1}{n} = \infty.\\
\int x^2 ~\text{d}x = \frac13 x^3 + c.
\end{tcolorbox}

\begin{align*}
\tcbhighmath[remember as=fx]{f(x)}
&= \int\limits_{1}^{x} \frac{1}{t^2}~dt
= \left[ -\frac{1}{t} \right]_{1}^{x}\\
&= -\frac{1}{x} + \frac{1}{1}\\
&=
\tcbhighmath[remember,overlay={%
\draw[blue,very thick,->] (fx.south) to[bend right] ([yshift=2mm]frame.west);}]
{1-\frac{1}{x}.}
\end{align*}

\end{document}

enter image description here

11

If you want a costumized box, you can use the empheq package:

\documentclass{article}

\usepackage{mathtools}
\usepackage[
  amsmath
]{empheq}
\usepackage{xcolor}

\definecolor{shadecolor}{cmyk}{0,0,0.45,0}
\definecolor{light-blue}{cmyk}{0.25,0,0,0}
\newsavebox{\mysaveboxM}
\newsavebox{\mysaveboxT}
\newcommand*\Garybox[2][A Nice Box]{%
  \sbox{\mysaveboxM}{#2}%
  \sbox{\mysaveboxT}{\fcolorbox{black}{light-blue}{#1}}%
  \sbox{\mysaveboxM}{%
    \parbox[b][\ht\mysaveboxM+0.5\ht\mysaveboxT+0.5\dp\mysaveboxT][b]{%
      \wd\mysaveboxM}{#2}%
  }%
  \sbox{\mysaveboxM}{%
    \fcolorbox{black}{shadecolor}{%
      \makebox[\linewidth-17.5em]{\usebox{\mysaveboxM}}%
    }%
  }%
  \usebox{\mysaveboxM}%
  \makebox[0pt][r]{%
    \makebox[\wd\mysaveboxM][c]{%
      \raisebox{\ht\mysaveboxM-0.5\ht\mysaveboxT
                +0.5\dp\mysaveboxT-0.5\fboxrule}{\usebox{\mysaveboxT}}%
    }%
  }%
}

\begin{document}

\begin{empheq}[box = {\Garybox[A Nice Box]}]{equation}
  K_{k+1}
  = P_{k}a_{k+1}^{T}\left(a_{k+1}P_{k}a_{k+1}^{T}+I_{N}\right)^{-1}
\end{empheq}

\end{document}

output

Note that my example is crudely stolen from pages 23--24 of the package manual.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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