2012年11月22日星期四

Font Selection in Beamer and Normal Tex Files

When I was trying to figure out how to change the font for the complete beamer presentation, I found the following two commands in the Manhattan Beamer Theme:

\renewcommand\sfdefault{phv}
\renewcommand\familydefault{\sfdefault}

Basically they give a new meaning for "\sfdefault" and "\familydefault" respectively. As a result, both "\sfdefault" and "\familydefault" are set to "phv".

I tried to eliminate the second command while keep the first one, the font in the beamer would be changed as well, however, not the other way around. On the other hand, for a normal LaTex article, only the second command by itself will change the font for the whole document, but not the first.

So what is "\sfdefault", "\familydefault", why do they have different effect for beamer and normal article? And what does "phv" stand for?

After searching for LaTex font setting online, I realized the font system is more complicated than I expected. There are essentially five attributes for fonts in LaTex: encoding, family, series, shape, and size. "phv" is a value for the family attribute, which denotes Adobe Helvetica, further details can refer to the references I put at the end.

As to "\sfdefault", actually there are two other commands in a kit: "\rmdefault" and "\ttdefault". In the above kit, “sf” stands for serif, "rm" stands for roman, and "tt" stands for typerwriter. Three of them also have corresponding commands respectively:
"\textsf", "\textrm" and "\texttt". So normally when we choose a template, the font families for "\textsf", "\textrm" and "\texttt" are already predefined when the template is fixed. So using "\renewcommand" is just to update the original value for each case. "\familydefault" is another macro denoting the system default font for the complete document. Hence, for instance, after using the following command:

\renewcommand\ttdefault{phv}

all texts covered by the "\texttt" will have the "phv" font.

The reason why "\renewcommand\sfdefault{phv}" changes the font for beamer but not normal article is because beamer use the value of "\sfdefault" for "\familydefault", while normal article use the value of  "\sfdefault" for "\familydefault". Therefore, only "\renewcommand\sfdefault{phv}" is enough to change font for beamer, only "\renewcommand\rmdefault{phv}" is also enough for normal article.



Reference:
http://www.latex-project.org/guides/fntguide.pdf

http://www.tug.org/pracjourn/2006-1/schmidt/schmidt.pdf

没有评论:

发表评论