6

enter image description here

I want to write down this code in latex. I write down a code for this but it not properly displayed as per the picture.

My code

\indent\fbox{$\Sigma=\Omega^{-1}$  \\ $\mu=\Omega^{-1}\xi$}

What should be the proper code? I don't have \usetikzlibrary{positioning} library in Texstudio. Without using it can I create it?

3

You can use a tabular, with a little help from 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}

enter image description here

7

You can use \fcolorbox from the xcolor package and a tabular to align them side by side.

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

enter image description here


Another alternative is to use MetaPost with 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}

enter image description here

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.