Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
3  
It works for me. Can you give more details through a MWE? –  Harish Kumar Mar 21 '12 at 7:49
1  
It works for me also. –  Mu30 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
add comment

2 Answers

up vote 13 down vote accepted

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

share|improve this answer
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. –  Harish Kumar Mar 21 '12 at 13:05
1  
That's perfect, thank you very much! –  Greg Mar 21 '12 at 13:15
add comment

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.

share|improve this answer
1  
I'll try this out, thanks for your help! –  Greg Mar 21 '12 at 8:44
5  
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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