[Tex/LaTex] Set section and subsection header to ttf font in KOMA-script

fontsfontspeckoma-script

I'd like to set a custom font I acquired for all section and subsection headers in a scratcl paper I'm writing. It's a ttf and installed correctly on my Mac.

I know about \setkomafont and \addtokomafont, and I also have found the fontspec package, but all that seems to do is set the font for the entire document via \setmainfont, or for a section via \fontspec if I understand correctly.

I just can't seem to add one and one here, so to recap: how do I set (sub)section headers to a font installed on my Mac?

Best Answer

To use the system fonts you need to use xe(la)tex or lualatex instead of (pdf)latex. And with fontspec you can define a new family with \newfontfamily.

% I'm a UNICODE/UTF-8 encoded file!
\documentclass{scrartcl}

\usepackage{fontspec}
\newfontfamily\atfamily{American Typewriter}

\addtokomafont{disposition}{\atfamily}

% for testing
\usepackage{lipsum}

\begin{document}
\section{Test}
\subsection{Test}
\lipsum[1]
\end{document}

Save this file as UTF-8 file and compile it with xelatex then you’ll get this.

result

Related Question