The LaTeX wiki says it makes a box, but when I used it with \mbox{Cos}
for example, it simply wrote "Cos" in the same way that writing Cos by itself would have done. What's the point of \mbox
?
[Tex/LaTex] What does $\mbox$ do
boxesmath-mode
boxesmath-mode
The LaTeX wiki says it makes a box, but when I used it with \mbox{Cos}
for example, it simply wrote "Cos" in the same way that writing Cos by itself would have done. What's the point of \mbox
?
Best Answer
You don't really want to do that, because the spacing would be wrong.
The
\mbox
should typeset its argument in text mode even if in math mode; however it's wrong anyway. Operator names should be typeset in text mode, but with an upright font in any circumstance. With\mbox
you don't ensure the correct spacing, nor that the font is right.Look at the following example. In the pair of lines the first has
\mbox{Cos}
, the second one has\Cos
properly defined.You can notice that the spacing in the first line is slightly bad, but the result is dramatically wrong in the third line.
By the way, the cosine function has been named “cos” for centuries, until Mathematica came along and changed the conventions. I'll stay with the tradition, and LaTeX already provides
\cos
for that purpose.It has been asked in comments to also deal with another usage of
\mbox
inside a math formula, say(actually moose is claiming to have found
${\mbox{\boldmath{$\epsilon$}}}$
, which I'm not really surprised of).This is a very old, outdated and deprecated method for making a boldface math symbol. One has to remember that
\boldmath
is not legal inside a math formula: so witha warning about
Command \boldmath invalid in math mode
would be issued and\boldmath
would be ignored. By switching to text mode within the\mbox
,\boldmath
becomes legal and produces the desired effect. Technical note: when\mbox
appears in a formula, TeX suspends math mode, enters text mode, typesets the box and switches back to math mode at the end.However, something like
would have a bad output, because the symbol will not be in subscript size.
Since many years, a better method has been available: the instructions
allows one to say
and
getting a bold epsilon in the right size.