6

I try to load exactly one symbol from an OpenType Font file and use it in a math environment. However, it seems to me, that I can only use the symbol in "normal" text but not in math mode. Here is a minimal example:

\documentclass{article}

\usepackage{fontspec}
\usepackage{unicode-math}

\setmainfont{Latin Modern Roman}
\setmathfont{Latin Modern Math}
\newfontfamily\foo{Untitled1.otf}

\newcommand{\foobar}{\foo\symbol{1}}

\begin{document}
\foobar
\[x \foobar y\]
\end{document}

In normal text the symbol appears but in math mode it does not. Do I have to use some special command to load a symbol for a math environment?

Or the other way arround. How could I typeset a formula where the first part of the formula is typed in font A and the second part in font B (where A != B)?

Update

The question aims at the following problem. I created a new symbol which is not known to be available in Unicode. Therefore I created a new one and saved in the file Untitled1.otf. Now I want to load this symbol into my document and use it in math formulas. Since the symbol is not known in unicode I cannot use a "standard" symbol to refer to it. Therefore, I thought to use a command and reference the symbol by its index of the OTF file.

1
  • Would it be an option to create a PDF with the symbol and say something like \newcommand{\foobar}{\includegraphics{mysymbol}}?
    – egreg
    Commented Mar 31, 2012 at 13:35

2 Answers 2

4

Just for one symbol, it's probably not worth going through the math setup, just define it as

\newcommand{\foobar}{\text{\foo\symbol{1}}}

so it'll work in math mode using the text font setup. (If you need it to get smaller in subscripts, load amsmath which will define \text to do that).

3

in this example the first 1 is taken from Latin modern math and all the other from XITS Math:

\documentclass{article}
\usepackage{unicode-math}

\setmainfont{Latin Modern Roman}
\setmathfont{XITS Math}

\begin{document}
{\setmathfont[range="0031]{Latin Modern Math}
\[x 1 y\] }
\[x 1 y\]
\end{document}

another example:

\documentclass{article}
\usepackage{unicode-math}

\setmainfont{Latin Modern Roman}
\setmathfont[version=XITS]{XITS Math}
\setmathfont[version=LMM]{Latin Modern Math}
\begin{document}
\mathversion{XITS}
\[x \mbox{\mathversion{LMM}$1$} y\] 
\[x 1 y\]
\end{document}
10
  • But how do you then typeset a formula where you want the number 1 typeset one time in Latin Modern Math and the other time in XITS Math? My question aims at the following problem. I created a new symbol which I then want to load into my document. Since this is not a standard/known symbol I cannot refer to it via a standard/printable symbol. I will update my question regarding this information.
    – Stefan
    Commented Mar 31, 2012 at 13:20
  • see edit of my answer
    – user2478
    Commented Mar 31, 2012 at 13:43
  • But then I cannot typeset $1 1$ anymore where the first one is typeset in Latin Modern and the second one is typeset in XITS. Again this all goes back to the problem that I want to define a new operator symbol such that I can write a \fancynewop b where \fancynewop should be a symbol out of an OTF file Untitled1.otf.
    – Stefan
    Commented Mar 31, 2012 at 15:11
  • @Stefan: I don't see why you want the same symbol to be taken from different fonts in the same formula, why don't you give your new symbol a unique code point in the private use area and simplify the issue. Commented Mar 31, 2012 at 15:26
  • @Stefan: see 2nd example in my answer
    – user2478
    Commented Mar 31, 2012 at 15:33

You must log in to answer this question.

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