Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm new to LaTeX, and I'm having an issue with using \framebox inside an equation (denoted with $$ signs at the beginning and the end).

The text that I'm trying to box is the following:

1.5 \times 10^{- 5} \; Pa

However, once I put a \framebox around it, like so:

\framebox{1.5 \times 10^{- 5} \; Pa}

I get the following error:

./assignment1.tex:85: Missing $ inserted.

...where 85 points to the line where I put in the \framebox. Any ideas why this is happening?

share|improve this question
3  
Inside the argument to the \framebox, the outer math environment is lost. You must place the argument itself inside math delimiters (single $) –  Steven B. Segletes Jan 29 at 2:05
    
If you want to keep the expression in displayed mode, you can load amsmath and use \boxed, as the following example shows: \[ \boxed{1.5 \times 10^{- 5} \; Pa} \] –  Gonzalo Medina Jan 29 at 2:18

2 Answers 2

up vote 10 down vote accepted

boxed will not span an equation if it encloses an alignment point i.e., & . In such cases you can use Aboxed from mathtools. See the example below for illustration. Further, to typeset units, better use siunitx.

\documentclass{article}
\usepackage{mathtools}
\usepackage{siunitx}
\begin{document}
  \framebox{$1.5 \times 10^{- 5}\si{\pascal}$}
  \begin{align}
    &\boxed{1.5 \times 10^{- 5}\si{\pascal}}\\
    \Aboxed{\text{Pressure} &=1.5 \times 10^{- 5}\si{\pascal}}
  \end{align}
\end{document}

enter image description here

A useful read will be this Q and its A

share|improve this answer
    
You wrote "\boxed will not span an entire equation" and that is not exactly true. \boxed will span an entire equation unless the box should cross an alignment point. –  Gonzalo Medina Jan 29 at 2:51
    
No problem :-) I'll delete this comment, and the previous one, shortly. –  Gonzalo Medina Jan 29 at 13:28

Package amsmath provides a command, namely \boxed, to generate boxed math.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[\boxed{E = mc^2}\]

$\boxed{E =mc^2}$
\end{document}

BTW, do NOT use $$, see here for details.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.