![如何在不使用 tikzlibrary 的情况下在乳胶中并排创建两个框](https://linux22.com/image/383396/%E5%A6%82%E4%BD%95%E5%9C%A8%E4%B8%8D%E4%BD%BF%E7%94%A8%20tikzlibrary%20%E7%9A%84%E6%83%85%E5%86%B5%E4%B8%8B%E5%9C%A8%E4%B9%B3%E8%83%B6%E4%B8%AD%E5%B9%B6%E6%8E%92%E5%88%9B%E5%BB%BA%E4%B8%A4%E4%B8%AA%E6%A1%86.png)
答案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}