LaTeX forum ⇒ Text FormattingChanging/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

Postby c4onastick » Thu Feb 12, 2009 8:21 pm

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
    - Change the section fonts and sizes to match
      - Solved with the "sectsty" package:
      1. \usepackage{sectsty}
      2. \sectionfont{\fontfamily{phv}\fontseries{b}\fontsize{11pt}{20pt}\selectfont}
      3. \subsectionfont{\fontfamily{phv}\fontseries{b}\fontsize{11pt}{20pt}\selectfont}
      4. \subsubsectionfont{\fontfamily{phv}\fontseries{b}\fontsize{11pt}{20pt}\selectfont}
    - Change the Table of Contents name from "Contents" to "Table of Contents" (again unrelated, but included for completeness)
    - Change the Table of Contents font to match the rest of the document
      - 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:
      1. \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:
  1. global {
  2. fontfamily: pvh;
  3. fontsize: 10pt 12pt;
  4. }
  5. section {
  6. fontweight: b;
  7. fontsize: 12pt;
  8. }
  9. ...

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: 593
Joined: Tue Mar 25, 2008 5:02 pm

Postby kaiserkarl13 » Sat Feb 14, 2009 7:05 pm

You might need to redefine some other commands, in particular things like \sfdefault and \rmdefault. If you change \rmdefault, for example, by
  1. \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
  1. \renewcommand{\sfdefault}{phv}
  2. \renewcommand{\familydefault}{\sfdefault}

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

Postby c4onastick » Mon Feb 16, 2009 9:28 pm

Thanks for the reply kaiserkarl13.

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:
  1. \fontsize{12pt}{20pt}
  2. \selectfont

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

Thanks!

kaiserkarl13
Posts: 593
Joined: Tue Mar 25, 2008 5:02 pm

Postby kaiserkarl13 » Fri Feb 20, 2009 9:20 pm

If you're looking for a default font size of 12pt, you may be able to simply say
  1. \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.


Return to “Text Formatting”

Who is online

Users browsing this forum: Google [Bot] and 5 guests