2

I'm in LaTex, and am trying to boldface this whole line of text:

$T^{-1}(x)$=$\frac{9}{5}$x+32.

However, when I use \textbf, it only boldfaces x+32. Any suggestions on how to boldface it all?

Thank you!

Scz
  • 1,633
  • Hello and welcome to TeX.SE. Well, first of all, I'm totally at a loss to understand your placement of $ signs there, but putting that to one side. The thing about \textbf is, well, it's for text! It only belongs in text mode (technically "paragraph mode" and "LR mode"). If you're in math mode (you enter math mode when you have your first $ and you exit it at the next $) you have to use \mathbf. That should give you what I think you want, although it won't embolden your operators (- = +) as far as I know – Au101 Jul 13 '15 at 00:04
  • I don't think it emboldens the brackets either – Au101 Jul 13 '15 at 00:05

2 Answers2

8

LaTeX works in one of three modes. (There are actually six TeX modes, but we really don't need to go into too much detail here. If you're interested: link.):

  • Paragraph mode

  • Math mode

  • Left-to-right mode (LR mode)

Paragraph mode is for normal text. LaTeX treats your input as text, it treats it as a series of letters which make up words which make up sentences which make up paragraphs. This influences the way LaTeX parses your input and the output it produces.

Left-to-right mode is just like paragraph mode, except LaTeX will not break lines.

These are your text modes. There are plenty of commands that only work in text modes, such as the accent command \'.

In math mode, LaTeX treats your input as mathematics. It does not think of letters as making up words - it thinks of them as variables. In paragraph and LR mode word is the word "word". In math mode word is the variable w times the variable o times the variable r times the variable d. In paragraph and LR mode, a word is the two words "a" and "word" in math mode, the space is irrelevant. It is merely the variable a times the other variables.

Almost all of your commands for mathematics only work in math mode. Additionally, plenty of text mode commands will not work in math mode, as I said above.

You are in paragraph mode most of the time. You enter math mode by typing a $ or \( and you exit it by typing a second $ or \). (N.B. you must use either $ ... $ or \( ... \) not $ ... \)).

More precisely, this is for in-line math. If you would like to enter a displaymath environment, to display your equation, you should use \[ ... \]. There are also environments which you can enter which will automatically put you into math mode, such as the equation environment.

It is possible to nest modes within each other, though. For example you can enter LR mode within math mode by typing \mbox{}. So if we had:

