2

I want to put a box around a equation spreading multiple lines. Minimum working example:

 \documentclass{article}
 \usepackage[utf8]{inputenc}
 %\usepackage{amsmath}
 \usepackage{comment}
 \usepackage{mathtools, cuted}
 %\usepackage{natbib}
 \usepackage{amssymb}
 \usepackage{breqn}
 %\usepackage{amsthm}
 \usepackage{hyperref}
 %\bibliographystyle{plain}
 %\newtheorem{thm}{Theorem}[section]
 %\newtheorem{lem}[thm]{Lemma}
 %\newtheorem{cor}[thm]{Corollary}
 \newtheorem{rmk}{Remark}
 %\newtheorem{def}[rmk]{Definition}
 %\newtheorem*{proof}{Proof}
 \usepackage{amsmath}
 \usepackage{mathtools}
 \usepackage{enumitem}

  %\usepackage[dvips]{epsfig}    % or this line, depending on which
                           % you prefer.
  \makeatletter
  \DeclareRobustCommand{\qed}{%
  \ifmmode % if math mode, assume display: omit penalty etc.
  \else \leavevmode\unskip\penalty9999 \hbox{}\nobreak\hfill
  \fi
  \quad\hbox{\qedsymbol}}
  \newcommand{\openbox}{\leavevmode
  \hbox to.77778em{%
  \hfil\vrule
  \vbox to.675em{\hrule width.6em\vfil\hrule}%
  \vrule\hfil}}
  \newcommand{\qedsymbol}{\openbox}
  \newenvironment{proof}[1][\proofname]{\par
  \normalfont
  \topsep6\p@\@plus6\p@ \trivlist
  \item[\hskip\labelsep\itshape
  #1.]\ignorespaces
   }{%
  \qed\endtrivlist
  }
   \newcommand{\proofname}{Proof}
   \makeatother

   \begin{document}
   \begin{align}
    &\frac{1}{\min_i \sum_j e^{c(i,j)}p(j|i)}\sum_{i,j=1}^s                                      e^{c(i,j)}p(j|i)x_i y_j \left[c(i,j) + \ln p(j|i)-\ln \sqrt{\pi_i} - 
   \ln\phi^{k(i)}(i) -\ln\left(\sum_{l=1}^s \phi^{k(i)}(l)\pi_la_{lj}         \right)+\ln \sqrt{\pi_j}+ \right. \nonumber \\
   & \left. \ln\left(\sum_{m=1}^s{\phi^{k(i)}(m)}^2\pi_m\right)\right]        \label{first}.
   \end{align}
   \end{document} 
6
5

Something like this?

enter image description here

 \documentclass{article}

\usepackage[margin=0.5in]{geometry}
\usepackage{empheq}


   \begin{document}
   \begin{empheq}[box=\fbox]{align}
    &\frac{1}{\min_i \sum_j e^{c(i,j)}p(j|i)}\sum_{i,j=1}^s                                      e^{c(i,j)}p(j|i)x_i y_j \left[c(i,j) + \ln p(j|i)-\ln \sqrt{\pi_i} - 
   \ln\phi^{k(i)}(i) -\ln\left(\sum_{l=1}^s \phi^{k(i)}(l)\pi_la_{lj}         \right)+\ln \sqrt{\pi_j}+ \right. \nonumber \\
   & \left. \ln\left(\sum_{m=1}^s{\phi^{k(i)}(m)}^2\pi_m\right)\right]        \label{first}.
   \end{empheq}
   \end{document}
1
  • For anyone interested: this works with multline* or whatever, in place of align – leo monsaingeon Jan 11 at 21:40

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.