Math & Sciencemultiple boxed equations

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
episanty
Posts: 26
Joined: Tue Mar 24, 2009 2:24 am

multiple boxed equations

Post by episanty »

Hi all,

I was looking for a way to produce an align of four equations in two rows and two columns, all of it boxed (as a summary of previous results). However, the standard \boxed, \gather approach doesn't work for me; it needs to be aligned. For some reason, I was unable to get \begin{align} to work properly: either it jumbled my equations, or it spread them wide throughout the page (i.e., too much horizontal space). Further, the box produced by empheq was too thin around, and the change proposed in the documentation (\fbox->\widefbox) failed to work.

I found an alternative solution, which I would like to share; if anyone knows of a more elegant way to produce (basically) the same output, I will certainly be interested.

Code: Select all

\begin{equation}
  \addtolength{\fboxsep}{5pt}
   \boxed{
   \begin{gathered}
      \begin{matrix}
      \quad[\phi]_{\gamma\star}^T =[\phi]_{\beta\star}^T A^{-1}&    [\phi]_{\beta\star}^T =[\phi]_{\gamma\star}^T A &\quad\forall\phi\in V\star \\
      [x]_\gamma=A[x]_\beta &\quad [x]_\beta=A^{-1}[x]_\gamma &\quad \forall x\in V \\
      \quad\gamma=\beta A^{-1} & \beta=\gamma A  &
      \end{matrix}\label{resumen}
   \end{gathered}
   }
\end{equation}
(In particular, I needed to manually align the equal signs, which I know is not desirable.)

episanty

Recommended reading 2024:

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

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

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

multiple boxed equations

Post by localghost »

A better alternative is to use the empheq package from the mh bundle.


Best regards
Thorsten
User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

multiple boxed equations

Post by Juanjo »

Try this:

Code: Select all

\begin{equation}\label{resumen}
   \addtolength{\fboxsep}{5pt}
   \boxed{
   \begin{alignedat}{3}
     [\phi]_{\gamma\star}^T &=[\phi]_{\beta\star}^T A^{-1} &\qquad 
        [\phi]_{\beta\star}^T &=[\phi]_{\gamma\star}^T A 
        &\qquad&\forall\phi\in V\star \\
     [x]_\gamma&=A[x]_\beta & [x]_\beta&=A^{-1}[x]_\gamma &&\forall x\in V \\
     \gamma&=\beta A^{-1} & \beta&=\gamma A  
   \end{alignedat}
   }
\end{equation}
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.
episanty
Posts: 26
Joined: Tue Mar 24, 2009 2:24 am

Re: multiple boxed equations

Post by episanty »

Thorsten,

as I said, I tried empheq but the box is too thin around the equations, and the solution proposed by the documentation (defining a new \widefbox command) failed to work. Further, I was unable to get any results remotely like what I wanted with the align environment, which is required for empheq and either tears up my equations, or spreads them through the whole width of the page, which I don't want.

Juanjo's solution works fine by me, though the vertical spacing is a bit wider. However, I don't quite see the advantage. I know my solution is anything but elegant, in particular because it uses manual spacing, but this is much the same in that regard.

Thank you,
episanty
User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

multiple boxed equations

Post by Juanjo »

episanty wrote: Juanjo's solution works fine by me, though the vertical spacing is a bit wider.
Well, that's a matter of taste. In my opinion, the matrix environment you used yields too cluttered equations.
episanty wrote: I don't quite see the advantage. I know my solution is anything but elegant, in particular because it uses manual spacing, but this is much the same in that regard.
You had to manually align the equal signs, which is not longer the case in my code. You used four \quad commands to set up horizontal spacing (two \quad per row). I only needed two \qquad commands in the first row to separate columns. Imagine what happened with a series of, say, six rows. Moreover, if you replace alignedat by aligned (in such a case, remove {3} at the right of \begin{alignedat}), spacing between columns is done automatically (although it is a little small, in my opinion). Finally, I prefer to use only one environment (alignedat, for example) instead of two nested environments (gathered and matrix).
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.
Post Reply