I am typesetting documents with example code and I often typeset metasyntactical variables or text. For example :
In OCaml, one cannot assign values to variables like in Python
but one can bind the value of an expression \metasyn{expr} to
a variable \metasyn{v} and evaluate an expression with respect to it~:
\begin{lstlisting}
let $\metasyn{v}$ = $\metasyn{expr}$ in
$\metasyn{code to evaluate}$
\end{lstlisting}
I want to display the metasyntactic elements with the normal math font, but in text mode, as it may contain spaces and generally should not use the interletter spacing rules of math mode.
I have been using (for two days !) fontspec and unicode-math with XeLaTeX. I use Asana-Math as my math font and my current definition of \metasyn
is
\def\metasyn#1{\text{\fontspec{Asana-Math.otf}#1}}
But this sets the text to upright Asana-Math, not the math-italic glyphs. In other terms, how can I make $\metasyn{v}$
use the same glyph as $v$
while allowing for multiletter identifiers and multiple words to be typeset as I intend ?
I was previously using textit as with kpfonts, text mode italics and math glyphs look alike, but this is not the case anymore with Asana-Math and Gentium which I now intend to use.
mathit on the other hand does not respect spaces and is not affected by \setmathfont{Asana-Math.otf}
and looks like the default (Computer modern ?) math italics.
\documentclass
and ending with\end{document}
.