23

How can one format a chapter or section heading in bold using a sans-serif font? I tried \textsf{\textbf{bold sans-serif text}}, but it does not seem to work. Any idea?

  • 3
    It works for me. Can you give more details through a MWE? – user11232 Mar 21 '12 at 7:49
  • 1
    It works for me also. – Mu30 murugans2katgmail Mar 21 '12 at 8:26
  • 1
    Hmm, my MWE also turned out to work, but it does not in my big document that uses some custom style. I try to change the font of a section heading, which is normally bold by default, but when I do: \section{\textsf{Section}}, it's no longer bold... – Greg Mar 21 '12 at 8:43
  • 2
    If you can get bold sans serif in normal text but not in the section header then probably your section style doesn't use the normal font selection system. You could try \section{\textbf{\textsf{Title}}} but it would much better to correct your custom style. – Ulrike Fischer Mar 21 '12 at 9:34
20

It looks like you are trying to change the sections font to sans serif and usual bold letters. If you want it to be in sans serif through out the document, then you can do it with sectsty package.

\documentclass{article}
\usepackage{sectsty}
\allsectionsfont{\bfseries\sffamily} % <---- omitting \bfseries still gives bold font
\begin{document}
\section{Section}
\section{Section}
\end{document}

enter image description here

Edit: For only one chapter the code can be modified like this.

\documentclass{book}
\usepackage{sectsty}
\begin{document}
\chapter{first}
\section{Section}
This is one section.
\section{Section}
This is another section.
\chapter{second}
%\sectionfont{\sffamily} for only sections in sf
\allsectionsfont{\sffamily} %<-----command here. use \sectionfont{\sffamily} for only sections
\section{Section}
This is one section.
\subsection{Subsection} A sub section
\section{Section}
This is another section.
\allsectionsfont{\rmfamily} %%<-----command here
\chapter{Third}
\section{Section}
This is one section.
\section{Section}
This is another section.
\end{document}

Please look into the documentation of sectsty for details

  • 2
    Yes, that's exactly what I want to do, but I'd like to do it selectively for only one chapter! Thanks – Greg Mar 21 '12 at 12:38
  • 2
    @Greg I have edited my answer to suit your needs. – user11232 Mar 21 '12 at 13:05
18

The following minimal example compiles without any errors or warnings:

\documentclass{article}
\begin{document}
\textbf{This is bold text.}
\textsf{This is sans-serif text.}
\textsf{\textbf{This is sans-serif bold text.}}
\textbf{\textsf{This is bold sans-serif text.}}
\end{document}

Note that both \textsf{\textbf{...}} and \textbf{\textsf{...}} both work, and both have the exact same effect. But if one order is not working for you, maybe try the other?

You should compare your document to this minimal example and see if you have used any packages or defined any macros which may have changed the way \textsf and/or \textbf operate. (It's also possible that your fonts are not compatible with one of these commands.) To isolate the problem, try starting from a minimal document in which this formatting works, and then keep adding the packages and macros you use until the error comes up.

  • 6
    The order of the commands should not be relevant if nobody has tempered with the commands. As default they lead to exactly the same font definition. – Ulrike Fischer Mar 21 '12 at 9:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.