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

How can I use \boxed{} in align environment?

1,506 views
Skip to first unread message

Merciadri Luca

unread,
Jun 27, 2010, 10:46:13 AM6/27/10
to
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

If I have
==
\begin{align}
a&=b,\\
c&=d
\end{align}
==
in some part of my document, how can I box `a=b'? Boxing `b' only is
evident:

==
\begin{align}
a&=\boxed{b},\\
c&=d
\end{align}
==

but

==
\begin{align}
\boxed{a&=b},\\
c&=d
\end{align}
==
naturally produces an error (this is comprehensible). Any idea?

Thanks.
- --
Merciadri Luca
See http://www.student.montefiore.ulg.ac.be/~merciadri/
- --

Repetitio Mater Memoriae.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/>

iEYEARECAAYFAkwnZDUACgkQM0LLzLt8MhxXDACfQ1L78AYbFGFoZYiK4U52W1Ki
lRkAn0f5iFbBYGtkeCgaJRTEvJfx+blR
=bZiM
-----END PGP SIGNATURE-----

Lars Madsen

unread,
Jun 27, 2010, 7:05:05 PM6/27/10
to

You cannot as the box hides the &, so you have to resort to cheating

Typeset the box, and pull it backwards, or use the provided macro


\documentclass{memoir}
\usepackage{amsmath,calc}
\makeatletter
\newcommand\Aboxed[1]{
\@Aboxed#1\ENDDNE}
\def\@Aboxed#1&#2\ENDDNE{%
&
\settowidth\@tempdima{$\displaystyle#1{}$}
\setlength\@tempdima{\@tempdima+\fboxsep+\fboxrule}
\kern-\@tempdima
\boxed{#1#2}
}
\makeatother

\begin{document}
\begin{align*}
\Aboxed{A&=B}\\
A&=B\\
&=C
\end{align*}
\end{document}

Merciadri Luca

unread,
Jun 28, 2010, 5:38:21 AM6/28/10
to
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Lars Madsen <dal...@imf.au.dk> writes:

Nice. It works perfectly. Do you mind if I put this in some TUGboat
article of mine?

Thanks.
- --
Merciadri Luca
See http://www.student.montefiore.ulg.ac.be/~merciadri/
- --

The only stupid question is the one that is not asked.


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/>

iEYEARECAAYFAkwobY0ACgkQM0LLzLt8Mhz3agCePG56RlsX2aHC5YZ/73wGSl7k
kYAAn3WV0Xz4Wdf5dteeZ/60x4bxgbZh
=o38Q
-----END PGP SIGNATURE-----

Lars Madsen

unread,
Jun 28, 2010, 6:10:57 AM6/28/10
to

no problem, could you send me a copy of the article offlist (I might
have some comments for it)

I might add a version of \Aboxed to mathtools

--

/daleif (remove RTFSIGNATURE from email address)

LaTeX FAQ: http://www.tex.ac.uk/faq
LaTeX book: http://www.imf.au.dk/system/latex/bog/ (in Danish)
Remember to post minimal examples, see URL below
http://www.tex.ac.uk/cgi-bin/texfaq2html?label=minxampl
http://www.minimalbeispiel.de/mini-en.html

Merciadri Luca

unread,
Jun 28, 2010, 6:23:29 AM6/28/10
to
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Lars Madsen <dal...@RTFMSIGNATUREimf.au.dk> writes:

Sure.

> I might add a version of \Aboxed to mathtools

Might be a good idea. :)

The secret of life is not to do what you like, but to like what you do.


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/>

iEYEARECAAYFAkwoeCEACgkQM0LLzLt8Mhye+QCdGntJ9kfaCyOYH37yGytt0dbl
z9gAoJK+gHN4gL+YSsuWK597o94ulC8D
=q8Dl
-----END PGP SIGNATURE-----

0 new messages