Fonts & Character Sets ⇒ Change Fonts for particular Elements of a Document
Change Fonts for particular Elements of a Document
I had some hard time managing fonts. How can I change the fonts of non-prime texts? By that I mean page numbering, equations and date. Additionaly, when I change my fonts I want the changes to persist. How can I set my preferences so that every document I open from now on will automatically have the fonts I choose and not the default fonts?
Thanks a lot
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
- Stefan Kottwitz
- Site Admin
- Posts: 10324
- Joined: Mon Mar 10, 2008 9:44 pm
Change Fonts for particular Elements of a Document
welcome to the board!
It depends on the special case, if you need a different font for each. But if you actually mean you want to change the font of the text but also have effect on numbering etc., redefine the default font used, such asKotoschow wrote:How can I change the fonts of non-prime texts? By that I mean page numbering, equations and date.
Code: Select all
\renewcommand*{\familydefault}{\sfdefault}
If you mean something specific, ask a specific question. Not just like "how to do all with fonts"

You can write all your font settings in a separateKotoschow wrote: Additionaly, when I change my fonts I want the changes to persist. How can I set my preferences so that every document I open from now on will automatically have the fonts I choose and not the default fonts?
.tex
file, let's say fonts.tex
, and include it within the preamble of your documents by \input
:Code: Select all
\input{fonts}
.sty
file and load that by \usepackage
.Stefan
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Change Fonts for particular Elements of a Document
The respective counters can be formatted accordingly by redefinition. But first you should clarify what you exactly want to change. That is to say family, series or shape of a font. Or do you want a completely different font for those elements?Kotoschow wrote:[…] By that I mean page numbering, equations and date. […]
Just use those settings in the preamble of all your documents. You could also put them into an own small package (*.sty) and place it where it can be found by the compiler.Kotoschow wrote:[…] Additionaly, when I change my fonts I want the changes to persist. How can I set my preferences so that every document I open from now on will automatically have the fonts I choose and not the default fonts? […]
Best regards and welcome to the board
Thorsten
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Change Fonts for particular Elements of a Document
Yes, that' what I meant. Where should I type the command you suggested? And how is it possible to adjust the font obtained by this command (i.e. choose a different family, series, etc.)Stefan_K wrote:[..] if you actually mean you want to change the font of the text but also have effect on numbering etc., [..]
The problem is I don't know how to use .tex files.Stefan_K wrote:You can write all your font settings in a separate .tex file, let's say fonts.tex, and include it within the preamble of your documents by \input
I want the font of everything I do to be Bera Sans of the Sans Serif family.localghost wrote:That is to say family, series or shape of a font. Or do you want a completely different font for those elements?
How do I define font settings in the preamable?localghost wrote:Just use those settings in the preamble of all your documents.
- Stefan Kottwitz
- Site Admin
- Posts: 10324
- Joined: Mon Mar 10, 2008 9:44 pm
Change Fonts for particular Elements of a Document
In the document preamble, i.e. beforeKotoschow wrote:Where should I type the command you suggested?
\begin{document}
.In this case, I would redefine the macroKotoschow wrote:And how is it possible to adjust the font obtained by this command (i.e. choose a different family, series, etc.)
\normalfont
.Here's an example, extending what I wrote above, specifically for Bera Sans Serif:Kotoschow wrote:I want the font of everything I do to be Bera Sans of the Sans Serif family.
Code: Select all
\documentclass{article}
\usepackage[scaled]{berasans}
\renewcommand*\familydefault{\sfdefault}
\usepackage[T1]{fontenc}
\begin{document}
Text
\end{document}
I recommend to read a LaTeX introduction, to learn some basics. If you have specific questions or problems then, you still could ask here. But it's hard to answer such a vague general question without writing a complete introduction.Kotoschow wrote:The problem is I don't know how to use .tex files ... How do I define font settings in the preamable?
Have a look at: LaTeX Resources for Beginners.
Stefan
Re: Change Fonts for particular Elements of a Document
It's not such a vague question, what I meant to ask is exactly what you answered. But I think I'll take your suggestion to read the LyX introduction before I try things like this.