How can I put multiple line equations inside a box in Latex?

  • Context: LaTeX 
  • Thread starter Thread starter kdv
  • Start date Start date
  • Tags Tags
    Box Latex
Click For Summary

Discussion Overview

The discussion centers around how to format multiple line equations within a box using LaTeX. Participants explore various methods for achieving this, particularly in the context of different environments such as equation arrays and the eqnarray.

Discussion Character

  • Technical explanation
  • Exploratory
  • Homework-related

Main Points Raised

  • Some participants express uncertainty about the appropriate forum for LaTeX questions.
  • One participant describes using \boxed{} for single line equations but encounters issues when attempting to apply it to multiline equations in an eqnarray.
  • A participant shares a method using \begin{gathered} within a boxed environment to successfully format multiline equations.
  • Another participant suggests using the 'split' environment for better alignment of multiline equations instead of 'gathered'.
  • There is mention of necessary packages, such as \usepackage{amsmath} and \usepackage{amssymb}, for successful compilation of the examples provided.

Areas of Agreement / Disagreement

Participants generally agree on the methods discussed for boxing multiline equations, but there is no consensus on the best approach, as different methods are proposed and shared.

Contextual Notes

Some participants note the need for specific LaTeX packages to compile their examples correctly, indicating potential limitations for users unfamiliar with these requirements.

Who May Find This Useful

Readers interested in LaTeX formatting, particularly those looking to format multiline equations within a boxed environment, may find this discussion beneficial.

kdv
Messages
345
Reaction score
5
I am not sure if this is the right place to post a Latex question. If not, tell me where I should go.

I would like to put equations inside a box. Now, I have found two ways to do this butthey work only for single line equations. The best method is to simply put the equations between boxed braces, i.e. \boxed{ equation}

this works if I am in an equation array i.e.

\begin{equation} \boxed{equation} \end{equation}

I have tried the same thing in an eqnarray but I get compilations errors. I would like to have equations spanning several lines which would be inside a box.

Anybody can help?

Thanks
 
Physics news on Phys.org
kdv said:
I am not sure if this is the right place to post a Latex question. If not, tell me where I should go.

I would like to put equations inside a box. Now, I have found two ways to do this butthey work only for single line equations. The best method is to simply put the equations between boxed braces, i.e. \boxed{ equation}

this works if I am in an equation array i.e.

\begin{equation} \boxed{equation} \end{equation}

I have tried the same thing in an eqnarray but I get compilations errors. I would like to have equations spanning several lines which would be inside a box.

Anybody can help?

Thanks

There are instructions in the https://www.physicsforums.com/showthread.php?t=8997" here at the forum. I haven't read the entire thing. There are over 700 posts.
 
Last edited by a moderator:
kdv said:
I am not sure if this is the right place to post a Latex question. If not, tell me where I should go.

I would like to put equations inside a box. Now, I have found two ways to do this butthey work only for single line equations. The best method is to simply put the equations between boxed braces, i.e. \boxed{ equation}

this works if I am in an equation array i.e.

\begin{equation} \boxed{equation} \end{equation}

I have tried the same thing in an eqnarray but I get compilations errors. I would like to have equations spanning several lines which would be inside a box.

Anybody can help?

Thanks

I found a way but I am not sure if it will work on the forums here, so here's the trick:
<br /> \begin{equation*}<br /> \addtolength{\fboxsep}{5pt}<br /> \boxed{<br /> \begin{gathered}<br /> \Pi_{i=1}^m \int d^4x_i \, e^{-i (k \cdot x)_i} ~\Pi_{j=1}^n \int d^4y_j \, e^{+ i (p \cdot y)_j} \\<br /> &lt;0| T\{ \phi(x_1) \ldots \phi(x_m) \phi(y_1) \ldots \phi(y_n) \} |0&gt;<br /> \\ = \biggl( \Pi_{i=1}^m \frac{i \sqrt{Z}}{k_i^2 - m^2} \biggr) \biggl(\Pi_{j=1}^n \frac{i \sqrt{Z}}{p_j^2 - m^2} \biggr) ~&lt;\vec{p}_1 \ldots \vec{p_n}|i T| \vec{k_1} \ldots \vec{k_m}&gt;<br /> \end{gathered}<br /> }<br /> \end{equation*}<br />

It worked!

(For anybody interested, left click on the equation to see the source code)
 
Thanks a lot for this tip kdv I'd been wondering how to get boxes around multiline equations.

Also, for alignment you can use the 'split' environment rather than 'gathered'.

<br /> \begin{equation*}<br /> \addtolength{\fboxsep}{10pt}<br /> \boxed{<br /> \begin{split}<br /> \int \frac{d^D P}{(2\pi)^D} \frac{{\cal P}_n(P)}<br /> {P^{2\alpha}(P-Q)^{2\beta}} =<br /> &amp;\frac{1}{(4\pi)^2}(Q^2)^{D/2-\alpha-\beta}\sum_{\sigma \ge 0}^{[n/2]}<br /> G(\alpha,\beta,n,\sigma) \cdot \\<br /> &amp;\cdot Q^{2\sigma} \left\{ \frac{1}{\sigma !}<br /> \left( \frac {\Box} {4} \right) ^\sigma {\cal P}_n(P)\right\}_{P=Q}<br /> \end{split}<br /> }<br /> \end{equation*}<br />

For anybody compiling this remember to include \usepackage{amsmath} in your preamble and for this particular example also \usepackage{amssymb} for the D'Alembertian.

Thanks again.
 
kdv, thanks for posting your answer after finding it. Google funneled me here, and your post has helped me out.
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 12 ·
Replies
12
Views
3K
  • · Replies 13 ·
Replies
13
Views
2K
  • · Replies 7 ·
Replies
7
Views
4K
  • · Replies 2 ·
Replies
2
Views
4K
Replies
11
Views
4K
  • · Replies 9 ·
Replies
9
Views
6K
  • · Replies 11 ·
Replies
11
Views
9K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K