Text FormattingBoxed and aligned Equations

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
hbaromega
Posts: 48
Joined: Mon Mar 07, 2011 8:21 pm

Boxed and aligned Equations

Post by hbaromega »

I want to box multiple equations using alignment. \boxed{} environment works
fine between \begin{equation} and \end{equation}. But if we do something like the following, I find errors.

Code: Select all

\begin{align}
\boxed{
x&=y+z\nonumber\\
y&=p^2+q^2\nonumber\\
z&=2pq
}
\end{align}
Thanks.
Last edited by Stefan Kottwitz on Wed Apr 04, 2012 4:42 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Boxed and aligned Equations

Post by Stefan Kottwitz »

It works with the empheq package:

Code: Select all

\documentclass{article}
\usepackage{empheq}
\begin{document}
\begin{empheq}[box=\fbox]{align}
  x &= y+z\nonumber\\
  y &= p^2+q^2\nonumber\\
  z &= 2pq
\end{empheq}
\end{document}
Stefan
LaTeX.org admin
hbaromega
Posts: 48
Joined: Mon Mar 07, 2011 8:21 pm

Re: Boxed and aligned Equations

Post by hbaromega »

Thanks a lot, Stefan. It's working fine. I have two more questions related to this:

1) Can I set box in such a way that it includes equation numbers also?

2) Can I define a length and width for the box?
User avatar
shadgrind
Posts: 140
Joined: Thu Jul 16, 2009 12:39 am

Boxed and aligned Equations

Post by shadgrind »

For boxing a group of aligned equations along with their labels, I use TikZ:

Code: Select all

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\newcommand{\boxalign}[2][0.97\textwidth]{
 \par\noindent\tikzstyle{mybox} = [draw=black,inner sep=6pt]
 \begin{center}\begin{tikzpicture}
  \node [mybox] (box){%
   \begin{minipage}{#1}{\vspace{-5mm}#2}\end{minipage}
  };
 \end{tikzpicture}\end{center}
}
\begin{document}
\boxalign{\begin{align}
  x &= y+z\\
  y &= p^2+q^2\\
  z &= 2pq
\end{align}}

\boxalign[0.6\textwidth]{\begin{align}
  x &= y+z\\
  y &= p^2+q^2\\
  z &= 2pq
\end{align}}
\end{document}
Notice how the width of the second box was changed. There are lots of ways to customize the box with TikZ.
System: TeX Live 2012, Fedora 18 x86_64, GNU Emacs 24.2
Post Reply