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

1 Answer 1

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}
2
  • For anyone interested: this works with multline* or whatever, in place of align Jan 11, 2021 at 21:40
  • It is not working with multline for me May 27, 2022 at 17:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .