1

thanks for your help in advance. I was wondering how to use the mainfont type for some features in the math environment. For example, let's say I'm using "font A" which I've uploaded using some otf file for the text and for math environment I'm using default LaTeX math font. While font A doesn't have greek letters, I'd still like to use it for the math environment when feasible (for example, letters of the alphabet and words like "max," "lim," etc.) How can I get my math environment to use font A for this but default math environment for the items that aren't accounted for in font A?

(Disclaimer: I know people will say you shouldn't mess with fonts/math environments like this, and I generally agree, but choosing not to do something and not being able to do it are separate things--and I'd still like to know how!)

1 Answer 1

2

There is the mathastext package that does exactly this.

MWE:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Chilanka}
\usepackage{mathastext}
\begin{document}
Some regular text in the Chilanka font

\[\lim_{x\to\infty} f(x) \max(a,b,\Gamma)\]
\end{document}

Result:

enter image description here

Note that you should load the package after setting the main font otherwise the normal math font is used.

If you want the variable names etc. in italics (as in default math typesetting) then you can use the package option [italic]. Note that you need a font that actually has italic glyphs - most 'normal' fonts have italics but 'fancy' fonts (such as Chilanka) sometimes consist of only upright glyphs. In that case LaTeX will give a warning and the math will be typeset in the upright font.

MWE with a font that has italics and the [italic] option set:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Laksaman}
\usepackage[italic]{mathastext}
\begin{document}
Some regular text in the Laksaman font, \textit{which has italics}

\[\lim_{x\to\infty} f(x) \sqrt{\max(a,b,\Gamma)}\]
\end{document}

Result:

enter image description here

5
  • Very nice font Chilanka. Very compliment for your choice.
    – Sebastiano
    Aug 31, 2019 at 19:24
  • Hi, thanks for the help! Definitely a helpful start. Unfortunately it seems like what should be written in italic ("x", "f(x)", "a", and "b") aren't for some reason. I'll play around and if i figure anything else will post back. Any tips on this appreciated
    – makala
    Sep 2, 2019 at 4:56
  • Found this: jf.burnol.free.fr/v13/mathastext.pdf
    – makala
    Sep 2, 2019 at 5:17
  • @makala I've added an example with italic math.
    – Marijn
    Sep 2, 2019 at 6:00
  • @Marijn thanks!!!
    – makala
    Sep 2, 2019 at 18:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .