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?
2 Answers
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}
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
-
2Yes, that's exactly what I want to do, but I'd like to do it selectively for only one chapter! Thanks– GregMar 21, 2012 at 12:38
-
2@Greg I have edited my answer to suit your needs.– user11232Mar 21, 2012 at 13:05
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.
-
7The 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. Mar 21, 2012 at 9:28
\section{\textbf{\textsf{Title}}}
but it would much better to correct your custom style.