2013年10月26日星期六

Change the Font for Your LaTeX Document

Sometimes, it is relatively easy and intuitive to determine which PDF file is created by LaTeX, due its distinct trademark font by default, which is quite different from other popular editors such as MS Office. However, LaTeX, as a professional editor, also supports various font setting. However, it is slightly more complicated than the WYSIWYG editors.

A detailed introduction to the LaTeX font system could refer to the first reference below. Basically, it is recommended that a single document should apply a uniform font, simply because that is more formal and beautiful. Thus, what we have to modify is actually the so-called "the font family".

The fonts could be systematically grouped into three main categories: roman (rm) or serif, sans serif (sf) and monospace (tt). For each category, LaTeX provides a default font, Computer Modern Roman, Computer Modern Sans Serif, and Computer Modern Typewritter, respectively. Further more, we can use the following three variables to refer to each of them:



  • \rmdefault
  • \sfdefault
  • \ttdefault
If not specification is made, the system will apply the serif or default roman font (rm), namely the Computer Modern. If we want to change it into the default sans serif (sf), namely Computer Modern Sans Serif, or the default monospace (tt), namely Computer Modern Sans Typewriter, we can use the following commands:

\renewcommand*{\familydefault}{\sfdefault}

\renewcommand*{\familydefault}{\ttdefault}

Besides the three default font families, LaTeX also provides some pre-installed font families, such as Palatino (ppl), Times (ptm), Helvetica (phv), Courier (pcr), etc. In principle, if the specific font belongs to the "rm" category, we just need to use the following command:

\renewcommand*\rmdefault{ppl}

Otherwise, we will have to first modify the system default font family category to "sf" or "tt" with the already mentioned commands respectively, then specify the particular font in a similar way:

\renewcommand*\sfdefault{pbk}

\renewcommand*\ttdefault{pcr} 


Or if you do not want to be so disciplined, you can just assign the particular font family to the system default roman font, namely:

\renewcommand*\rmdefault{pbk}


Please note that only abbreviations are accepted. For a complete list of pre-installed font families and their abbreviations, refer to the last reference.




Reference:

http://en.wikibooks.org/wiki/LaTeX/Fonts
http://www.tug.dk/FontCatalogue/
http://www.macfreek.nl/memory/Fonts_in_LaTeX

没有评论:

发表评论