LyXChanging the font of chapter headings

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

Changing the font of chapter headings

Post by MarcAurel »

I want to change the font of all the chapters in a document I have prepared with the class "book". I could do this manually, but it would be tedious, and it would not change the heading of the table of contents. I figure there must be a simple command, maybe via "evil red text" that does this. Note that I don't want to do anything fancy like changing the font. I just want chapter headings to be in the default sans-serif font, while the text is in a serif font.

(I do not want to use any other document class because I prefer the output of "book" over KOMA script and Memoir.)

How do I do this?

Thanks a lot in advance!

Recommended reading 2024:

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

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

mas
Posts: 226
Joined: Thu Dec 04, 2008 4:39 am

Re: Changing the font of chapter headings

Post by mas »

Take a look at the titlesec package. Even the sectsty package will be useful.

Regards,

sridhar

OS: Debian/GNU Linux; LaTeX System : TeXLive; Editor : Vim
MarcAurel
Posts: 20
Joined: Tue Jul 07, 2009 1:33 pm

Re: Changing the font of chapter headings

Post by MarcAurel »

Thanks for your reply!

I have added the package "titlesec" to the document preamble, but then I have found that I would have to define all the attributes of the font all over again. (Also, three blank pages were inserted after the TOC, for reasons I cannot fathom.)

Is there no way to keep all the attributes of the document class "book" but just change the font the way I want?

Of course, there is a workaround:

1) creating two copies of the same document, one serif, one sans-serif
2) in the serif-document, change all chapter headings to sans serif, print to pdf
3) print the sans-serif document to pdf
4) open the pdf from the sans-serif document (with serif headings), and replace the TOC with the one from the sans-serif version

Obviously, this would be a bit tedious, but it would have been quicker than fiddling around with the LaTeX preamble for over an hour. :(
mas
Posts: 226
Joined: Thu Dec 04, 2008 4:39 am

Changing the font of chapter headings

Post by mas »

Here is what you can try for some fancy stuff :-)

Code: Select all

\documentclass[11pt]{report}
%
  \usepackage[english]{babel}
  \usepackage{blindtext}
  \usepackage{sectsty}
    \sectionfont{\sffamily\Large}
    \subsectionfont{\sffamily}
  
  \usepackage[Bjornstrup]{fncychap}
    \ChTitleVar{\raggedleft\LARGE\sffamily\bfseries}

\begin{document}
  \blinddocument
\end{document}

You can play around with the fncychap and get very good results.

Regards,

sridhar

OS: Debian/GNU Linux; LaTeX System : TeXLive; Editor : Vim
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Changing the font of chapter headings

Post by localghost »

A concrete example based on the suggestions of mas.

Code: Select all

\documentclass[11pt,a4paper,english]{book}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{babel}
\usepackage{sectsty}
\usepackage{blindtext}

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

\begin{document}
  \Blinddocument
\end{document}

Best regards and welcome to the board
Thorsten
MarcAurel
Posts: 20
Joined: Tue Jul 07, 2009 1:33 pm

Re: Changing the font of chapter headings

Post by MarcAurel »

Again, thanks for your help. I really appreciate it!
Post Reply