2

I'm making a style package for my student union, changing to our official fonts and adding other convenience methods. I've declared a main (serif) font and a title (sans) font family, and I want to use titlesec to make the title and section headers use \titlefont, but in order to change only the font I need to know what the defaults are. That is, what would the titlesec commands to produce the original look and feel be?

I use XeLaTeX.

2
  • Which document class do you use? Which font size?
    – Bernard
    Sep 21, 2014 at 17:25
  • @Bernard Article, default font size. I figured the native header settings would be relative.
    – Gustaphe
    Sep 21, 2014 at 19:01

1 Answer 1

3

You don't need to reset everything to do this if all you want is to use your sans serif font as the titling font. You can just set your sans font with fontspec and then pass the [sf] option to titlesec. If you also want to change the title formatting you will need to load the titling package, which provides simple hooks for doing so.

If you do want to set the font separately using titlesec, §9.2 of the titlesec documentation gives the exact format for the standard classes.

In the following example I've combined both methods to show the possibilities. I've chosen a silly font for the title just for illustrative purposes.

% !TEX TS-program = XeLaTeX
\documentclass{article}
\usepackage{fontspec}
\setmainfont{Linux Libertine O}
\setsansfont{Linux Biolinum O}
\newfontfamily\mytitlefont{TeX Gyre Chorus}
\usepackage{titling}
\renewcommand\maketitlehooka{\mytitlefont}
\usepackage[sf]{titlesec}
\titleformat*{\section}{\Large\mytitlefont}
\title{A title}
\author{An author}
\begin{document}
\maketitle
\section{A section}
Some text.
\subsection{A subsection}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.