LaTeX forum ⇒ Fonts & Character SetsSpecifications for Math Numerals

Information and discussion about fonts and character sets (e.g. how to use language specific characters)
hugovdberg
Posts: 133
Joined: Sat Feb 25, 2012 6:12 pm
Location: 's-Hertogenbosch, Netherlands

Specifications for Math Numerals

Postby hugovdberg » Fri Feb 21, 2014 6:36 pm

I use mathspec to change the numerals from eulervm to the numerals from my text font, which do blend quite nicely. I have to this because I also use siunitx, and no matter what setting I use, in math mode it will use the euler numerals even if I don't set the euler-digits option. Unfortunately, with the \setmathfont also the digits within the DOI identifiers in my bibliography are changed, and thus look really ugly. I tried using and explicit \setmonofont, that does change the letters and symbols, but still not the digits, whether I set the mono-spaced font before the math font or after it. Also note I only set the FreeMono as mono-spaced font for extra contrast to see what changed, I think it's rather ugly and definitely prefer a font better fitting with the rest of the text.

Below are the files "test2.tex", and "test2.bib" (sorry, "test.tex" was already actively in use ;) ) I also attached the corresponding output on my system.

  1. \documentclass{scrartcl}
  2. \usepackage{amsfonts}
  3. \usepackage{eulervm}
  4.  
  5. \usepackage{siunitx}
  6. \sisetup{
  7. detect-all
  8. }
  9.  
  10. \usepackage{mathspec}
  11. \setmainfont[
  12. Ligatures={Common,TeX},
  13. Numbers={OldStyle,Proportional}
  14. ]{Calluna}
  15. \setsansfont[
  16. Ligatures={Common,TeX},
  17. Numbers={Lining,Proportional}
  18. ]{Calluna Sans}
  19. % According to the manual this sets the digits to the regular arabics,
  20. % while leaving the latin and greek letters untouched,
  21. % this is intented, I want eulervm for maths letters.
  22. \setmathfont(Digits,Latin,Greek)[%
  23. Arabic=Regular,
  24. Uppercase=Plain,
  25. Lowercase=Plain,
  26. Numbers={Lining,Proportional}
  27. ]{Calluna}
  28. \setmonofont[
  29. Ligatures={NoRequired,NoCommon,NoContextual},
  30. Numbers={Lining,Monospaced}
  31. ]{FreeMono}
  32.  
  33. \usepackage[
  34. style=authoryear-comp,
  35. doi=true,
  36. url=true,
  37. sorting=nyvt,
  38. backend=biber,
  39. ]{biblatex}
  40. \usepackage[hidelinks]{hyperref}
  41. \addglobalbib{test2.bib}
  42.  
  43. \begin{document}
  44.  
  45. \section{Verify sans font}
  46. The following line shows the normal verb command is unaffected:
  47.  
  48. {\scshape DOI:}\ \verb|10.1016/j.sedgeo.2010.04.015|
  49.  
  50. The following is a sentence to test the various fonts for digits with or without
  51. \verb|\sisetup{detect-all}| or \verb|\setmathfont|.
  52.  
  53. 1234567890, \(1234567890\),
  54. \SI{1234567890}{\metre}, \(\SI{1234567890}{\metre}\),
  55. \num{1234567890}, \(\num{1234567890}\).
  56.  
  57. \textcite{Hay2011} shows the problem with the DOI, I included this one because it
  58. has an ugly mixture of letters and digits, showing the problem to its full extent.
  59.  
  60. \printbibliography
  61. \end{document}


  1. @Article{Hay2011,
  2. Title = {Can humans force a return to a `Cretaceous' climate?},
  3. Author = {William W. Hay},
  4. Journaltitle = {Sedimentary Geology},
  5. Year = {2011},
  6. Doi = {10.1016/j.sedgeo.2010.04.015},
  7. ISSN = {0037-0738},
  8. Language = {english},
  9. Note = {Causes of oxic - anoxic changes in Cretaceous marine environments and their implications for Earth systems },
  10. Number = {1-2},
  11. Pages = {5--26},
  12. Volume = {235},
  13.  
  14. __markedentry = {[hugo:1]},
  15. Journal = {Sedimentary Geology },
  16. Keywords = {Cretaceous},
  17. Owner = {hugo},
  18. Timestamp = {2014.02.21}
  19. }
Attachments
test2.pdf
(22.2 KiB) Downloaded 144 times
Ubuntu 13.10 + Tex Live 2013 + Texmaker / Windows 7 Pro + MikTex 2.9 + TexnicCenter / Android 4.3 + TexPortal + DroidEdit

Link:
BBcode:
HTML:
Hide post links
Show post links

hugovdberg
Posts: 133
Joined: Sat Feb 25, 2012 6:12 pm
Location: 's-Hertogenbosch, Netherlands

Postby hugovdberg » Sun Feb 23, 2014 11:52 pm

A small update on the issue, for now I just set my monofont to Calluna, since in the current document I don't need listings or verbatim environments. However, if someone could point me in the right direction where to find the declarations that specify the typesetting of the DOI I would be very grateful.
Ubuntu 13.10 + Tex Live 2013 + Texmaker / Windows 7 Pro + MikTex 2.9 + TexnicCenter / Android 4.3 + TexPortal + DroidEdit

Link:
BBcode:
HTML:
Hide post links
Show post links

hugovdberg
Posts: 133
Joined: Sat Feb 25, 2012 6:12 pm
Location: 's-Hertogenbosch, Netherlands

Postby hugovdberg » Sun Mar 02, 2014 3:25 pm

Since apparently nobody over here can help me I decided to cross-post it to TeX.sx, see my question over there: http://tex.stackexchange.com/questions/ ... references
Ubuntu 13.10 + Tex Live 2013 + Texmaker / Windows 7 Pro + MikTex 2.9 + TexnicCenter / Android 4.3 + TexPortal + DroidEdit

Link:
BBcode:
HTML:
Hide post links
Show post links

hugovdberg
Posts: 133
Joined: Sat Feb 25, 2012 6:12 pm
Location: 's-Hertogenbosch, Netherlands

Postby hugovdberg » Sun Mar 02, 2014 8:08 pm

Thanks to egreg at TeX.se this problem has been solved, the code below is his solution to the problem.

  1. \begin{filecontents}{test.bib}
  2. @Article{Hay2011,
  3. Title = {Can humans force a return to a `Cretaceous' climate?},
  4. Author = {William W. Hay},
  5. Journaltitle = {Sedimentary Geology},
  6. Year = {2011},
  7. Doi = {10.1016/j.sedgeo.2010.04.015},
  8. ISSN = {0037-0738},
  9. Language = {english},
  10. Note = {Causes of oxic - anoxic changes in Cretaceous marine environments and their implications for Earth systems },
  11. Number = {1-2},
  12. Pages = {5--26},
  13. Volume = {235},
  14.  
  15. Journal = {Sedimentary Geology },
  16. Keywords = {Cretaceous},
  17. }
  18. \end{filecontents}
  19.  
  20. \documentclass{scrartcl}
  21.  
  22. \usepackage{amsfonts}
  23. \usepackage{eulervm}
  24.  
  25. \usepackage{siunitx}
  26. \sisetup{
  27. % detect-all,
  28. math-rm=\mathlining,
  29. }
  30.  
  31. \usepackage[no-math]{fontspec}
  32. \setmainfont[Ligatures={Common,TeX},Numbers={OldStyle,Proportional}]{TeX Gyre Termes}
  33. \newfontfamily{\liningmain}[Ligatures={Common,TeX},Numbers=Lining]{TeX Gyre Termes}
  34. \setsansfont[Ligatures={Common,TeX},Numbers={Lining,Proportional}]{TeX Gyre Heros}
  35. \setmonofont[Ligatures={NoRequired,NoCommon,NoContextual},Numbers={Lining,Monospaced}]{TeX Gyre Cursor}
  36.  
  37. % A trick for extracting the family information
  38. % which works independently of the chosen font
  39. \begingroup
  40. \def\getfamily#1#2#3#4#5{#4}
  41. \edef\x{\endgroup
  42. \def\noexpand\liningdefault{\expandafter\expandafter\expandafter
  43. \getfamily\csname liningmain \endcsname}}\x
  44.  
  45. \DeclareSymbolFont{liningmath}{\encodingdefault}{\liningdefault}{m}{n}
  46. \DeclareSymbolFontAlphabet{\mathlining}{liningmath}
  47. \Umathcode`0="7 \symliningmath `0
  48. \Umathcode`1="7 \symliningmath `1
  49. \Umathcode`2="7 \symliningmath `2
  50. \Umathcode`3="7 \symliningmath `3
  51. \Umathcode`4="7 \symliningmath `4
  52. \Umathcode`5="7 \symliningmath `5
  53. \Umathcode`6="7 \symliningmath `6
  54. \Umathcode`7="7 \symliningmath `7
  55. \Umathcode`8="7 \symliningmath `8
  56. \Umathcode`9="7 \symliningmath `9
  57.  
  58. \usepackage[
  59. style=authoryear-comp,
  60. doi=true,
  61. url=true,
  62. sorting=nyvt,
  63. backend=biber,
  64. ]{biblatex}
  65. \usepackage[hidelinks]{hyperref}
  66. \addglobalbib{test.bib}
  67. \begin{document}
  68.  
  69. \section{Verify sans font}
  70. The following line shows the normal verb command is unaffected:
  71.  
  72. DOI: \verb|10.1016/j.sedgeo.2010.04.015|
  73.  
  74. URL: \url{10.1016/j.sedgeo.2010.04.015}
  75.  
  76. This is a sentence to test the various fonts for digits with or without
  77. \verb|\sisetup{detect-all}| or \verb|\setmathfont|.\\
  78. No math: 1234567890,\\
  79. Math: \(1234567890\),\\
  80. \verb|\SI| in text: \SI{1234567890}{\metre},\\
  81. \verb|\SI| in math: \(\SI{1234567890}{\metre}\),\\
  82. \verb|\num| in text: \num{1234567890},\\
  83. \verb|\num| in math: \(\num{1234567890}\).
  84.  
  85. A test of math: $X=12$.
  86.  
  87. \begin{verbatim}
  88. This is a test of numerals in the verbatim environment: 1234567890
  89. \end{verbatim}
  90.  
  91. \textcite{Hay2011} shows the problem with the DOI, I included this one because it has an ugly mixture of letters and digits, showing the problem to its full extent.
  92. \printbibliography
  93. \end{document}
Ubuntu 13.10 + Tex Live 2013 + Texmaker / Windows 7 Pro + MikTex 2.9 + TexnicCenter / Android 4.3 + TexPortal + DroidEdit

Link:
BBcode:
HTML:
Hide post links
Show post links

hugovdberg
Posts: 133
Joined: Sat Feb 25, 2012 6:12 pm
Location: 's-Hertogenbosch, Netherlands

Postby hugovdberg » Wed Mar 19, 2014 4:41 pm

Another update of this topic, since it later turned out this didn't solve the problem entirely. This solution works as it stands with TeX Gyre since that has lining figures as its default numerals (so named characters one, two, three, etc. for those familiar with OpenType fonts' internals), but Calluna, and the more regularly available EB Garamond have OldStyle figures by default. These are not loaded correctly without adding the option Renderer=Basic to the \liningmain font specification, but then the font is loaded correctly only about half the time, randomly changing between compilation runs. At the moment we suspect this is caused by a bug in luaotfload, so an issue has been opened at their GitHub, hopefully a fix will be available any time soon.
Ubuntu 13.10 + Tex Live 2013 + Texmaker / Windows 7 Pro + MikTex 2.9 + TexnicCenter / Android 4.3 + TexPortal + DroidEdit

Link:
BBcode:
HTML:
Hide post links
Show post links


Return to “Fonts & Character Sets”

Who is online

Users browsing this forum: No registered users and 3 guests