XeTeXHow to globally assign fonts to elements of a given type, and to environments

Information and discussion about XeTeX, an alternative for pdfTeX based on e-Tex
Post Reply
crl
Posts: 4
Joined: Sat Jun 03, 2017 4:26 pm

How to globally assign fonts to elements of a given type, and to environments

Post by crl »

I'm thinking of moving from pdfLaTeX to XeLaTeX or LuaLaTex, and have read the users' part of the fontspec document and done a web search.

Possibly I've missed something, but couldn't find information or examples on how to assign, in the preamble, a font or a font family to all elements in a document of a given type, for example section names (titles), table contents or environments. To illustrate, I'd like to to use a sans serif font different from the main one for the chapter titles of a book.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

How to globally assign fonts to elements of a given type, and to environments

Post by Stefan Kottwitz »

That's independent of the engine (XeLaTeX or pdfLaTeX or LuaLaTeX). It's a style thing, so it depends on style files (.sty, packages) or the document class. Which one do you use? Modern classes, such as KOMA-Script classes, provide exactly this what you are looking for.

Stefan
LaTeX.org admin
crl
Posts: 4
Joined: Sat Jun 03, 2017 4:26 pm

How to globally assign fonts to elements of a given type, and to environments

Post by crl »

Thanks for your reply. Up till now I've used only the standard book and article classes (book for self-editing a friend's novels, article for scientific writing). In reaction to historical misuse of computing power, these deliberately encourage users to use only one font. KOMA-Script is new to me. There is a lot to read in the manual, but it answers my question, while giving sound advice on the legitimate use of a second font for headings. Modern fonts like Lato have many variants that should help even an amateur in obtaining a good balance.

On a related front, I've been rather ineptly trying to influence the approach of LibreOffice Writer to styles and immediate formatting (https://bugs.documentfoundation.org/sho ... i?id=90068). Recent developments in the LaTeX ecosystem might guide a much-needed modernisation of LO if the respective experts would indulge in a bit of cross-fertilisation. I think the most urgent priority here is to get each element of Writer that has a style (headings...) to scale automatically to the text body point size. This seems obvious to LaTeX users, but not, apparently, to the wierd world of wordprocessors.
Post Reply