Fonts & Character SetsChanging math fonts

Information and discussion about fonts and character sets (e.g. how to use language specific characters)
Post Reply
mellon
Posts: 2
Joined: Wed Jul 21, 2010 11:24 pm

Changing math fonts

Post by mellon »

Currently, in my LaTeX documents, I'm using two difference fonts: one for the text and another for math equations. I would like to know if there is any way to use my text font (the italic form) in the math equations and keeping save all the other math symbols.

Thank you.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Changing math fonts

Post by frabjous »

What font is it? How did you install it?

Anyway, you might look at the mathspec package for XeLaTeX, which makes it kind of easy for using an arbitrary font for the letters in math mode, while keeping the usual symbol (The Unicode math package provides even greater flexibility, but may not quite be ready for every day use.) But that’s only if you’re using XeLaTeX.

If using regular pdfLaTeX or LaTeX, and there isn't already a math package for the font, it gets trickier.
mellon
Posts: 2
Joined: Wed Jul 21, 2010 11:24 pm

Re: Changing math fonts

Post by mellon »

I use pdflatex and I have installed Bembo as a text font and MathTime 2 Lite as math font. I'm quite happy with this combination but I was wondering if would be possible to use Bembo Italic font in math equations (instead of MathTime one). That is just because if like very much Bembo Italic font and it will fit very well in math mode.

Can it be done without using XeTeX??


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

Changing math fonts

Post by frabjous »

It’s certainly a lot easier if you’re using XeTeX.

I was, however, experimenting with how it might be done with regular pdfLaTeX the other day. I had meant to experiment with it more and tweak my results, but I was able to make the normal variables for the letters A-Z a-z appear in the font (italics), and the numerals 0-9 similarly (no italics), keeping Computer Modern for all the other symbols. I had wanted to keep experimenting to get things like Greek letters, etc., working too, but hadn’t made it that far. Maybe someone else will know. (I’m no expert about this, and probably should have asked myself, but sometimes I like to learn by trying.)

To do this, you need to know the font family name (usually a three-letter "Berry" abbreviation) of the font you want to use, and the encoding it’s using. What these would be for Bembo depends on how you installed it, which is actually why I asked. (You didn’t say.)

In my example, I’m using T1 encoding for the “Baservald ADF” font, font-family ybv, which just recently appeared on CTAN. It would be up to you to make the necessary adjustments to get Bembo instead. You'll see {T1}{ybv} appear four times. You’d need to change it everywhere to whatever the appropriate thing would be for Bembo.

It's already a bit involved. I don't know whether or not there would be a way of shortening this. Obviously, the important part is where the comment says “experiment”.

Code: Select all

\documentclass[12pt]{article}
\usepackage{baskervald}
\usepackage[english]{babel}
\usepackage{blindtext}


% ------------------------ experiment -----------------------
\DeclareSymbolFont{mymathvariables}{T1}{ybv}{m}{it}
\SetSymbolFont{mymathvariables}{normal}{T1}{ybv}{m}{it}
\DeclareSymbolFontAlphabet{\mathnormal}{mymathvariables}

\DeclareMathSymbol{a}{\mathalpha}{mymathvariables}{`a}
\DeclareMathSymbol{b}{\mathalpha}{mymathvariables}{`b}
\DeclareMathSymbol{c}{\mathalpha}{mymathvariables}{`c}
\DeclareMathSymbol{d}{\mathalpha}{mymathvariables}{`d}
\DeclareMathSymbol{e}{\mathalpha}{mymathvariables}{`e}
\DeclareMathSymbol{f}{\mathalpha}{mymathvariables}{`f}
\DeclareMathSymbol{g}{\mathalpha}{mymathvariables}{`g}
\DeclareMathSymbol{h}{\mathalpha}{mymathvariables}{`h}
\DeclareMathSymbol{i}{\mathalpha}{mymathvariables}{`i}
\DeclareMathSymbol{j}{\mathalpha}{mymathvariables}{`j}
\DeclareMathSymbol{k}{\mathalpha}{mymathvariables}{`k}
\DeclareMathSymbol{l}{\mathalpha}{mymathvariables}{`l}
\DeclareMathSymbol{m}{\mathalpha}{mymathvariables}{`m}
\DeclareMathSymbol{n}{\mathalpha}{mymathvariables}{`n}
\DeclareMathSymbol{o}{\mathalpha}{mymathvariables}{`o}
\DeclareMathSymbol{p}{\mathalpha}{mymathvariables}{`p}
\DeclareMathSymbol{q}{\mathalpha}{mymathvariables}{`q}
\DeclareMathSymbol{r}{\mathalpha}{mymathvariables}{`r}
\DeclareMathSymbol{s}{\mathalpha}{mymathvariables}{`s}
\DeclareMathSymbol{t}{\mathalpha}{mymathvariables}{`t}
\DeclareMathSymbol{u}{\mathalpha}{mymathvariables}{`u}
\DeclareMathSymbol{v}{\mathalpha}{mymathvariables}{`v}
\DeclareMathSymbol{w}{\mathalpha}{mymathvariables}{`w}
\DeclareMathSymbol{x}{\mathalpha}{mymathvariables}{`x}
\DeclareMathSymbol{y}{\mathalpha}{mymathvariables}{`y}
\DeclareMathSymbol{z}{\mathalpha}{mymathvariables}{`z}

