Basically, I want to achieve the same as for instance in this question: Changing the math-mode figures to “old style”. But not in general math, only for URLs, which are set in math mode (in the manual, I read that this is done due to “context-sensitive linebreaking”).
So, a simple MWE:
%!TEX program=lualatex
\documentclass{article}
\usepackage[no-math]{fontspec}
\usepackage{unicode-math}
\usepackage{url}
\urlstyle{same}
\setmainfont[Numbers={OldStyle}]{Libertinus Serif}
\setmathfont[]{Libertinus Math}
\begin{document}
math: $123$
text: 123
url: \url{123}
\end{document}
The math number should of course stay as they are, but I would prefer to have the same number style in URLs as in normal text. In the MWE, I used the predefined url-style \urlstyle{same}
. For custom styles, I would use the macro \renewcommand*{\UrlFont}{\mathversion{osf}\normalfont}
and define a suitable math version with \setmathfont[version=osf,....enable oldstyle numbers....]{Libertinus Math}
.
However, I do not know how to “activate” old-style numbers with unicode-math. When adding the option Numbers={OldStyle}
as for the the main font, I do not observe any effect.
Edit
I tried it with \mathversion
s and substitituting only a range
, but this does not work. But \mathversion
s alone work – at least for equations put inside $
signs. For URLs, it is somehow ignored.
Update MWE
%!TEX program=lualatex
\documentclass{article}
\usepackage[no-math]{fontspec}
\usepackage{unicode-math}
\usepackage{url}
\renewcommand*{\UrlFont}{\mathversion{osf}}
\setmainfont[Numbers={OldStyle}]{Libertinus Serif}
\setmathfont{Libertinus Math}[version=default]
\setmathfont{Libertinus Serif}[version=osf,Numbers=OldStyle]
\begin{document}
\mathversion{osf}
math (osf): $123$
\mathversion{default}
math (default): $123$
text: 123
url: \url{123}
\end{document}
\setmathfont{Libertinus Serif}[range=up/digits, Numbers=OldStyle]
and the math version withversion=osf
. Unfortunately,range=
andversion=
are mutually exclusive as of 2021.\setmathrm
and use the\mathrm
font in math mode, but the way\url
is defined seems to be set up to use commands such as\rmfamily
or\ttfamily
, not\mathrm{123}
.hyperref
might work better for you?hyperref
uses theurl
package? I do usehyperref
indeed, and wanted to change the appearance of links.