[Tex/LaTex] How to write bold, italic and sans-serif at the same time

boldfontsformattingitalicsans-serif

My title is bold and sans-serif right now but two words in the title have to be italic in addition (scientific name of bacterium). Currently I'm using \selectfont to make the whole thing sans serif but when I try \textit for that name it does not work.

So, in the end it should look like this:

Bla bla bla bla P. aeruginosa

Best Answer

Your issue is "font-dependent".

Background

Indeed, special shapes of a font (bold, italic, slanted, small caps) are not defined relatively to a main font (its regular shape), but independently. The "bold version" of a font is defined per se (it is an independent *otf, *.ttf-file you can install and use, even if you don't have the main/regular version), and not as an homothetic transformation of the main font.

This is why we often refer to a font-family, that is the different shapes of a font (i.e. regular ("main font"), bold, italic, slanted, bold+italic, bold+slanted, small-caps, etc. versions). Some font-families have a lot of versions/shapes (e.g. not only bold, but also semi-bold), some others only one (there is no bold nor italic versions).

To be complete, a font-family has only shapes variations. Yet neither serif, nor sans-serif are shapes - they are characteristic of a font-family. A font-family is thus either serif, or sans-serif (or mono-spaced, etc.). Over font-families, there are thus font-harmonies, that are a selection of one serif font-family, one sans-serif font family, one mono-spaced ("typewriter") font-family, etc. that goes well the one with the other.

Answer

So the output produce depends on the font-family (thus the font-harmony) used by LaTeX during the compilation: if the bold+{italic/slanted} version of the sans-serif font-family is not installed on your computer (often because it doesn't exist), you cannot achieve what you want.

By default, LaTeX uses the Computer Modern font-harmony. Its sans-serif font-family doesn't have a bold + {italic/slanted} shape version. So you cannot get what you want.

\documentclass{article}

\begin{document}
    Some normal text. 
    \textsf{\textbf{Blah blah \emph{P. aeruginosa}}}

    Some normal text. 
    \textsf{\textbf{Blah blah \textit{P. aeruginosa}}}

     Some normal text. 
    \textsf{\textbf{Blah blah \textsl{P. aeruginosa}}}
\end{document}

enter image description here

However, when you load e.g. the lmodern-package, you tell LaTeX to use the Latin Modern font-harmony. Since its sans-serif font-family has a bold+italic and a bold+slanted version, it can produce the output you want.

\documentclass{article}
    \usepackage{lmodern}
\begin{document}
    Some normal text. 
    \textsf{\textbf{Blah blah \emph{P. aeruginosa}}}

    Some normal text. 
    \textsf{\textbf{Blah blah \textit{P. aeruginosa}}}

     Some normal text. 
    \textsf{\textbf{Blah blah \textsl{P. aeruginosa}}}
\end{document}

enter image description here