Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Box around multiple equations in align environment

1,739 views
Skip to first unread message

Jeff Krimmel

unread,
Sep 7, 2004, 1:17:57 PM9/7/04
to
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Greetings all,

I am curious if anyone could tell me how to place a box around a series
of equations created in the align environment (in LaTeX). I would prefer
for the box to act like the \boxed{} tool in that it should close
tightly around the equations and leave the equation numbers outside and
right-justified as usual.

Any suggestions?

Thanks for your time,

Jeff

- --
Add an underscore between 'd' and 's' and remove the first three
letters of the alphabet for email.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFBPe1FlRbyBxB9qBwRAo6lAKCQ7hbZPylU4vwPkGrCSk05AT2CAwCeLuDH
TRxe+oSBFBTgpdom3BC6fQA=
=psMH
-----END PGP SIGNATURE-----

Lars Madsen

unread,
Sep 7, 2004, 1:39:48 PM9/7/04
to
On Tue, 07 Sep 2004 10:17:57 -0700, Jeff Krimmel
<madscien...@hotmail.com> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Greetings all,
>
> I am curious if anyone could tell me how to place a box around a series
> of equations created in the align environment (in LaTeX). I would prefer
> for the box to act like the \boxed{} tool in that it should close
> tightly around the equations and leave the equation numbers outside and
> right-justified as usual.
>
> Any suggestions?
>
> Thanks for your time,
>
> Jeff

empheq (get it from CTAN) is what you want, it has been constructed
to solve a problem like this

--
/daleif (remove RTFSIGNATURE from email address)

LaTeX FAQ: http://www.tex.ac.uk/faq
AMSMATH Intro: http://www.ams.org/tex/amslatex.html
LaTeX Intro: http://people.ee.ethz.ch/~oetiker/lshort/lshort.pdf
Graphics Intro: http://www.ctan.org/tex-archive/info/epslatex.pdf
Superb Class:
http://www.ctan.org/tex-archive/help/Catalogue/entries/memoir.html
Remember to post minimal working examples.

Jeff Krimmel

unread,
Sep 7, 2004, 3:17:18 PM9/7/04
to
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Lars Madsen wrote:

| empheq (get it from CTAN) is what you want, it has been constructed
| to solve a problem like this

Thanks for the suggestion. I downloaded and installed the package
(correctly, I hope). Here is my small test file:

===============================
\documentclass{article}
\usepackage{empheq}
\begin{document}

\begin{empheq}[boxtype=\fbox]
\begin{align}
1 + 1 &= 2\\
2 + 2 &= 4\\
4 + 4 &= 8
\end{align}
\end{empheq}

\end{document}
===============================

Here is the output:

===============================
! Missing \endcsname inserted.
<to be read again>
~ \def
l.6 \begin
~ {align}
! Extra \endcsname.
\reserved@a ...ine }\csname \endcsname \endcsname

l.6 \begin
~ {align}

! Missing \endcsname inserted.
<to be read again>
~ \KV@toks@
l.6 \begin
~ {align}
! Argument of \KV@@sp@b has an extra }.
<inserted text>
~ \par
l.6 \begin
~ {align}
Runaway argument?
! Paragraph ended before \KV@@sp@b was complete.
<to be read again>
~ \par
l.6 \begin
~ {align}
! Argument of \KV@@sp@b has an extra }.
<inserted text>
~ \par
l.6 \begin
~ {align}
Runaway argument?
\endcsname
! Paragraph ended before \KV@@sp@b was complete.
<to be read again>
~ \par
l.6 \begin
~ {align}
! Missing \endcsname inserted.
<to be read again>
~ \par
l.6 \begin
~ {align}
)
! Incomplete \iffalse; all text was ignored after line 6.
<inserted text>
~ \fi
<*> \nonstopmode\input test.tex

! Emergency stop.
<*> \nonstopmode\input test.tex

No pages of output.
===============================

What am I doing wrong?

Thanks,

Jeff

- --
Add an underscore between 'd' and 's' and remove the first three
letters of the alphabet for email.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFBPgk+lRbyBxB9qBwRAlwmAJ4667lwvzDUBQzIhj4MLPXISQRwJgCeORXF
BNcjk2vWlI7lBMUY46Pmq28=
=tmuq
-----END PGP SIGNATURE-----

Morten Høgholm

unread,
Sep 7, 2004, 3:23:16 PM9/7/04
to
On Tue, 07 Sep 2004 12:17:18 -0700, Jeff Krimmel
<madscien...@hotmail.com> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Lars Madsen wrote:
>
> | empheq (get it from CTAN) is what you want, it has been constructed
> | to solve a problem like this
>
> Thanks for the suggestion. I downloaded and installed the package
> (correctly, I hope). Here is my small test file:
>
> ===============================
> \documentclass{article}
> \usepackage{empheq}
> \begin{document}
>
> \begin{empheq}[boxtype=\fbox]
> \begin{align}
> 1 + 1 &= 2\\
> 2 + 2 &= 4\\
> 4 + 4 &= 8
> \end{align}
> \end{empheq}
>
> \end{document}

I already answered Jeff in private mail. The answer (in case anyone else
would like to know) is to upgrade to the latest release.
--
Morten Høgholm
I haven't got a smelly address.
UK-TUG FAQ: <URL:http://www.tex.ac.uk/cgi-bin/texfaq2html>

Jeff Krimmel

unread,
Sep 7, 2004, 3:35:07 PM9/7/04
to
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Morten Høgholm wrote:
| On Tue, 07 Sep 2004 12:17:18 -0700, Jeff Krimmel
| <madscien...@hotmail.com> wrote:
|
|> -----BEGIN PGP SIGNED MESSAGE-----
|> Hash: SHA1
|>
|> Lars Madsen wrote:
|>
|> | empheq (get it from CTAN) is what you want, it has been constructed
|> | to solve a problem like this
|>
|> Thanks for the suggestion. I downloaded and installed the package
|> (correctly, I hope). Here is my small test file:
|>
|> ===============================
|> \documentclass{article}
|> \usepackage{empheq}
|> \begin{document}
|>
|> \begin{empheq}[boxtype=\fbox]
|> \begin{align}
|> 1 + 1 &= 2\\
|> 2 + 2 &= 4\\
|> 4 + 4 &= 8
|> \end{align}
|> \end{empheq}
|>
|> \end{document}
|
|
| I already answered Jeff in private mail. The answer (in case anyone
| else would like to know) is to upgrade to the latest release.

Yes, that ended up working _beautifully_. I already had the latest
release, but I was (stupidly) using documentation I found on the web as
opposed to the documentation that came bundled with the package. The
syntax that works is

\begin{empheq}[box=\fbox]{align}


1 + 1 &= 2\\
2 + 2 &= 4\\
4 + 4 &= 8

\end{empheq}

Thanks a bunch to both Lars and Morten for the help!

Jeff

- --
Add an underscore between 'd' and 's' and remove the first three
letters of the alphabet for email.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFBPg1rlRbyBxB9qBwRAj3HAJ47nERXD3th5oIqpMbVqrX8SwIorACbB9RP
F+vyAKe/xHnW9qbqBmjkFds=
=jfIz
-----END PGP SIGNATURE-----

"Žarko F. Čučej"

unread,
Sep 8, 2004, 2:58:11 PM9/8/04
to
Lars Madsen wrote:
> On Tue, 07 Sep 2004 10:17:57 -0700, Jeff Krimmel
> <madscien...@hotmail.com> wrote:
>
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Greetings all,
>>
>> I am curious if anyone could tell me how to place a box around a series
>> of equations created in the align environment (in LaTeX). I would prefer
>> for the box to act like the \boxed{} tool in that it should close
>> tightly around the equations and leave the equation numbers outside and
>> right-justified as usual.
>>
>> Any suggestions?
>>
>> Thanks for your time,
>>
>> Jeff
>
>
> empheq (get it from CTAN) is what you want, it has been constructed
> to solve a problem like this
>

Dear all,
I like to put a frame around equations created with flalign environment.
Since this is not supported by empheq, I do the following:

\documentclass{article}
\usepackage{framed,empheq}

\begin{document}

there is some text there is some text there is some text there is
some text there is some text there is some text there is some text
\begin{framed}
\begin{flalign}
\text{Fourier transform} &&
X(\omega) & = \int_{-\infty}^{\infty}x(t)e^{j\omega t} dt & \\
\text{Inverse Fourier transform} &&
x(t) & = \frac{1}{2\pi}\int_{-\infty}^{\infty}X(\omega)e^{j\omega
t} d\omega &
\end{flalign}
\end{framed}
in there the text is continued

\end{document}
Result is almost satisfactory except that text after frame is indented.
(this can solve by use \noindent after frame, but this is quite annoying).

Is there a way to use just empheq functionality to get the same frame
(or shadow box) around equations (frame should include equations numbering)?

Regards, Zarko

Morten Høgholm

unread,
Sep 8, 2004, 4:01:13 PM9/8/04
to
On Wed, 08 Sep 2004 20:58:11 +0200, Žarko F. Čučej <zarko...@uni-mb.si>
wrote:


> I like to put a frame around equations created with flalign environment.
> Since this is not supported by empheq, I do the following:

flalign *is* supported by empheq - at least that's what I thought until I
tried it. Apparently I have screwed up somewhere in my source code, so
I'll just fix that. Quite embarrassing!

> Is there a way to use just empheq functionality to get the same frame
> (or shadow box) around equations (frame should include equations
> numbering)?

Well empheq will only put the equation numbers on the outside - that's the
whole point of it :-) What you want to do can be done relatively easy with
lrbox as shown here:

\documentclass{article}
\usepackage{fancybox,calc,amsmath}

\newsavebox\mysavebox
% Because it looks better.
\newcommand*\myshadowbox[1]{\shadowbox{\hspace{1em}#1\hspace{1em}}}
\newenvironment{eqshadow}
{%
\begin{lrbox}{\mysavebox}%
\begin{minipage}{\linewidth-\widthof{\myshadowbox{}}}
}
{%
\end{minipage}%
\end{lrbox}%
\[
\myshadowbox{\usebox\mysavebox}
\]
\ignorespacesafterend
}

\begin{document}

Some text
\begin{eqshadow}


\begin{flalign}
\text{Fourier transform} &&
X(\omega) & = \int_{-\infty}^{\infty}x(t)e^{j\omega t} dt & \\
\text{Inverse Fourier transform} &&
x(t) & = \frac{1}{2\pi}\int_{-\infty}^{\infty}X(\omega)e^{j\omega t}
d\omega &
\end{flalign}

\end{eqshadow}
Some unindented text
\end{document}

"Žarko F. Čučej"

unread,
Sep 8, 2004, 4:49:30 PM9/8/04
to
Morten Høgholm wrote:

> On Wed, 08 Sep 2004 20:58:11 +0200, Žarko F. Čučej

> <zarko...@uni-mb.si> wrote:
>
>
>> I like to put a frame around equations created with flalign
>> environment. Since this is not supported by empheq, I do the following:
>
>
> flalign *is* supported by empheq - at least that's what I thought until
> I tried it. Apparently I have screwed up somewhere in my source code,
> so I'll just fix that. Quite embarrassing!

oh, don't wory. simiar thing hapend to me very often ...

thanks for above code. its give beter positioning of frame and euations
inside as do my example! Please, can you tell me, what to do to have
just simple frame around equations?

best reagards, Zarko

Morten Høgholm

unread,
Sep 8, 2004, 4:52:16 PM9/8/04
to
On Wed, 08 Sep 2004 22:49:30 +0200, Žarko F. Čučej <zarko...@uni-mb.si>
wrote:


> thanks for above code. its give beter positioning of frame and euations
> inside as do my example! Please, can you tell me, what to do to have
> just simple frame around equations?

Just substitute \myshadowbox (all instances!) with your preferred type of
box.

"Žarko F. Čučej"

unread,
Sep 8, 2004, 5:01:55 PM9/8/04
to
Morten Høgholm wrote:

> On Wed, 08 Sep 2004 22:49:30 +0200, Žarko F. Čučej

> <zarko...@uni-mb.si> wrote:
>
>
>> thanks for above code. its give beter positioning of frame and
>> euations inside as do my example! Please, can you tell me, what to do
>> to have just simple frame around equations?
>
>
> Just substitute \myshadowbox (all instances!) with your preferred type
> of box.

oh, yes! i just discover this ... now I'm quite embarrassed ...

thank you very much! regards Zarko

"Žarko F. Čučej"

unread,
Sep 8, 2004, 5:34:38 PM9/8/04
to
Morten Høgholm wrote:

> On Wed, 08 Sep 2004 22:49:30 +0200, Žarko F. Čučej

> <zarko...@uni-mb.si> wrote:
>
>
>> thanks for above code. its give beter positioning of frame and
>> euations inside as do my example! Please, can you tell me, what to do
>> to have just simple frame around equations?
>
>
> Just substitute \myshadowbox (all instances!) with your preferred type
> of box.

Dear Morten Høgholm,
the vertival position of math stuf inside frame is look like to be
dependent from selected math environment. For example, in case of use
the flalign the vertical place between last equation and bottom border
of the frame is smaller then it is the top distance. But in case of use
of the equation, it is almost equal:

\documentclass{article}
\usepackage{calc,amsmath}

\newsavebox\mysavebox % Because it looks better...
\newcommand*\myshadowbox[1]{\framebox{\hspace{1em}#1\hspace{1ex}}}
\newenvironment{eqshadow}
{\begin{lrbox}{\mysavebox}%
\begin{minipage}{\linewidth-\widthof{\framebox{}}}


}{%
\end{minipage}%
\end{lrbox}%
\[
\myshadowbox{\usebox\mysavebox}
\]
\ignorespacesafterend
}

\begin{document}
Some text some text some text some text some text some text some
text some text some text some text some text some text some text


\begin{eqshadow}
\begin{flalign}
\text{Fourier transform} &&
X(\omega) & = \int_{-\infty}^{\infty}x(t)e^{j\omega t} dt & \\
\text{Inverse Fourier transform} &&
x(t) & = \frac{1}{2\pi}\int_{-\infty}^{\infty}X(\omega)e^{j\omega
t} d\omega &
\end{flalign}
\end{eqshadow}

Some unindented text some unindented text some unindented text some
unindented text some unindented text some unindented text
\begin{eqshadow}
\begin{equation}
X(\omega) = \int_{-\infty}^{\infty}x(t)e^{j\omega t} dt
\end{equation}
\end{eqshadow}

Some indented text
\end{document}

is there some "smart" mechanishm for centering of math stuff independly
from math environment?

regards, Zarko

Morten Høgholm

unread,
Sep 9, 2004, 2:32:44 AM9/9/04
to
On Wed, 08 Sep 2004 23:34:38 +0200, Žarko F. Čučej <zarko...@uni-mb.si>
wrote:

> the vertival position of math stuf inside frame is look like to be

> dependent from selected math environment. For example, in case of use
> the flalign the vertical place between last equation and bottom border
> of the frame is smaller then it is the top distance. But in case of use
> of the equation, it is almost equal:
>
> \documentclass{article}
> \usepackage{calc,amsmath}
>
> \newsavebox\mysavebox % Because it looks better...
> \newcommand*\myshadowbox[1]{\framebox{\hspace{1em}#1\hspace{1ex}}}
> \newenvironment{eqshadow}
> {\begin{lrbox}{\mysavebox}%
> \begin{minipage}{\linewidth-\widthof{\framebox{}}}

Try adding a \setlength\abovedisplayskip{0pt}% here

> is there some "smart" mechanishm for centering of math stuff independly
> from math environment?

If you mean center vertically then not really. It depends on the height of
the first line of the equation so in order to get the positioning correct
one must measure that. That's one of the uglier parts of the empheq
internals... Look at it if you dare!

"Žarko F. Čučej"

unread,
Sep 11, 2004, 4:53:47 AM9/11/04
to
Dear Morten Høgholm,
thank you for your help. With it I'm able now to improve the look of my
document (textbook).

Morten Høgholm wrote:
> On Wed, 08 Sep 2004 23:34:38 +0200, Žarko F. Čučej

> <zarko...@uni-mb.si> wrote:
>
>> the vertival position of math stuf inside frame is look like to be
>> dependent from selected math environment. For example, in case of use
>> the flalign the vertical place between last equation and bottom
>> border of the frame is smaller then it is the top distance. But in
>> case of use of the equation, it is almost equal:
>>
>> \documentclass{article}
>> \usepackage{calc,amsmath}
>>
>> \newsavebox\mysavebox % Because it looks better...
>> \newcommand*\myshadowbox[1]{\framebox{\hspace{1em}#1\hspace{1ex}}}
>> \newenvironment{eqshadow}
>> {\begin{lrbox}{\mysavebox}%
>> \begin{minipage}{\linewidth-\widthof{\framebox{}}}
>
> Try adding a \setlength\abovedisplayskip{0pt}% here
>

This work satisfactory in all my tested cases!


>> is there some "smart" mechanishm for centering of math stuff
>> independly from math environment?
>
> If you mean center vertically then not really. It depends on the height
> of the first line of the equation so in order to get the positioning
> correct one must measure that.

Yes, I can imaginage this. Unfortunately this is mostly beyond to my
(La)TeX skils ...

> That's one of the uglier parts of the
> empheq internals... Look at it if you dare!

as soon as I will have some more time. Now I'm in rush to finish my text
book ...

Best regards, Zarko

0 new messages