Text Formattingchanging font according to \normalfont?

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
snowfrog
Posts: 38
Joined: Wed Jan 06, 2010 8:11 pm

changing font according to \normalfont?

Post by snowfrog »

Hi,

I was testing the titlesec package and copied some code I found in the forum to see if it was working

Code: Select all

\titleformat{\chapter}[display]
{\normalfont\Large\color{white}\filcenter\sffamily}
{\titlerule[1pt]%
\vspace{1pt}%
\titlerule
\vspace{1pc}%
\LARGE\MakeUppercase{\chaptertitlename} \thechapter}
{1pc}
{\titlerule
\vspace{1pc}%
\Huge}
The font of the chapter's title using the example above is actually far nicer than the default one in my document class and I would like to use it for the text whole document. How can I do this? I'm guessing the \normalfont is responsible for the change in this font but I can't understand why and how to change it for the whole document.
Could anybody help please?

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

changing font according to \normalfont?

Post by frabjous »

The \normalfont there isn't doing anything but clear out previous font commands to make sure they don't affect the titles.

The change you like is probably the result of \sffamily, which changes it to sans serif.

Try \textsf{...} as a command, or \sffamily as a declaration.

If you want to typeset an entire document in a sans serif font, look at the options available in the LaTeX Font Catalogue.

The command:

\renewcommand*\familydefault{\sfdefault}

makes the document default to sans serif, however.
snowfrog
Posts: 38
Joined: Wed Jan 06, 2010 8:11 pm

changing font according to \normalfont?

Post by snowfrog »

Thanks frabjous, you guessed the right font.

I have had to use a combination of 2 of the commands you suggested:

Code: Select all

\renewcommand*\familydefault{\sfdefault}
changes the font of all my headings (i.e. \chapter, \section, \subsection etc} and using \sffamily as a declaration changes the font of the text.

I tried to find where the font is set in the *cls file (set by the University for a thesis) but I can't see anything recognisable. For future reference, could you point me to what kind of code I should look out for to identify where the font was set?
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

changing font according to \normalfont?

Post by frabjous »

What font are you getting otherwise?

If it's Computer Modern, it's entirely possible that your document class isn't setting this, but it's just using the default.

In any case, I'd advise against monkeying with the .cls file. I'd also advise talking with your University administrators about what fonts are allowed. I'd be very surprised if they allowed you to submit the final draft of your thesis in a sans serif font. The university where I submitted my thesis certainly wouldn't have allowed it.

They might allow you your choice of sober serif fonts (Computer/Latin Modern, Times, Palatino, etc.), however.

(Though of course it's harmless to stick with one one while composing and sharing with your committee and change afterwards.)
snowfrog
Posts: 38
Joined: Wed Jan 06, 2010 8:11 pm

changing font according to \normalfont?

Post by snowfrog »

I'd also advise talking with your University administrators about what fonts are allowed
Very wise frabjous...I have checked and I am indeed not allowed to use sans serif font for the text, but I have to for headings.

Thank you for all the info!
Post Reply