$\mathbf{T^{-1}(x) = \frac{9}{5}x + 32} \mbox{ isn't that nice?}$

Then isn't that nice? would be processed in LR mode. You could then use text mode commands such as \' within mbox, e.g.:

$\mathbf{T^{-1}(x) = \frac{9}{5}x + 32} \mbox{ d\'{e}j\`{a} vu}$

But you couldn't use math mode commands within \mbox{}. Either side of it, though, you can use math mode commands, but you can't use text mode commands.

Now then, basics over with: your question. \textbf{} is used for creating bold text - its argument will be processed as text.

If we're in math mode, we have \mathbf{} to use instead - this cannot be used in a text mode. However, \mathbf{} is mainly intended for emboldening variables and numbers and things, it does not make everything bold. As Mico says in the comments "\mathbf works on latin-alphabet letters but not on symbols, including =, +, -, (, and )":

$\mathbf{T^{-1}(x) = \frac{9}{5}x + 32.}$

enter image description here

Nine times out of ten, of course, that's a good thing, too. But if you really want everything emboldened, you can apply \boldsymbol to any symbols you have. Plainly, this isn't the way to go: far too messy.

Instead, there is, of course, the bm package. Please see Mico's fine answer for more.

Possibly the author of bm will not be very happy with me for saying this, but, I have to ask you, are you sure this is what you want? If you want to emphasise an equation in some way, emboldening the whole lot is not generally the way to go. For one thing, bold face means something in mathematics. It's used for vectors, matrices and sets. Rarely does a = a. Try displaying it, or numbering it.

Now, that being said, we can use \textbf{} in math mode if we want - but it will stick us in text mode. Re-reading your question, I imagine what you had done before is this:

 \textbf{$T^{-1}(x)$=$\frac{9}{5}$x+32}

The problem you have is that the $ ... $ puts you into math mode and you start afresh. The original, outer \textbf{} is not carried over, if you see what I mean? It doesn't permeate through, it doesn't continue to operate down through the levels. You could call it again, e.g.:

\textbf{$T^{-1}(\textbf{x})$=$\frac{9}{5}$x+32}

This would compile. But this is obviously not a very nice way to go about things.

Anyway, in your original code, you then leave math mode, but the = cannot be emboldened. You then re-enter it (same problem) and finally you exit it and you have something in text mode that can be emboldened: the x and the 32. Not the +.

Now, if you were to stick a \textbf{} command around everything, within math mode, like this:

$\textbf{T^{-1}(x) = \frac{9}{5}x + 32.}$

You will have problems because you are in text mode. ^, for example, is not defined in text mode. Nor is \frac.

What we can do is use \textbf{} if we want to put emboldened words into our mathematics.

Meanwhile, we should use \mathbf{} if we want to embolden mathematical objects, such as vectors.

Compare:

$T^{-1}(x) = \frac{9}{5}x + 32 \mathbf{some faffing about}$

enter image description here

$T^{-1}(x) = \frac{9}{5}x + 32 \textbf{some faffing about}$

enter image description here


A final note. In your question, you have

 $T^{-1}(x)$=$\frac{9}{5}$x+32

You seem to be entering math mode whenever you have to typeset something you can't do in a text mode (paragraph or LR mode) and then leaving it as soon as possible. This is not a good way to use LaTeX. First of all, notice that your x is italic on the left hand side of the = sign and upright on the right hand side. Secondly, math mode will automatically give you the correct spacing around your binary operators = and +. Thirdly, LaTeX was originally conceived around logical structures. Your equation is a single logical unit. Finally, of course, it's easier on your hands.

Au101
  • 10,278
  • 3
    +1 for the detailed explanation. Perhaps you could also mention that “text mode” commands like \textbf or \textit can be used directly in math mode too, as in \( \textit{counter} \leftarrow \textit{counter}+1 \). – GuM Jul 13 '15 at 00:42
  • Good point, @GustavoMezzetti, give me two shakes of a lamb's tail. Well, maybe five? – Au101 Jul 13 '15 at 00:45
  • 1
    \mathbf works on latin-alphabet letters but not on symbols, including =, +, -, (, and ). If these (and other) symbols need to be typeset in bold as well, it's necessary to apply \boldsymbol to them. In contrast, \bm operates both on latin letters and on symbols. By the way, when mentioning various operating modes, you left out the all-important vertical mode, which is part of the TeX core and not just something provided by a package. At any rate, for the purpose of the posting at hand, I believe it suffices to distinguish between text mode and math mode. – Mico Jul 13 '15 at 01:20
  • @Mico Good comment, I was going off of Lamport's User's Guide and Reference Manual. He has an entry for vertical mode in the index, but I can't find it in the text. Is vertical mode a LaTeX mode or a TeX mode? I've got a feeling Lamport mentions it. Anyway, your succinct summary is better than mine, I'll edit – Au101 Jul 13 '15 at 01:28
  • @Au101 -- see my comment to mico regarding \boldsymbol. excellent point about a not = a. but i think the point that has been missed (by mico too) is that the rationale for doing this is "missing"; the op may have an excellent reason (e.g. it's the style required for a book cover, although i'd question even that), but it's not stated. anyone in the math publishing biz should seriously question this style, because, as you say, usually a not = a. another (perhaps minor) point -- i would suggest \text instead of \mbox (requires amsmath). – barbara beeton Jul 13 '15 at 14:45
  • I think that it is inappropriate to mention “core” TeX’s vertical mode in this context (one should also begin to distinguish between internal and outer vertical mode…). After all, Lamport’s “paragraph mode” corresponds to a situation in which TeX goes back and forth between vertical mode and (unrestricted) horizontal mode, whereas “LR mode” is just TeX’s restricted horizontal mode… Enough: “text” versus “math” mode is the concern here, as @Mico says. – GuM Jul 13 '15 at 14:51
  • @Au101 thank you so much for the informative comment! I'm still fairly new to LaTex, so I'm literally googling everything I can to learn it. I didn't realize that you could put $\command{...}$, and that would process all as math (I knew that you needed to put anything you wanted to make math in $..$, but I didn't realize you could do entire strings. That was a big help. I used the \mathbf command, and it worked splendidly! The only reason I wanted to bold the entire equation is because it was a final presentation I had to present to my "class, and I wanted to emphasize my final answer. – deathcat05 Jul 16 '15 at 02:11
7

A comment up front: It's strongly advisable to render the entire formula in math mode: $T^{-1}(x)=\frac{9}{5}x+32$. Typographic spacing rules differ according to whether the material is text or a (math) formula. Is you switch back and forth between the two modes within one and the same formula, there's no hope of getting the correct spacing.

I can think of two methods that will let you achieve your goal. First, you could load the bm package and use its \bm{...} macro:

$\bm{ T^{-1}(x)=\frac{9}{5}x+32 }$

Second, you could write

{\boldmath $T^{-1}(x)=\frac{9}{5}x+32$}

Observe that the entire formula is encased in a {\boldmath ...} "wrapper".

enter image description here

\documentclass{article}
\usepackage{bm} % for \bm macro
\begin{document}
plain: $T^{-1}(x)=\frac{9}{5}x+32$

\medskip
\medskip
bold I: $\bm{ T^{-1}(x)=\frac{9}{5}x+32 }$ 

\medskip
bold II: {\boldmath $T^{-1}(x)=\frac{9}{5}x+32$}
\end{document}
Mico
  • 506,678
  • much to my surprise, $\boldsymbol{T^{-1}(x) ... }$ acts on the whole string just as \bm or {\boldmath ...} does. it's not documented, i don't think, and i have no intention of doing so. – barbara beeton Jul 13 '15 at 14:40
  • @barbarabeeton - I wasn't aware of the broad scope of amsmath's \boldsymbol macro either... According to the user guide of the bm package, \bm is faster, and takes more care of spacing, than amsmath's \boldsymbol does. – Mico Jul 13 '15 at 14:44
  • and what's more, the ams documentation recommends that \bm be used instead of \boldsymbol. i'd say that's a pretty clear directive. – barbara beeton Jul 13 '15 at 15:16