7

The following works with xelatex:

\documentclass{article}
\usepackage{url}
    \urlstyle{same}
\usepackage{fontspec}
    \setmainfont{Libertine Serif}[Numbers = {OldStyle, Proportional}]
\begin{document}
\url{http://example.com/1234567890}
\end{document}

enter image description here

But not with lualatex:

enter image description here

Fix possible? Bug?

13
  • This is no biblatex matter, but rather one of the url package as \url{http://example.com/1234567890} in the document shows. Maybe it is a good idea to make the example even more minimal and remove biblatex as it is certainly not the culprit here.
    – moewe
    Sep 1, 2015 at 15:31
  • @moewe Good catch - will do.
    – Sverre
    Sep 1, 2015 at 15:34
  • IIRC, this is a duplicate of an earlier posting (which, unfortunately, I can't seem to locate right away). At any rate LuaLaTeX (but not XeLaTeX) appears to process the argument of \url in quasi-math mode, and math mode uses only lining figures, no oldstyle figures. Juxtapose the output of 1234567890 and \url{1234567890} to see what I mean.
    – Mico
    Sep 1, 2015 at 15:46
  • Found it: How to make the url package respect fontspec font options (stylisticset) with LuaLaTeX. In that posting, note that \path is an alias for \url.
    – Mico
    Sep 1, 2015 at 15:49
  • @Mico Possibly this one?
    – Sverre
    Sep 1, 2015 at 15:50

2 Answers 2

3

A similar question was asked in How to make the `url` package respect fontspec font options (stylisticset) with LuaLaTeX, and egreg's answer with a following comment provide the solution for this as well.

\documentclass{article}
\usepackage{url}
    \urlstyle{same}
\usepackage{fontspec}
    \setmainfont{Libertine Serif}[Numbers = {OldStyle, Proportional}]

\makeatletter
    \g@addto@macro\UrlSpecials{%
        \do\0{\mbox{\UrlFont\char`\0}}%
        \do\1{\mbox{\UrlFont\char`\1}}%
        \do\2{\mbox{\UrlFont\char`\2}}%
        \do\3{\mbox{\UrlFont\char`\3}}%
        \do\4{\mbox{\UrlFont\char`\4}}%
        \do\5{\mbox{\UrlFont\char`\5}}%
        \do\6{\mbox{\UrlFont\char`\6}}%
        \do\7{\mbox{\UrlFont\char`\7}}%
        \do\8{\mbox{\UrlFont\char`\8}}%
        \do\9{\mbox{\UrlFont\char`\9}}%
    }
\makeatother

\begin{document}
\url{http://example.com/1234567890}
\end{document}

enter image description here

For what it's worth, @egreg considers this to be a bug.

2
1

Here is a patch to modify the font used by url to be configured to use so called base mode in LuaTeX+luaotfload lingua. Indeed by default text fonts are declared using node mode, which (quote) does not work in math mode whatever that means. The patch modifies the font name to replace mode=node if present by mode=base.

But... in the example below I get the Old Style Figures to work, but the tnum (Tabular Figures) feature does not.

More experimenting reveals that it works separately for one feature (be it Numbers=OldStyle or Numbers=Monospaced or Numbers=Proportional but not with two at the same time; naturally I checked that the font name is correctly prepared in all cases).

\documentclass{article}
\usepackage{fontspec}
\setmainfont{TeX Gyre Termes}[Numbers = {OldStyle, Monospaced}]
\usepackage{url}
\urlstyle{same}

\makeatletter
\ifx\directlua\undefined\else
\begingroup
\catcode`N 12
\catcode`O 12
\catcode`D 12
\catcode`E 12
\lowercase{\gdef\FixFontForMath@i #1=NODE;#2#3\relax #4\@empty}%
  {%
  \ifx#2\empty
      \let\FixedFontForMath\font
  \else\font\FixedFontForMath=#1=base;#2#3\relax\fi 
  }%
\lowercase{\gdef\FixFontForMath {\expandafter\FixFontForMath@i
    \fontname\font\relax\relax=NODE;\empty\relax\@empty }}%
\endgroup
\def\Url@FormatString{%
 \UrlFont \FixFontForMath \Url@MathSetup 
 $\fam\z@ \textfont\z@\FixedFontForMath
 \expandafter\UrlLeft\Url@String\UrlRight
 \m@th$%
% \if\urldebug \showlists \fi 
}%
\fi
\makeatother
\begin{document}

http://www.0123456789.org (text)

\url{http://www.0123456789.org} (url)

\hsize 6cm

For some reason the `Tabular' feature is not obeyed in math. But the `Old Style'
feature now is.

\end{document}

% Local Variables:
% TeX-engine: luatex
% End:

enter image description here

4
  • +tnum doesn't work in mode=base regardless if you are in math or not (for oldstyle number, normal numbers are lining anyway). May 3, 2016 at 7:48
  • @UlrikeFischer I tested with \setmainfont{TeX Gyre Termes}[Numbers = {Monospaced}] in the code above and I do get tabular figures in \url, and the mode=base.
    – user4686
    May 3, 2016 at 7:50
  • Do you get non-tabular figures somewhere if you remove the Numbers=Monospaced? May 3, 2016 at 7:53
  • @UlrikeFischer to get non-tabular figures with TeX Gyre Termes I need to use Numbers = Proportional. Then I do get them. With my code above and \setmainfont{TeX Gyre Termes}[Numbers = {Proportional}] the text and url are exactly identical and use proportional figures.
    – user4686
    May 3, 2016 at 7:55

You must log in to answer this question.

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