How to draw box for my math equation in latex

In summary: Argument of \fbox has an extra }."If you want a box that fits the equation, I can do that too... but it's more involved that a simple boxed.
  • #1
snshusat161
214
1
I want to enclose my final equation inside a box but i find no way to do that in latex. please help me out as soon as possible.

Thanks!
 
Physics news on Phys.org
  • #2
Use "\boxed{}"
 
  • #3
Not working

My latex code is

Code:
\begin{flalign*}
E_1 & = \frac{e_{1max}}{\sqrt{2}}\\
& = \frac{N_1.{\phi}_m.w}{\sqrt{2}}\\
& = \frac{N_1{\phi}_m.2\pi.f}{\sqrt{2}}\\
\\
E_1 & = 4.44 N_1.{\phi}_m.f\\
\\
E_1 & = 4.44 N_1.B_m.A.f
\end{flalign*}

and after using \boxed in
Code:
E_1 & = 4.44 N_1.B_m.A.f

I get the following error:

Code:
This is pdfTeX, Version 3.1415926-1.40.11 (MiKTeX 2.9)
entering extended mode
(E:/notes/test.tex
LaTeX2e <2009/09/24>
Babel <v3.8l> and hyphenation patterns for english, afrikaans, ancientgreek, ar
abic, armenian, assamese, basque, bengali, bokmal, bulgarian, catalan, coptic, 
croatian, czech, danish, dutch, esperanto, estonian, farsi, finnish, french, ga
lician, german, german-x-2009-06-19, greek, gujarati, hindi, hungarian, iceland
ic, indonesian, interlingua, irish, italian, kannada, kurmanji, lao, latin, lat
vian, lithuanian, malayalam, marathi, mongolian, mongolianlmc, monogreek, ngerm
an, ngerman-x-2009-06-19, nynorsk, oriya, panjabi, pinyin, polish, portuguese, 
romanian, russian, sanskrit, serbian, slovak, slovenian, spanish, swedish, swis
sgerman, tamil, telugu, turkish, turkmen, ukenglish, ukrainian, uppersorbian, u
senglishmax, welsh, loaded.
("C:\Program Files\MiKTeX 2.9\tex\latex\base\report.cls"
Document Class: report 2007/10/19 v1.4h Standard LaTeX document class
("C:\Program Files\MiKTeX 2.9\tex\latex\base\size12.clo"))
("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\graphicx.sty"
("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\keyval.sty")
("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\graphics.sty"
("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\trig.sty")
("C:\Program Files\MiKTeX 2.9\tex\latex\00miktex\graphics.cfg")
("C:\Program Files\MiKTeX 2.9\tex\latex\pdftex-def\pdftex.def"
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\infwarerr.sty")
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\ltxcmds.sty"))))
("C:\Program Files\MiKTeX 2.9\tex\latex\ams\math\amsmath.sty"
For additional information on amsmath, use the `?' option.
("C:\Program Files\MiKTeX 2.9\tex\latex\ams\math\amstext.sty"
("C:\Program Files\MiKTeX 2.9\tex\latex\ams\math\amsgen.sty"))
("C:\Program Files\MiKTeX 2.9\tex\latex\ams\math\amsbsy.sty")
("C:\Program Files\MiKTeX 2.9\tex\latex\ams\math\amsopn.sty"))
(E:\notes\test.aux)
======================================================================
pdflatex.EXE: Cannot start MiKTeX package manager.
pdflatex.EXE: Data: Invalid syntax

======================================================================
 (E:\notes\title.tex
<./images/logo.png, id=1, 143.53625pt x 59.22125pt> <use ./images/logo.png>
[1{C:/ProgramData/MiKTeX/2.9/pdftex/config/pdftex.map} <E:/notes/images/logo.pn
g>])
Chapter 1.
<./images/1.jpg, id=12, 401.5pt x 301.125pt> <use ./images/1.jpg>
<./images/2.jpg, id=13, 401.5pt x 303.1325pt> <use ./images/2.jpg>
<./images/3.jpg, id=14, 401.5pt x 301.125pt> <use ./images/3.jpg>
<./images/4.jpg, id=15, 201.75375pt x 225.09094pt> <use ./images/4.jpg>
Overfull \hbox (2.61108pt too wide) in paragraph at lines 8--12
[] []

Overfull \hbox (2.61108pt too wide) in paragraph at lines 8--12
[] []
[1 <E:/notes/images/1.jpg> <E:/notes/images/2.jpg> <E:/notes/images/3.jpg> <E:/
notes/images/4.jpg>] <./images/6.png, id=19, 208.52907pt x 125.71968pt>
<use ./images/6.png>
Underfull \hbox (badness 10000) in paragraph at lines 18--23


Underfull \hbox (badness 10000) in paragraph at lines 18--23


Underfull \hbox (badness 10000) in paragraph at lines 24--31


Underfull \hbox (badness 10000) in paragraph at lines 24--31


Underfull \hbox (badness 10000) in paragraph at lines 24--31

[2 <E:/notes/images/6.png (PNG copy)>]

Package amsmath Warning: Foreign command \over;
(amsmath)                \frac or \genfrac should be used instead
(amsmath)                 on input line 38.


Underfull \hbox (badness 10000) in paragraph at lines 43--46


Underfull \hbox (badness 10000) in paragraph at lines 50--51

! Missing } inserted.
<inserted text> 
                }
l.59 \end{flalign*}
                   
?
 
  • #4
To use the \boxed{} command, I think you need to load amsmath package.
 
  • #5
yenchin said:
To use the \boxed{} command, I think you need to load amsmath package.
snshusat161 is doing just that. Look at the LaTeX output:
snshusat161 said:
Code:
("C:\Program Files\MiKTeX 2.9\tex\latex\ams\math\amsmath.sty"
For additional information on amsmath, use the `?' option.
snshusat161 said:
Not working

and after using \boxed in E_1 & = 4.44 N_1.B_m.A.f

I get the following error:[error output elided]
Well of course it's not working. You can't box around the separator character "&". That doesn't make sense.

What you can do is to put a box around the right hand side of your final equation:
Code:
\begin{align*}
E_1 & = \frac{e_{1max}}{\sqrt{2}}\\
& = \frac{N_1.{\phi}_m.w}{\sqrt{2}}\\
& = \frac{N_1{\phi}_m.2\pi.f}{\sqrt{2}}\\
\\
E_1 & = 4.44 N_1.{\phi}_m.f \\
\\
E_1 &= \boxed{4.44 N_1.B_m.A.f}
\end{align*}
[tex]\begin{align}
E_1 & = \frac{e_{1max}}{\sqrt{2}}\\
& = \frac{N_1.{\phi}_m.w}{\sqrt{2}}\\
& = \frac{N_1{\phi}_m.2\pi.f}{\sqrt{2}}\\
\\
E_1 & = 4.44 N_1.{\phi}_m.f \\
\\
E_1 &= \boxed{4.44 N_1.B_m.A.f}
\end{align}[/tex]You can box the entire final equation as well, but you'll have to make your final equation standalone:
Code:
\begin{align*}
E_1 & = \frac{e_{1max}}{\sqrt{2}}\\
& = \frac{N_1.{\phi}_m.w}{\sqrt{2}}\\
& = \frac{N_1{\phi}_m.2\pi.f}{\sqrt{2}}\\
\\
E_1 & = 4.44 N_1.{\phi}_m.f
\end{align*}
\begin{equation*}
\boxed{E_1 = 4.44 N_1.B_m.A.f}
\end{equation*}
[tex]\begin{align}
E_1 & = \frac{e_{1max}}{\sqrt{2}}\\
& = \frac{N_1.{\phi}_m.w}{\sqrt{2}}\\
& = \frac{N_1{\phi}_m.2\pi.f}{\sqrt{2}}\\
\\
E_1 & = 4.44 N_1.{\phi}_m.f
\end{align}[/tex][tex]
\boxed{E_1 = 4.44 N_1.B_m.A.f}
[/tex]
BTW, it would have been helpful in the original post if you had specified that you wanted to do this in a flalign environment.
 
  • #6
Thanks D H. You are great! :)
 
  • #7
[tex]
\begin{align*}
E_1 & = \frac{e_{1max}}{\sqrt{2}}\\
& = \frac{N_1.{\phi}_m.w}{\sqrt{2}}\\
& = \frac{N_1{\phi}_m.2\pi.f}{\sqrt{2}}\\
\\
E_1 & = 4.44 N_1.{\phi}_m.f \\
\\
E_1 &= \fbox{$4.44 N_1.B_m.A.f$}
\end{align*}
[/tex]
\fbox works in ordinary [itex]\LaTeX[/itex]... but you'll need to use \fbox{$math expression$}
 

1. How do I create a box around my math equation in LaTeX?

To create a box around your math equation in LaTeX, you can use the \boxed command. Simply place your equation inside the command, like this: \boxed{y = mx + b}. This will create a box around your equation.

2. Can I change the color or style of the box around my equation?

Yes, you can change the color and style of the box around your equation by using the \fcolorbox command. This command allows you to specify the color, line thickness, and style of the box. For example, \fcolorbox{red}{white}{y = mx + b} will create a red box with a white background around your equation.

3. How can I adjust the size of the box around my equation?

To adjust the size of the box around your equation, you can use the \scalebox command. This command allows you to resize the box while maintaining the proportions of the equation. For example, \scalebox{2}{y = mx + b} will make the box and equation twice as large.

4. Is it possible to add a label or caption to the box around my equation?

Yes, you can add a label or caption to the box around your equation by using the \boxed command in conjunction with the \label and \caption commands. For example, \boxed{y = mx + b}\label{eq:line} \caption{Equation of a line} will create a box with the equation and a label and caption below it.

5. Can I use the box around my equation in a document with multiple columns?

Yes, you can use the box around your equation in a document with multiple columns by using the \parbox command. This command allows you to create a box with a specified width, which is useful for fitting the equation in a specific column. For example, \parbox{3cm}{\boxed{y = mx + b}} will create a box with a width of 3cm around your equation.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
789
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
13
Views
974
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
905
  • MATLAB, Maple, Mathematica, LaTeX
2
Replies
36
Views
905
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
Back
Top