\DeclareMathSymbol{A}{\mathalpha}{mymathvariables}{`A}
\DeclareMathSymbol{B}{\mathalpha}{mymathvariables}{`B}
\DeclareMathSymbol{C}{\mathalpha}{mymathvariables}{`C}
\DeclareMathSymbol{D}{\mathalpha}{mymathvariables}{`D}
\DeclareMathSymbol{E}{\mathalpha}{mymathvariables}{`E}
\DeclareMathSymbol{F}{\mathalpha}{mymathvariables}{`F}
\DeclareMathSymbol{G}{\mathalpha}{mymathvariables}{`G}
\DeclareMathSymbol{H}{\mathalpha}{mymathvariables}{`H}
\DeclareMathSymbol{I}{\mathalpha}{mymathvariables}{`I}
\DeclareMathSymbol{J}{\mathalpha}{mymathvariables}{`J}
\DeclareMathSymbol{K}{\mathalpha}{mymathvariables}{`K}
\DeclareMathSymbol{L}{\mathalpha}{mymathvariables}{`L}
\DeclareMathSymbol{M}{\mathalpha}{mymathvariables}{`M}
\DeclareMathSymbol{N}{\mathalpha}{mymathvariables}{`N}
\DeclareMathSymbol{O}{\mathalpha}{mymathvariables}{`O}
\DeclareMathSymbol{P}{\mathalpha}{mymathvariables}{`P}
\DeclareMathSymbol{Q}{\mathalpha}{mymathvariables}{`Q}
\DeclareMathSymbol{R}{\mathalpha}{mymathvariables}{`R}
\DeclareMathSymbol{S}{\mathalpha}{mymathvariables}{`S}
\DeclareMathSymbol{T}{\mathalpha}{mymathvariables}{`T}
\DeclareMathSymbol{U}{\mathalpha}{mymathvariables}{`U}
\DeclareMathSymbol{V}{\mathalpha}{mymathvariables}{`V}
\DeclareMathSymbol{W}{\mathalpha}{mymathvariables}{`W}
\DeclareMathSymbol{X}{\mathalpha}{mymathvariables}{`X}
\DeclareMathSymbol{Y}{\mathalpha}{mymathvariables}{`Y}
\DeclareMathSymbol{Z}{\mathalpha}{mymathvariables}{`Z}

\DeclareSymbolFont{mymathnumerals}{T1}{ybv}{m}{n}
\SetSymbolFont{mymathnumerals}{normal}{T1}{ybv}{m}{n}
\DeclareSymbolFontAlphabet{\mathnormal}{mymathnumerals}

\DeclareMathSymbol{0}{\mathalpha}{mymathnumerals}{`0}
\DeclareMathSymbol{1}{\mathalpha}{mymathnumerals}{`1}
\DeclareMathSymbol{2}{\mathalpha}{mymathnumerals}{`2}
\DeclareMathSymbol{3}{\mathalpha}{mymathnumerals}{`3}
\DeclareMathSymbol{4}{\mathalpha}{mymathnumerals}{`4}
\DeclareMathSymbol{5}{\mathalpha}{mymathnumerals}{`5}
\DeclareMathSymbol{6}{\mathalpha}{mymathnumerals}{`6}
\DeclareMathSymbol{7}{\mathalpha}{mymathnumerals}{`7}
\DeclareMathSymbol{8}{\mathalpha}{mymathnumerals}{`8}
\DeclareMathSymbol{9}{\mathalpha}{mymathnumerals}{`9}
% ------------------------------------ experiment ---------------

\begin{document}

\blindmathpaper

\end{document}
justinkearns
Posts: 7
Joined: Sat Sep 05, 2009 5:16 am

Re: Changing math fonts

Post by justinkearns »

Post Reply