Text Formattingchange font type of chapters' and section's title

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
len
Posts: 2
Joined: Thu Dec 30, 2010 1:23 am

change font type of chapters' and section's title

Post by len »

Hi,

I am trying to create a document template (using report) in which I would like to use a font for the text (epigrafica in my case) and another one for the titles (tgschola).

I inserted in the preamble the following code:

Code: Select all

\usepackage{titlesec}
\usepackage[LGR,OT1]{fontenc}
\usepackage{epigrafica}
.
.
.
\makeatletter
\renewcommand{\@makechapterhead}[1]{%
\vspace*{50 pt}%
{\setlength{\parindent}{0pt} \raggedright \bfseries\LARGE
\color{royalblue} {\thechapter.\ #1\par\nobreak\vspace{20 pt}}}}
\makeatother

\titleformat{\section}{\color{royalblue}\bfseries\Large}{\thesection}{1em}{}
The code creates a custom title chapter, and the color used is a custom color.
If I compile this code everything works fine, and the code used for everything is the "epigrafica".
I tried several ways to specify that I wanted to use "tgschola" for my titles, but up to now no success...
Can anyone suggest me any solution?

Thanks 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.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

change font type of chapters' and section's title

Post by frabjous »

Putting in \fontfamily{qcs}\selectfont in the right places should do the trick.

(qcs is the berry family name for TeX Gyre Schola -- don't ask me why.)

Code: Select all

\documentclass{report}
\usepackage{xcolor}
\usepackage{titlesec}
\usepackage[LGR,OT1]{fontenc}
\usepackage{epigrafica}

\makeatletter
\renewcommand{\@makechapterhead}[1]{%
\vspace*{50 pt}%
{\setlength{\parindent}{0pt} \raggedright \fontfamily{qcs}\selectfont\bfseries\LARGE
\color{blue} {\thechapter.\ #1\par\nobreak\vspace{20 pt}}}}
\makeatother

\titleformat{\section}{\color{blue}\fontfamily{qcs}\selectfont\bfseries\Large}{\thesection}{1em}{}


\begin{document}

\chapter{Chapter Heading}

Some text. 

\section{Section Heading}

Some more text.

\end{document}
I'm a bit curious why you use titlesec commands for editing the section titles, but do a more direct method for editing the chapter titles, but be that as it may...

Oh I changed the color just to "blue" while testing since I didn't know your definition of your royalblue. Obviously, you can change this back.
len
Posts: 2
Joined: Thu Dec 30, 2010 1:23 am

Re: change font type of chapters' and section's title

Post by len »

Thanks a lot!

I had tried something like that, but I guess the problem was in the name I was putting instead of "qcs".

I used titlesec commands because I found this solution on the web and it worked fine (I am not really an expert with Latex...)
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

change font type of chapters' and section's title

Post by localghost »

If the problem is solved with that, please be so kind and mark the topic (not the last post) accordingly as clearly written in the Board Rules (to be read before posting). Otherwise please tell us what is missing. Please keep that in mind for the future so that further reminders will not be necessary.


Best regards and welcome to the board
Thorsten
Post Reply