I'm trying to write the following in latex:
Any suggestions please?
Thank you.
amsmathmath-mode
I'm not sure what you mean by "\textcircled
doesn't seem to like this", because
\documentclass{article}
\begin{document}
\raisebox{.5pt}{\textcircled{\raisebox{-.9pt} {$f_n$}}}
\end{document}
compiles fine for me. That said, it does look a bit rubbish:
You might consider a little TikZ picture for this situation. You could put the $f_n$
inside a circular TikZ node. The node would adjust its size correctly, depending on its contents, and align correctly on the baseline of the surrounding text.
\documentclass{article}
\usepackage{tikz}
\newcommand\encircle[1]{%
\tikz[baseline=(X.base)]
\node (X) [draw, shape=circle, inner sep=0] {\strut #1};}
\begin{document}
Lorem \encircle{$f_n$} ipsum \encircle{q} dolor \encircle{a}
sit \encircle{A} amet \encircle{Hello}.
\end{document}
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.}$
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}$
$T^{-1}(x) = \frac{9}{5}x + 32 \textbf{some faffing about}$
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.
Best Answer
Here is a possibility: