带数字的方框方程

带数字的方框方程

我的最低工作示例:

\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}

结果:

在此处输入图片描述

现在我该如何给这个方程编号?

答案1

只需将center环境替换为equation。我认为使用更大的括号会看起来更好一些。

编辑:将其作为分数读起来可能更容易 - 除了它似乎是一个关于矩阵的方程......

\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}

在此处输入图片描述

答案2

tcolorboxhelp 可以在框架环境中包含方程编号。它提供选项ams equationams gatherams align相应的带星号版本。它还可以tcolorboxempheq包结合使用。

\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}

在此处输入图片描述

答案3

如果你想要一个定制的盒子,你可以使用empheq包裹:

\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}

输出

请注意,我的例子粗略地抄袭自包装手册第 23-24 页

答案4

给出的答案很棒,这里是另一个解决方案breqn

输出

\documentclass{report}
\usepackage{breqn}

\begin{document}
    \begin{dmath}[frame]
        K_{k+1}=P_ka_{k+1}^T(a_{k+1}P_ka_{k+1}^T+I_N)^{-1}
    \end{dmath}
\end{document}

您还可以使用以下方法调整边框粗细和间距:

\begin{dmath}[frame={<amount>pt},framesep={<amount>pt}] ... \end{dmath}

相关内容