2

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?)

6
  • ln `which xelatex` `which pdflatex` Commented Jun 27, 2015 at 4:21
  • @SeanAllred Why?
    – cfr
    Commented Jun 27, 2015 at 12:55
  • @cfr Sorry about that – that kind of snark was the effect of two-years-expired cough syrup that I unwittingly took… My point was that there is little reason that I can think of to stick to pdftex especially when you want to do fancy things with your fonts. Commented Jun 27, 2015 at 14:31
  • @SeanAllred I don't really agree, but my main point was that it wouldn't even work.
    – cfr
    Commented Jun 27, 2015 at 16:13
  • 1
    @SeanAllred I don't use other engines, since then I'll learn features I can't use when submitting to journals. If I only ever use PDFlatex I won't have that problem.
    – Canageek
    Commented Jun 27, 2015 at 18:21

2 Answers 2

5

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.

2
  • I suggest you broaden you answer by giving some code.
    – Sveinung
    Commented Jun 27, 2015 at 7:46
  • The OP made a rather broad question, so the broad general answer.
    – jarnosz
    Commented Jun 27, 2015 at 19:49
4

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.

canageekTitleFonts

\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}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .