3

Very few monospace fonts support unicode characters like U+1D4AA (Mathematical Script Capital O). I'm using DejaVu Sans Mono, and I'd like to define a fallback. Right now I have this:

\documentclass{article}
\usepackage{fontspec}
\usepackage{newunicodechar}
\setmonofont{DejaVu Sans Mono}[Scale=MatchLowercase]
\newunicodechar{𝒪}{$\mathcal{O}$}
\begin{document}
Aa\texttt{Aa𝒪A}
\end{document}

Which produces:

AaAaOA

I'd like the O to be the same size as the monospaced A (but keeping the height of the monospaced a the same as the body text a).

1

I'm not seeing any OpenType font with the Computer Modern calligraphic letters. With Latin Modern Math you get a similar glyph. Anyway, I'm afraid you need to compute the scale factor yourself.

\documentclass{article}
\usepackage{fontspec}
\usepackage{newunicodechar}

\setmonofont{DejaVu Sans Mono}[Scale=MatchLowercase]
\newfontface{\calligraphic}{Latin Modern Math}[Scale=0.85]
\newunicodechar{𝒪}{{\normalfont\calligraphic 𝒪}}

\begin{document}

Aa\texttt{Aa𝒪A}

\end{document}

enter image description here

  • @DavidCarlisle Can you elaborate why it's an issue in this case? I'd like to understand this. We're dealing with a true unicode character, not trying to make a font change. – ipswitch Jun 13 at 11:07
  • @DavidCarlisle Ah, got it. Thanks! This is just a minimal example. I'm using it to typeset Julia code that has some unicode characters. – ipswitch Jun 13 at 16:28
1
\documentclass{article}
\usepackage{unicode-math}
\usepackage{newunicodechar}
\setmonofont{DejaVu Sans Mono}[Scale=MatchLowercase]
\setmathfont{XITS Math}
\setmathfont[Scale=0.85,range="1D4AA]{XITS Math}
\newunicodechar{𝒪}{$\symcal{O}$}
\begin{document}
    Aa\texttt{Aa𝒪A}\tiny Aa\texttt{Aa𝒪A}
\end{document}

enter image description here

  • That's definitely the desired effect! Does there happen to be a way to do it without using the unicode-math package? – ipswitch Jun 12 at 20:57
  • Yes, you can define your own virtual font, but that is more work than using unicode-math which itself should already be loaded if someone uses xelatex or lualatex – Red-Cloud Jun 13 at 6:17

Your Answer

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

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