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.

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?

share|improve this question
add comment

2 Answers

up vote 9 down vote accepted

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

share|improve this answer
    
Thanks for answering! Also thanks for using \addtokomafont, I hate having to figure out sizes and stuff :) –  Zsub Mar 26 '12 at 10:44
add comment

If you want to use pdf(la)tex you will have to generate the various support files needed: metrics .tfm, encoding files, font definition files, map files, perhaps virtual font files.

With xelatex/lualatex you can use the font directly:

\documentclass{scrreprt}
\usepackage{fontspec,color}
\setkomafont{subsection}{\color{red}\fontspec{Times New Roman}}
\begin{document}
\chapter{Abc}
\section{text}
\subsection{text}
\end{document}
share|improve this answer
    
Thanks for answering! –  Zsub Mar 26 '12 at 10:42
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.