Featured Book

LaTeX Beginners Guide

Who is online

In total there are 2 users online :: 0 registered, 0 hidden and 2 guests (based on users active over the past 5 minutes)
Most users ever online was 1327 on Tue Nov 05, 2013 7:11 pm

Users browsing this forum: No registered users and 2 guests

Partner Sites

TeXwelt - Fragen und Antworten goLaTeX
TeXblog
TeXnicCenter
TeXample

box around just one equation inside align

Add tags Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).

box around just one equation inside align

Postby kwicky on Sun Mar 21st, 2010

Hi,
I am using "\begin{align}..." to align two equations. I would like to put a box around the second equation only. However, "\boxed{...}" does not seem to work if the alignment character "&" is inside the "{}".
Any advice?

Thanks a lot,
Kai
kwicky
 
Posts: 2
Joined: Sun Mar 21st, 2010

Re: box around just one equation inside align

Postby daleif on Sun Mar 21st, 2010

As you have seen you cannot directly, but we can cheat a little (in the example memoir is not important, it is jut my standard class in emacs)

Code: Select all  •  Open in writeLaTeX
\documentclass{memoir}
\usepackage{calc,amsmath
}
\newlength\dlf
\newcommand\alignedbox[2]{
  % #1 = before alignment
  % #2 = after alignment
  &
  \begingroup
  \settowidth\dlf{$\displaystyle #1$}
  \addtolength\dlf{\fboxsep+\fboxrule}
  \hspace{-\dlf}
  \boxed{#1 #2}
  \endgroup
}
\begin{document}

\begin{align*}
  f(x) &= a \\
  \alignedbox{g(x)}{=5}
\end{align*}
\end{document
}


It is the same kind of trick \MoveEqLeft from mathtools make use of
daleif
 
Posts: 199
Joined: Wed Nov 19th, 2008

Re: box around just one equation inside align

Postby kwicky on Mon Mar 22nd, 2010

Daleif,

Brilliant, works perfectly!
Thanks a lot,

Kai
kwicky
 
Posts: 2
Joined: Sun Mar 21st, 2010


Return to Math & Science

Who is online

Users browsing this forum: No registered users and 2 guests