Fonts & Character SetsChange Fonts for particular Elements of a Document

Information and discussion about fonts and character sets (e.g. how to use language specific characters)
Post Reply
Kotoschow
Posts: 28
Joined: Mon Apr 09, 2012 3:13 pm

Change Fonts for particular Elements of a Document

Post by Kotoschow »

Hi,

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

Recommended reading 2024:

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

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

User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

Change Fonts for particular Elements of a Document

Post by Stefan Kottwitz »

Hi Kotoschow,

welcome to the board!
Kotoschow wrote:How can I change the fonts of non-prime texts? By that I mean page numbering, equations and date.
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 as

Code: Select all

\renewcommand*{\familydefault}{\sfdefault}
to get sans serif font by default. In most times, just load the font package, perhaps with options.

If you mean something specific, ask a specific question. Not just like "how to do all with fonts" ;-)
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?
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:

Code: Select all

\input{fonts}
With some more effort, you could make a .sty file and load that by \usepackage.

Stefan
LaTeX.org admin
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Change Fonts for particular Elements of a Document

Post by localghost »

Kotoschow wrote:[…] By that I mean page numbering, equations and date. […]
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:[…] 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? […]
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.


Best regards and welcome to the board
Thorsten
Kotoschow
Posts: 28
Joined: Mon Apr 09, 2012 3:13 pm

Change Fonts for particular Elements of a Document

Post by Kotoschow »

Stefan_K wrote:[..] if you actually mean you want to change the font of the text but also have effect on numbering etc., [..]
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: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
The problem is I don't know how to use .tex files.
localghost wrote:That is to say family, series or shape of a font. Or do you want a completely different font for those elements?
I want the font of everything I do to be Bera Sans of the Sans Serif family.
localghost wrote:Just use those settings in the preamble of all your documents.
How do I define font settings in the preamable?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

Change Fonts for particular Elements of a Document

Post by Stefan Kottwitz »

Kotoschow wrote:Where should I type the command you suggested?
In the document preamble, i.e. before \begin{document}.
Kotoschow wrote:And how is it possible to adjust the font obtained by this command (i.e. choose a different family, series, etc.)
In this case, I would redefine the macro \normalfont.
Kotoschow wrote:I want the font of everything I do to be Bera Sans of the Sans Serif family.
Here's an example, extending what I wrote above, specifically for Bera Sans Serif:

Code: Select all

\documentclass{article}
\usepackage[scaled]{berasans}
\renewcommand*\familydefault{\sfdefault}
\usepackage[T1]{fontenc}
\begin{document}
Text
\end{document}
Kotoschow wrote:The problem is I don't know how to use .tex files ... How do I define font settings in the preamable?
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.

Have a look at: LaTeX Resources for Beginners.

Stefan
LaTeX.org admin
Kotoschow
Posts: 28
Joined: Mon Apr 09, 2012 3:13 pm

Re: Change Fonts for particular Elements of a Document

Post by Kotoschow »

It's working! Absolutely fantastic, thanks!

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.
Post Reply