# how to box formulas inside eqnarray* [duplicate]

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


## marked as duplicate by Werner math-mode StackExchange.ready(function() { if (StackExchange.options.isMobile) return; $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() { var$hover = $(this).addClass('hover-bound'),$msg = $hover.siblings('.dupe-hammer-message');$hover.hover( function() { $hover.showInfoMessage('', { messageElement:$msg.clone().show(), transient: false, position: { my: 'bottom left', at: 'top center', offsetTop: -7 }, dismissable: false, relativeToBody: true }); }, function() { StackExchange.helpers.removeMessages(); } ); }); }); Dec 6 '15 at 19:11

• eqnarray is 'outdated' -- rather use align or alignat (or the starred variants) – user31729 Dec 6 '15 at 10:32
• – Henri Menke Dec 6 '15 at 10:33

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}


• ={}& in both cases; and \dots, not \ldots – egreg Dec 6 '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 6 '15 at 10:54
• @user164118: mathtools makes some additions to amsmath – user31729 Dec 6 '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 6 '15 at 12:54
• @user164118: That's another possibility, of course. But you still use the outdated eqnarray stuff. – user31729 Dec 6 '15 at 17:10