2

I'm working on a document with Xelatex so I use \fontspec. I have set the monotype fonts with \setmonofont to use Inconsolata, for example, in the urls of the bibliography. This minimal example shows it:

\documentclass[11pt,notitlepage,oneside,a4paper]{article}
\usepackage[backend=biber,style=authoryear,doi=true]{biblatex}
\usepackage{fontspec}
\usepackage{filecontents}

\setmonofont{Inconsolata}

\begin{filecontents}{biblio.bib}
@article{test, 
  author = {Author, A.},
  year = {2015},
  title = {Title},
  journal = {Some Journal},
  doi = {10.1016/S0169-8141(98)00038-9},
}
\end{filecontents}
\addbibresource{biblio.bib}

\usepackage[colorlinks=true,breaklinks]{hyperref}

\begin{document}

Lorem ipsum dolor \textcite{test}

\printbibliography

\end{document}

The result with the correct font is: example1

Then, I wanted to change the mathfont so I changed from \fontspec to \mathspec and added a \setmathfont. Everything works fine with the math fonts except now the urls in my bibliography are typeset in that math font and not in Inconsolata

\documentclass[11pt,notitlepage,oneside,a4paper]{article}
\usepackage[backend=biber,style=authoryear,doi=true]{biblatex}
%\usepackage{fontspec}
\usepackage{mathspec}
\usepackage{filecontents}

\setmathfont(Digits,Latin,Greek)[Numbers={Lining,Monospaced}]{Alegreya Sans Light}
\setmonofont{Inconsolata}

\begin{filecontents}{biblio.bib}
@article{test, 
  author = {Author, A.},
  year = {2015},
  title = {Title},
  journal = {Some Journal},
  doi = {10.1016/S0169-8141(98)00038-9},
}
\end{filecontents}
\addbibresource{biblio.bib}

\usepackage[colorlinks=true,breaklinks]{hyperref}

\begin{document}

Lorem ipsum dolor \textcite{test}

\printbibliography

\end{document}

And now the result is: example2

What's the problem? How can I set the math font and mantain Inconsolata as the monotype font?

Thanks for your help.

  • It seems a bug in mathspec – egreg Aug 17 '15 at 21:32
0

As a workaround, you can use the package unicode-math. You can see here the differences between unicode-math and mathspec. In short, mathspec is intended for replace some fonts in math mode with system fonts (which you are looking for), while unicode-math main purpose is use complete math OpenType fonts.

Using unicode-math, you can set a complete math family and replace some character sets with another font. Here is a MWE:

\documentclass[11pt,notitlepage,oneside,a4paper]{article}
\usepackage{fontspec}
%\usepackage{xunicode}% unicode character macros
%\usepackage{xltxtra}

\usepackage[math-style=TeX]{unicode-math}
\setmathfont{Asana Math}
\setmathfont[range=\mathit/{latin,Latin},Numbers={Lining,Monospaced}]{Nimbus Sans L Regular Italic}           
\setmathfont[range=\mathup/{latin,Latin},Numbers={Lining,Monospaced}]{Nimbus Sans L}           

\setmainfont{Nimbus Sans L}
\setmonofont{Inconsolatazi4}

\usepackage[spanish]{babel}
\usepackage[backend=biber,style=authoryear,doi=true]{biblatex}
\usepackage{filecontents}

\begin{filecontents}{biblio.bib}
@article{test, 
  author = {Author, A.},
  year = {2015},
  title = {Title},
  journal = {Some Journal},
  doi = {10.1016/S0169-8141(98)00038-9},
}
\end{filecontents}
\addbibresource{biblio.bib}

\usepackage[colorlinks=true,breaklinks]{hyperref}

\begin{document}

Lorem ipsum dolor \textcite{test}

\[e=mc^2\]

\printbibliography

\end{document}

The idea is you set a math font (Asana) for all glyphs and letters (even greek letters) and replace some of them by a sans serif font (Nimbus Sans L)

This way, you can use Alegreya Sans Light as math font and Inconsolata as mono font (I've replaced Alegreya by Nimbus Sans L, in order of simplicity; most of linux distros have Nimbus installed by default, as replacement of Helvetica).

I have no experience with mathspec package, so you problem may be a bug, or someone can post a better solution based on it.

Hope this help you.

Kind regards

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.