LyXHow do I change the font for sections?

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Post Reply
MarcAurel
Posts: 20
Joined: Tue Jul 07, 2009 1:33 pm

How do I change the font for sections?

Post by MarcAurel »

The code is below.

Thanks to the great help I have received at this forum I could solve all my remaining problems except one, but this is just a minor point. I was able to set a bold font for the headings, but the same font looks a bit too heavy for the sections.

What is the right command? I did some research but found it a bit too confusing.

What I am looking for is a command that allows me to use "Gill Sans Std - Extra Bold" for just the section titles.

Any help is greatly appreciated!

Code: Select all

\date{}

\usepackage{sectsty}
\usepackage{blindtext}
\usepackage{lettrine}

% Headings setup (sectsty)
\allsectionsfont{\sffamily}


\@ifundefined{XeTeXversion}{}{%
\usepackage{fontspec}%

\defaultfontfeatures{Scale=MatchLowercase,Mapping=tex-text}

\setromanfont{Minion Pro}%
\setromanfont[Ligatures={Common}, Numbers={OldStyle}]{Minion Pro}

\setsansfont{Gill Sans Std}%
\setsansfont [BoldFont={Gill Sans Std-Ultra Bold}]{Gill Sans Std}

\setmonofont{Courier New}%

}%
\usepackage{xunicode} 
\usepackage{xltxtra} 

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

How do I change the font for sections?

Post by meho_r »

As I mentioned before, you may use titlesec package for finer control over typesetting sectioning parts of a document. I don't own Gill Sans font so I cannot demonstrate with it, but I'll try to give you an idea with Myriad Pro font instead. Here's an example:

Code: Select all

\documentclass[english]{book}
\usepackage{babel}
\usepackage{blindtext}

%%% XeLaTeX %%%
\usepackage{fontspec}
\usepackage{xltxtra}
\usepackage{xunicode}

\setmainfont{Minion Pro}
\newfontfamily\secfont{Myriad Pro Bold}% font for using with titlesec below; here you'll want to use Gill Sans

%%% Titlesec %%%
\usepackage{titlesec}
\titleformat*{\section}{\secfont\Large}% this is most basic way; for more advanced settings consult titlesec manual; btw, no chapter formatting is allowed with this "easy" way, only with advanced formatting

\titleformat*{\subsection}{\secfont\itshape}

\begin{document}
\blinddocument
\end{document}
MarcAurel
Posts: 20
Joined: Tue Jul 07, 2009 1:33 pm

Re: How do I change the font for sections?

Post by MarcAurel »

Thanks for your reply! I needed more time to get familiar with the titlesec package.
Post Reply