答案1
您可以使用tabular
,并借助hhline
:
\documentclass{article}
\usepackage{hhline}
\usepackage[table]{xcolor}
\begin{document}
\begin{center} % or \[
\arrayrulecolor{red!50!black}
\setlength{\arrayrulewidth}{1pt}
\renewcommand{\arraystretch}{1.2}
\begin{tabular}{|c|c|c|}
\multicolumn{1}{c}{moments} &
\multicolumn{1}{c}{\qquad} &
\multicolumn{1}{c}{canonical} \\
\hhline{|-|~|-|}
$\Sigma=\Omega^{-1}$ && $\Omega=\Sigma^{-1}$ \\
$\mu=\Omega^{-1}\xi$ && $\xi=\Sigma^{-1}\mu$ \\
\hhline{|-|~|-|}
\end{tabular}
\arrayrulecolor{black} % because `\arrayrulecolor` is global
\end{center} % or \]
\end{document}
答案2
您可以使用包装\fcolorbox
中的xcolor
和来tabular
将它们并排对齐。
\documentclass{article}
\usepackage{amsmath}
\usepackage{xcolor}
\begin{document}
\setlength\fboxrule{1pt}
\begin{tabular}{cc}
moments & canonical \\
\fcolorbox{red!50!black}{white}{$
\begin{aligned}
\Sigma &= \Omega^{-1} \\
\mu &= \Omega^{-1} \xi
\end{aligned}
$} &
\fcolorbox{red!50!black}{white}{$
\begin{aligned}
\Omega &= \Sigma^{-1} \\
\xi &= \Sigma^{-1} \mu
\end{aligned}
$} \\
\end{tabular}
\end{document}
另一种选择是将 MetaPost 与 LuaTeX 一起使用。
\documentclass{article}
\usepackage{amsmath}
\usepackage{luamplib}
\mplibtextextlabel{enable}
\everymplib{
input rboxes;
beginfig(0);
}
\everyendmplib{endfig;}
\begin{document}
\begin{mplibcode}
boxit.moments(btex
$
\begin{aligned}
\Sigma &= \Omega^{-1} \\
\mu &= \Omega^{-1} \xi
\end{aligned}
$
etex);
moments.c = (-1cm,0);
boxit.canonical(btex
$
\begin{aligned}
\Omega &= \Sigma^{-1} \\
\xi &= \Sigma^{-1} \mu
\end{aligned}
$
etex);
canonical.c = (1cm,0);
draw bpath moments withpen pencircle scaled 1pt withcolor .5[red,black];
draw bpath canonical withpen pencircle scaled 1pt withcolor .5[red,black];
drawunboxed(moments, canonical);
label.top("moments", moments.n);
label.top("canonical", canonical.n);
\end{mplibcode}
\end{document}