# Can I modify the font shape on-the-fly in my chapter headings if I have used sectsty to format?

I am having problems formatting the text in my chapter headings. I used sectsty to modify all my headings to \sffamily, but I have some parts of the heading that should be in italics and I can't work out how to achieve this.

Here's an example. It seems to work fine if I comment out the three lines relating to sectsty.

\documentclass[12pt, a4paper, oneside, fleqn]{report}

\usepackage{sectsty}          % put section headings in sans-serif font
\allsectionsfont{\sffamily}
\chapterfont{\LARGE\sffamily}

\begin{document}

\chapter{I want some \textit{Text In Italic} in my heading}

Where has the \textit{italic text} gone from my title?

\end{document}


• You shouldn't use \ensuremath, but simply $\mathbf{B}$, which in turn shouldn't be sans serif if in the text it is serif: it is a symbol and so it's not modifiable. If you find it conflicting with the style for chapter titles, then change the style. – egreg Feb 11 '14 at 17:04
• I just used that example because it was a general example of something I have a lot in my text, used for various other things. I want the maths B to be roman. It's the italic text I want fixed. I only included that to show that I knew it was possible for some things to override the default (though I appreciate the example is a little different. I will remove it, as it's obviously confusing. – FionaSmith Feb 11 '14 at 17:10
• The Computer Modern fonts don't have a “sans serif bold italic”, so LaTeX substitutes with the nearest font according to its rules: the font family is changed last, the shape first. You find Font shape OT1/cmss/bx/it' undefined, using OT1/cmss/bx/n' instead in your log file. – egreg Feb 11 '14 at 17:17

\usepackage{lmodern}

The Computer Modern fonts don't have a “sans serif bold italic”, so LaTeX substitutes with the nearest font according to its rules: the font family is changed last, the shape first. You find Font shape 'OT1/cmss/bx/it' undefined, using 'OT1/cmss/bx/n' instead in your log file.