1

How to box formulas such as

\begin{eqnarray*}
&&P(X_{n+1} = i_{n+1}\mid
X_{0}=i_{0}, X_{1}=i_{1},\ldots,X_{n-1}=i_{n-1},X_{n}=i_{n}) \\
&&=P(X_{n+1}=i_{n+1}\mid X_{n}=i_{n}).
\end{eqnarray*}

I use amsmath package

\begin{eqnarray*}
p(x) &= 3x^6 + 14x^5y + 590x^4y^2 + 19x^3y^3\\
&- 12x^2y^4 - 12xy^5 + 2y^6 - a^3b^3
\end{eqnarray*}

1 Answers1

2

Here are two versions: empheq and tcolorbox

\documentclass{article}
\usepackage{mathtools}
\usepackage{empheq}
\usepackage[most]{tcolorbox}
\begin{document}


%\begin{eqnarray*}
%&&P(X_{n+1} = i_{n+1}\mid
%X_{0}=i_{0}, X_{1}=i_{1},\ldots,X_{n-1}=i_{n-1},X_{n}=i_{n}) \\
%&&=P(X_{n+1}=i_{n+1}\mid X_{n}=i_{n}).
%\end{eqnarray*}

\begin{empheq}[box=\fbox]{align*}
   &P(X_{n+1} = i_{n+1}\mid X_{0}=i_{0}, X_{1}=i_{1},\dots,X_{n-1}=i_{n-1},X_{n}=i_{n}) \\
  ={}&P(X_{n+1}=i_{n+1}\mid X_{n}=i_{n})
\end{empheq}

\begin{tcolorbox}[ams align*,colback=white!40!yellow]
   &P(X_{n+1} = i_{n+1}\mid X_{0}=i_{0}, X_{1}=i_{1},\dots,X_{n-1}=i_{n-1},X_{n}=i_{n}) \\
  ={}&P(X_{n+1}=i_{n+1}\mid X_{n}=i_{n})
\end{tcolorbox}


\end{document}

enter image description here

  • 1
    ={}& in both cases; and \dots, not \ldots – egreg Dec 06 '15 at 10:40
  • Thanks everybody. Do I understand correctly that I should use mathtools instead of amsmath? Replacing eqnarray* by align* did not help when I use amsmath – user164118 Dec 06 '15 at 10:54
  • @user164118: mathtools makes some additions to amsmath –  Dec 06 '15 at 11:00
  • I found that \usepackage{amsmath} suffices \documentclass[a4paper,12pt]{article} \usepackage{amsmath,amsfonts} \usepackage{graphicx}

    \begin{document}

    \begin{eqnarray} \boxed{ \begin{aligned} \hbox{}&P(X_{n+1} = i_{n+1}\mid X_{0}=i_{0}, X_{1}=i_{1},\ldots,X_{n-1}=i_{n-1},X_{n}=i_{n}) \ \hbox{}&=P(X_{n+1}=i_{n+1}\mid X_{n}=i_{n}). \end{aligned} } \end{eqnarray}

    \end{document}

    – user164118 Dec 06 '15 at 12:54
  • @user164118: That's another possibility, of course. But you still use the outdated eqnarray stuff. –  Dec 06 '15 at 17:10
  • @ Christian Thanks again. I am very happy with your suggestion to use align rather than eqnarray. Indeed this gives a much nicer result. – user164118 Dec 07 '15 at 21:48