Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am trying to use system font for LaTeX. I am able to do it for text but not for the math part. Here is an example (compiled using XeLaTeX), where I use the font "Broadway", but it doesn't work for the math part. Any suggestion for how to define the font for the math part?

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}

\usepackage[xetex]{graphicx}
\usepackage{fontspec,xunicode}
\defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
\setmainfont[Scale=.95]{Broadway}
\setmonofont{Broadway}

\begin{document}
This is the formula for $(a+b)^2$
\begin{equation}
(a+b)^2=a^2+2ab+b^2
\end{equation}

\end{document} 

I found alternate ways from The LaTex Font Catalogue.

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}

\usepackage{concmath}
\usepackage[T1]{fontenc}

\begin{document}
This is the formula for $(a+b)^2$
\begin{equation}
(a+b)^2=a^2+2ab+b^2
\end{equation}

\end{document}

I was looking for typewritter font and "concmath" is a good one and also provides math support. But I am more interested in courier font which is also available in catalogue

\usepackage{courier}
\renewcommand*\ttdefault{lcmtt}
\renewcommand*\familydefault{\ttdefault}
\usepackage[T1]{fontenc}

But now the maths appears in Roman. Is there any possible way to make the math part use the courier font. I am not sure if it can be done by modifying the corresponding .sty file somehow or if there is any other better way. All I am trying to do is to make the math part use the same font (for the text part only, not for the symbol) as text without any italic or bold.

share|improve this question
4  
Never use inputenc with xetex. Beside this: You can use a textfont for some special chars in math, but textfonts can't be used to replace all math. Math fonts need much more internal structure. –  Ulrike Fischer Jan 30 '13 at 13:03
    
Thanks @UlrikeFischer. I don't have any good idea about the functionality of inputenc or utf. However I find an alternate way from The Latex Font Catalogue which may be helpful. I edited my post with what I have find. –  Sumit Jan 31 '13 at 8:18
    
Do you still use xelatex? Then - as I said - don't use inputenc. You should also avoid font packages meant for pdflatex, look for xelatex solutions. And no: courier too is a text font and you can't use it simply for math (beside the fact that it will look horrible. courier is a typewriter font). –  Ulrike Fischer Jan 31 '13 at 8:44
    
try with \usepackage[italic]{mathastext} in case you don't find some math font which fits with your text font. However, this is only for the Latin letters, so if you use XeLaTeX then go with mathspec as the first choice. (with mathastext the fontspec package must be loaded with option no-math) –  jfbu Jan 31 '13 at 9:31

1 Answer 1

Use mathspec package. Note however that most fonts include only Latin, Greek alphabets that can be used with mathspec. If you want the math fonts, alphabets and symbols alike, to be consistent, you need unicode-math package together with an OpenType fonts with MATH table. Such fonts are relatively rare, and the only font with complete Unicode coverage is XITS/STIX.


Basic usage of mathspec:

\usepackage{mathspec}
\setmainfont{Broadway}
\setmathsfont(Digits,Latin,Greek)[Numbers={Lining,Proportional}]{Broadway}

Several comments:

  • Do not load fontspec package. It will clash with mathspec.
  • Symbols not available in the text fonts will fall back to Computer Modern. If you like the operators provided by mnsymbol package, which is designed to work with Minion Pro, use the option \usepackage[MnSymbol]{mathspec}.

Basic usage of unicode-math:

This package is for fonts that contain an OpenType MATH table. Currently only these fonts are available:

The last one is recommended for its complete coverage and times-like appearance (most professional books use times-like fonts for math).

\usepackage{unicode-math}
\setmainfont{XITS}
\setmathfont{XITS Math}
\setmathfont[range={\mathcal,\mathbfcal},StylisticSet=1]{XITS Math}

The last line is only usable with XITS Math or STIX. It makes sure that \mathcal and \mathscr looks different and be consistent with looks in traditional TeX fonts.


Miscellaneous comments on your code:

  • Don't use inputenc with XeTeX or LuaTeX. The utf8 option of inputenc is a compilation of dirty hacks that implements a tiny fraction of Unicode while XeTeX natively suuports UTF-8 and UTF-16.
  • There is no need to specify xetex with graphicx package. In modern distributions it auto detects.
  • Your alternative solutions all utilize legacy code, like T1 fontenc, which should be avoided with xetex.
share|improve this answer
1  
Could you expand your answer with an example of how to use mathspec? –  egreg Jan 30 '13 at 13:52
    
@egreg: Just type texdoc mathspec in your terminal, and read the manual. –  C.R. Jan 30 '13 at 16:41
7  
I know how to do it; the OP might not. The more complete an answer is, the more helpful it is for future readers. –  egreg Jan 30 '13 at 16:45
    
@C.R. One of the reasons why providing as complete solution as possible is that then it is much easier to verify what the code does and suggest any improvements. We do it quite a lot (and even users with low reputation suggest improvements to codes of the top users, which they often gratefully accept). :) –  tohecz Jan 31 '13 at 8:15
    
@C.R. i read tex/sx for education; some things i grab for the faq. i happen to have the faq stuff about maths fonts under review atm, but hadn't thought of mathspec. an actual example of using mathspec would be very helpful for this "no longer mathematician" who no longer has his own maths to typeset... –  wasteofspace Jan 31 '13 at 9:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.