Fonts & Character SetsSeparate Text and Math Fonts

Information and discussion about fonts and character sets (e.g. how to use language specific characters)
Post Reply
ers
Posts: 4
Joined: Mon Aug 23, 2010 7:14 am

Separate Text and Math Fonts

Post by ers »

This is probably (hopefully) a simple question, but how would I go about implementing two different fonts for my Latex documents? For example, how would I go about defining all text environment (typical paragraphs and the such) as the standard Times New Roman, while defining math symbols in any math environment as Euler VM?

Any hints, help or articles would be very appreciated! Thanks in advance!
Last edited by ers on Wed Aug 25, 2010 9:25 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Separate Text and Math Fonts

Post by frabjous »

For the particular combination you requested, you could do:

Code: Select all

\usepackage{eulervm}
\usepackage{tgtermes}
which would give you Euler in all math contexts, and Times (the TeX Gyre Termes version) outside of math contexts.

If you want to do things “like” this, but not this, probably the easiest things would be to switch to XeLaTeX and use the fontspec and mathspec and/or unicode-math packages, which make it really easy to switch regular and math fonts at will.
ers
Posts: 4
Joined: Mon Aug 23, 2010 7:14 am

Re: Separate Text and Math Fonts

Post by ers »

Thanks that was helpful! What I gather from your advice is that font packages should, in theory, only modify either text fonts or math fonts or both.

It seems that there are many font packages that modify both text and math environments. But let's suppose I only wanted the math modification but not the text modification. Are there any commands that can allow me to choose?

For example, CONCMATH changes both my math and text fonts to concrete. But what if I wanted to only change the math font and keep my text at the default Computer Modern Roman?

Thanks in advance, again!
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Separate Text and Math Fonts

Post by frabjous »

Packages tend to either apply just to text mode, or to both text and math mode, depending on the font. I don't really know how things "should" be. But using a package that applies to both, and then loading another package that just applies to text mode is one way, as with the combination above, to achieve what you're after. It helps if there is a text-mode-only package for your font, which sometimes there isn't.

You can always use “low level” font commands to change fonts rather than relying on packages, but using packages just tends to make things much easier. There's a summary of the basic font commands here:

http://tex.loria.fr/general/new/fntguide.html

Changing math fonts without using a package with regular latex/pdflatex is really really difficult. Changing the main text font isn't comparatively as hard. Probably if you wanted a unique combination, and didn't want to use XeLaTeX, my advice would be to load the package for the font, even if it applied to both modes, and then switch the text modes back afterwards.

For example, if you wanted Computer Modern as your text mode font, and something else (concmath or whatever) as your math mode font, I'd load the package for math mode, and then afterwards, put it:

Code: Select all

\renewcommand{\rmdefault}{cmr}
\renewcommand{\sfdefault}{cmss}
\renewcommand{\ttdefault}{cmtt}
Which should change the main text font back to Computer Modern. But it's easier and more failsafe to use packages when possible, especially because sometimes it's hard to figure out what the "Family name" is for LaTeX fonts (things like cmr for Computer Modern Roman, cmss for Computer Modern Sans Serif, etc.)
ers
Posts: 4
Joined: Mon Aug 23, 2010 7:14 am

Re: Separate Text and Math Fonts

Post by ers »

Again, very helpful. Your advice worked, but because the concrete package is lighter in contrast to CMR, when I convert text back to CMR it inherits the lighter font.

It sounds like I am better off investing time in learning XeTex or LuaTex.

Thanks!
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Re: Separate Text and Math Fonts

Post by frabjous »

With XeLaTeX, there's (almost) nothing to learn. It uses the same syntax as LaTeX. Heck, you could process the LaTeX files you already have with XeLaTeX without changing them beforehand. The only thing there would be to learn are the commands offered by specific packages like fontspec and mathspec.

I don't really understand what you mean about Computer Modern becoming "lighter" than normal. Perhaps this has something to do with the font encoding changing?
ers
Posts: 4
Joined: Mon Aug 23, 2010 7:14 am

Re: Separate Text and Math Fonts

Post by ers »

You were right, T1 fontenc encoding was degrading the quality of the PDF. Seems to look pretty good now that I changed that.

Thanks for all the help. Much appreciated!
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Separate Text and Math Fonts

Post by localghost »

Now that the problem is solved, please mark the topic accordingly as described in Section 3 of the Board Rules.


Best regards and welcome to the board
Thorsten
Post Reply