1

I want to nicely put equations and equations arrays inside a box or a frame. I also like to align objects in align environment like in the eqnarray environment [r|c|l], see example below.

Working example:

\documentclass{article}[A4]
\usepackage{amsmath,amssymb}

\newenvironment{bbox}
{\par\smallskip\centering\begin{lrbox}{0}%
\begin{minipage}[c]{0.99\textwidth}}
{\end{minipage}\end{lrbox}%
\framebox[0.99\textwidth]{\usebox{0}}%
\par\medskip
\ignorespacesafterend}

\begin{document}

\title{Box test}

I want to box equations. For a simple equation:
\begin{equation} \label{1}
\boxed{ 1 + 2 = \pi - 0.14 \quad  \implies \quad \pi \in \mathbb{Q}  }
\end{equation}
Eqnarray:
\begin{eqnarray}
1 + 2 = \pi - 0.14  & \implies & \pi \in \mathbb{Q} 
\end{eqnarray}
Align:
\begin{align}
1 + 2 = \pi - 0.14  & \implies & \pi \in \mathbb{Q} 
\end{align}
I want the \texttt{align} to be aligned like \texttt{eqnarray}, how to do that?

For align and eqnarray the \texttt{boxed} won't work,
\begin{verbatim}
\begin{align}
\boxed{ 1 + 2 = \pi - 0.14  & \implies & \pi \in \mathbb{Q} }
\end{align}
\end{verbatim}
Using the environment ``bbox'' it seems to work but has some space in the top so it looks a little bit ugly:
\begin{bbox}
\begin{align}
 1 + 2 = \pi - 0.14  & \implies & \pi \in \mathbb{Q} 
\end{align}
\end{bbox}
I want it to look like equation \eqref{1}

How to do that?

The result: The result of this LaTeX code

Edit: What about multiline equations?

Multiline:
\begin{align}
\Aboxed{ 1 + 2 = \pi - 0.14   \implies & \pi \in \mathbb{Q}  \\
3 \ne \pi \implies & \pi \in \mathbb{R} } 
\end{align}

See also: Create environment out of eqnarray with frame box

4
  • 1
    Unrelated: \documentclass{article}[A4] where do you have this syntax from? Because it is incorrect and where ever you have it from ought to be updated.
    – daleif
    Apr 4 at 12:21
  • 1
    Do not use eqnarray , the spacing at the alignment point is not correct. To have a box around an equation in an align environment, you have the \Aboxed command defined by mathtools.
    – Bernard
    Apr 4 at 12:44
  • Off-topic: You've transferred the alignment syntax from eqnarray to align. That's a mistake. Don't write 1 + 2 = \pi - 0.14 & \implies & \pi \in \mathbb{Q}. Instead, write 1 + 2 = \pi - 0.14 & \implies \pi \in \mathbb{Q}. Can you spot the difference?
    – Mico
    Apr 4 at 13:16
  • Yes, the extra & which aligns [rcl]. Apr 5 at 6:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.