Suppose I wanted to use a different font for a title then the body text in LaTeX (pdflatex). (For example, if I wanted to use a slightly fancier font for titles, or a sans-serif one.) How would I do that, change the font of a class of thing throughout the document, in a proper way. (Likewise, if I wanted to change the document title, captions, etc. Is there a general way of doing this?)
2 Answers
The titlesec or sectsty packages are your friends for the standard classes. If you want some more control, try the komascript classes or memoir. See the UKTeXFAQ.
-
-
The OP made a rather broad question, so the broad general answer.– jarnoszCommented Jun 27, 2015 at 19:49
I would say that really much depends on what you are trying to achieve.
Do you want to make a class that others can use as well? You can
define your own commands for sectioning. Are there just minor
changes within one of your documents? Use package etoolbox
and
patch your changes. Are there bigger changes to the sectioning
and titles? Package titlesec
is commonly used with the standard
classes.
KOMA-classes have their own way of defining the font for various instances of a document. The following example shows the interface.
Disclaimer: This is just for demonstration, nobody should use that many stuff in just one document.
\documentclass[plainheadsepline,headsepline=2pt]{scrreprt}
\usepackage{blindtext}
\usepackage{scrlayer-scrpage}
\usepackage{xcolor}
\RedeclareSectionCommand[font={\Huge\fontfamily{qhv}}]{chapter}
\RedeclareSectionCommand[font={\rmfamily\footnotesize\itshape}]{section}
\addtokomafont{captionlabel}{\usefont{T1}{qzc}{m}{it}}
\addtokomafont{caption}{\color{red!80!black}}
\addtokomafont{headsepline}{\color{red!80!black}}
\begin{document}
\chapter{lazy Leguan}
\section{walzing wombat}
\captionof{figure}{A figure caption}
\blindtext
\end{document}
ln `which xelatex` `which pdflatex`