# Font selection in LaTeX (very simple)

I want to have a subsection with the following name:

The synchronized Keyword

i.e., make the word "synchronized" appear in a code-like font. I tried doing this:

\subsection{The \ttfamily{synchronized} keyword}


but it also makes the word "keyword" in the code-like font. How can I only apply the font to one word?

The LaTeX command is \texttt for a teletype font:

\subsection{The \texttt{synchronised} keyword}

• What I want to know is why the \ttfamily command exists at all if it pulls crap like that and the \texttt command works just fine. Feb 16, 2011 at 14:20
• LaTeX 2.09 had only the modal commands (\tt etc), which in LaTeX2e were deprecated in favour of the longer form (\ttfamily) as they now select font axes rather than a single font. The command forms (\texttt) are similar, although they also, as noted by Villemoes, produce italic spacing correction. The command forms tend to be more useful when you just want to change a single word or short phrase, so you don't have to "undo" them mid paragraph. The modal commands are more useful when you want the selection to apply to an entire group, such as when renewing the \maketitle command. Feb 16, 2011 at 15:06
\subsection{The {\ttfamily synchronized} keyword}

• It is perhaps pointing out that while each \textXX{bla} has a {\XX(shape/family/series) bla} counterpart, they are not strictly equivalent in all cases: \textit{} automatically takes care of italic correction, while {\itshape } does not. Compare the results of Is {\itshape Puff} a magic dragon? and Is \textit{Puff} a magic dragon?. In general, the \textXX should be used when a single word or a short phrase needs a different font, while the declaration forms should be used for larger pieces of text (usually within an environment). Feb 16, 2011 at 5:05
• \itshape is far different to all other ... but we were talking about typewriter ... ;-)