3

This should be easy. But it's not easy to find. MWE:

% !TeX program = LuaLaTeX
% !TeX encoding = UTF-8
\documentclass{article}
\usepackage[no-math]{fontspec}
\usepackage{unicode-math}
\begin{document}
\rmdefault\par
\sfdefault\par
\ttdefault\par
% What prints the math default font(s)? Expecting lmm.
\end{document}

Above prints lmr, lmss, lmtt for the three text fonts. Good.

I would like the document to print the name(s) of the default math font. If necessary I can enter and exit math mode for the command, but I do not actually need to use the math font there. And, I'm not interested in looking in the PDF for its list of fonts. I know what the math font is. Getting its name to print in the document, is the question.

4
  • 1
    math uses (without unicode math) a number of fonts, so your question doesn't make much sense. Feb 17, 2017 at 19:23
  • @UlrikeFischer Perhaps MWE is too minimal! Actual purpose of my question: I wish to know whether the \setmathfont command was used, without hacking the code for that command. I can do this for \setmainfont by string comparison of \rmdefault to lmr.
    – user103221
    Feb 17, 2017 at 19:27
  • 1
    Your question still isn't clear even after the comments, \setmathfont isn't even defined unless unicode-math has been used, so clearly not been used in that case (and if uniocde-math is loaded then the default fonts are changed to latin modern math) Feb 17, 2017 at 19:50
  • @DavidCarlisle Oops. My MWE was too minimal. I am indeed using unicode-math. Will modify MWE.
    – user103221
    Feb 17, 2017 at 20:13

1 Answer 1

3

enter image description here

\documentclass{article}
\usepackage{fontspec}
\begin{document}
\rmdefault\par
\sfdefault\par
\ttdefault\par

$x$

\fontname\textfont0\par
\fontname\textfont1\par
\fontname\textfont2\par
\fontname\textfont3\par

% What prints the math default font(s)? Expecting lmm.
\end{document}

this is the primitive layer font name, not an NFSS axis name in the style of \rmfamily

With unicode-math by default you will get

enter image description here

5
  • Great! I can take it from there. This is related to the issue I raised earlier this week, regarding l3 and my hacked fontspec code. I am now un-hacking my code. Works, but I didn't know how to get at the math part (I don't do math, myself).
    – user103221
    Feb 17, 2017 at 19:53
  • @RobtA everybody should do math! Feb 17, 2017 at 19:53
  • Oh all right, I'll do a little math. I notice that your solution requires something to be printed in math mode, before the math textfonts are set. I discovered that this works in Preamble: \newlength\widthofmathx then \setlength\widthofmathx{\widthof{\(x\)}}. That sets the math textfonts, without actually printing anything. Then I can read the textfont strings in Preamble, and execute code based on which fonts were set. Incidentally, in my document class a dollar is a dollar, not math mode.
    – user103221
    Feb 17, 2017 at 20:11
  • @RobtA no, not in the preamble (if you are using unicode-math) you have to set it up after begin{document} Feb 17, 2017 at 20:50
  • Ah, that helps! I had it working, then not working... It had to do with where I put it.
    – user103221
    Feb 17, 2017 at 21:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy