## LaTeX forum ⇒ Text Formatting ⇒ Changing/Defining Fonts for an Entire Document

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
c4onastick
Posts: 2
Joined: Thu Feb 12, 2009 1:34 am

### Changing/Defining Fonts for an Entire Document

Hi All,

I'm in the process of writing a large (100+ pages) technical/scientific document. Given the idiosyncrasy of Word's behavior with equations, figures, tables, etc. I am extremely hesitant to even attempt to write it in Word (plus LaTeX is just more fun!). However, I unfortunately do have to bend LaTeX to conform to the accepted standard Word format we have which means changing the fonts, sizes, spacing, etc.

I've been able to get close by Googling around, but I fear I'm adding more "band-aids" to the wound and not really solving the underlying problem. I realize that this will probably need to live in a new document class once completely tuned but I figured I'd post here for some help with the specifics. The transformation to a class can happen later.

Essentially, my question is this:
Where/how can one globally define the fonts (i.e. family, size, shape, etc.) for each of the environments used in a LaTeX document (i.e. global, sections, chapters, captions, etc.)?

Specifically, these are the issues I need to tackle (and my "band-aid" solutions thus far):
- Change the margins to match (unrelated, but included for future people that run across this post.)
- Change the default document font and attributes
- Solved with this in the document body:
`\fontencoding {T1}\fontfamily {phv}\fontseries {m}\fontshape {n}\fontsize {11pt} {19pt}\linespread {1}\selectfont`

- I'd like to set this globally (which might save some of the trouble I'm having below) tried this to no avail:
- Change the section fonts and sizes to match
- Solved with the "sectsty" package:
`\usepackage{sectsty}\sectionfont{\fontfamily{phv}\fontseries{b}\fontsize{11pt}{20pt}\selectfont}\subsectionfont{\fontfamily{phv}\fontseries{b}\fontsize{11pt}{20pt}\selectfont}\subsubsectionfont{\fontfamily{phv}\fontseries{b}\fontsize{11pt}{20pt}\selectfont}`
- This works with my previous fixes to the styles, but page numbers listed in the table are still in the default roman font. This is a nit-picky one, I could probably slip by with out it
- Change the Figure, Table, Equation captions fonts
- Got close with the "caption" package, but it again looks like I need to be able to set the "normalsize" and "sfdefault" variables:
`\usepackage[labelfont=bf,labelsep=period,font={bf,sf,normalsize}]{caption}`
- Change the font of tables' contents (i.e. the stuff in a table is still in the roman font, I'd need to have the font size a tiny bit smaller too.)
- Haven't found a solution to this yet...
- Change the font in the Bibliography or References section
- Haven't got here yet...
- Etc.

As you can see, it pretty much boils down to being able to define the font attributes used by each section. I haven't found the place where these are actually defined and what the best place to put these definitions is (looked through "article.cls" to no avail).

So all of this points to the question:
Where/how can one globally define the fonts (i.e. family, size, shape, etc.) for each of the environments used in a LaTeX document (i.e. global, sections, chapters, captions, etc.)?

I'd like to find the LaTeX equivalent of CSS for HTML, so I can essentially write:
`global {   fontfamily: pvh;   fontsize: 10pt 12pt;}section {   fontweight: b;   fontsize: 12pt;}...`

But I'm a little stuck on how and where to define that! Any insight you may have would be much appreciated! Thanks in advance!

kaiserkarl13
Posts: 620
Joined: Tue Mar 25, 2008 5:02 pm
You might need to redefine some other commands, in particular things like \sfdefault and \rmdefault. If you change \rmdefault, for example, by
`\renewcommand{\rmdefault}{phv}`

It will pick Helvetica as the default Roman font (the fact that it's not Roman is unimportant), and your section headings should automatically match your body text (no auxiliary packages required).

My suggestion is to issue

which will instead change the default family to Sans Serif (instead of pretending that Serif text is Sans Serif instead...).

I've never had occasion to redefine fonts without simply including a package, but my usual reference on the subject is
http://www.cl.cam.ac.uk/~rf10/pstex/latexcommands.htm

The packages pxfonts and txfonts do a lot with math-mode font changing, so you may look into that. Just reading through to see which defaults they redefine is helpful.

Good luck!

c4onastick
Posts: 2
Joined: Thu Feb 12, 2009 1:34 am

The second code listing you have there did the trick! Thank you! I wasn't able to find the correct syntax to redefine the default size on the link in your previous post though. Any thoughts there?

I still have to have:
`\fontsize{12pt}{20pt}\selectfont`

in the body of the document to get the proper spacing.

Thanks!

kaiserkarl13
Posts: 620
Joined: Tue Mar 25, 2008 5:02 pm
If you're looking for a default font size of 12pt, you may be able to simply say
`\documentclass[12pt]{book}`

or similar. This actually loads a file called size12.clo into the article and report classes or bk12.clo for the book class which redefines all the default sizes to be based on 12 points instead of 10.

However, the link I posted previously says you can use the same command you used (\fontsize) to change the default font size.