“doi”文本(不是 doi 本身)与文档字体不匹配

“doi”文本(不是 doi 本身)与文档字体不匹配

使用 TeX Live 2016 并在 Fedora 27 上使用 Lua 进行编译时,以下代码会为“doi”文本生成错误的字体。

% LuaLaTeX
\documentclass[10pt]{article}

%%% this fix is required to properly load my intended font
%%% see https://tex.stackexchange.com/questions/329593/fontspec-font-not-found-alegreyasans-package
\usepackage[no-math]{fontspec}
\makeatletter
\let\fontspec@setsansfont\setsansfont
\def\setsansfont{%
  \let\Alegreya@boldstyle\AlegreyaSans@boldstyle
  \let\setsansfont\fontspec@setsansfont
  \setsansfont
}
\makeatother
%%% end of fix

\usepackage[osf,sfdefault]{AlegreyaSans}
\usepackage[authordate,backend=biber]{biblatex-chicago}
\addbibresource{bib.bib}
\urlstyle{same}

\begin{filecontents}{bib.bib}

@article{one,
    author          = {John Doe},
    title           = {Title},
    journaltitle    = {Journal},
    year            = {2000},
    volume          = {1},
    pages           = {2},
    doi            = {11.1111/abc.1111}
}

\end{filecontents}

\addbibresource{bib.bib}
\nocite{*}

\begin{document}

\printbibliography

\end{document}

在此处输入图片描述

我该如何修复此问题?我发现的所有修复方法都只涉及 doi 编号本身的字体,而不是实际的“doi”文本。

答案1

我不知道 TeX Live 2016 的情况,但 TeX Live 2018 软件包AlegreyaSans无法将 Alegreya Sans 设置为主字体。

添加一些修复应该可以解决这个问题。

\begin{filecontents}{\jobname.bib}
@article{one,
    author          = {John Doe},
    title           = {Title},
    journaltitle    = {Journal},
    year            = {2000},
    volume          = {1},
    pages           = {2},
    doi            = {11.1111/abc.1111}
}
\end{filecontents}

\documentclass[10pt]{article}

%%% this fix is required to properly load my intended font
%%% see https://tex.stackexchange.com/questions/329593/fontspec-font-not-found-alegreyasans-package
\usepackage[no-math]{fontspec}

\makeatletter
\let\fontspec@setsansfont\setsansfont
\def\setsansfont{%
  \let\Alegreya@boldstyle\AlegreyaSans@boldstyle
  \let\setsansfont\fontspec@setsansfont
  \setsansfont
}
\makeatother
%%% end of fix

\usepackage[osf,sfdefault]{AlegreyaSans}
\usepackage[authordate,backend=biber]{biblatex-chicago}
\addbibresource{\jobname.bib}
\urlstyle{same}

% Add these
\edef\familydefault{\sfdefault}
\edef\rmdefault{\sfdefault}
%%%

\begin{document}

Some text
\nocite{*}

\printbibliography

\end{document}

在此处输入图片描述

不过,你可以避开这个包裹AlegreyaSans

\begin{filecontents}{\jobname.bib}
@article{one,
    author          = {John Doe},
    title           = {Title},
    journaltitle    = {Journal},
    year            = {2000},
    volume          = {1},
    pages           = {2},
    doi            = {11.1111/abc.1111}
}
\end{filecontents}

\documentclass[10pt]{article}

\usepackage[no-math]{fontspec}

\setmainfont{AlegreyaSans}[
  Extension = .otf,
  UprightFont = *-Regular,
  ItalicFont = *-Italic,
  BoldFont = *-Bold,
  BoldItalicFont = *-BoldItalic,
  Numbers = OldStyle,
]

\usepackage[authordate,backend=biber]{biblatex-chicago}
\addbibresource{\jobname.bib}
\urlstyle{same}

\begin{document}

Upright 1234567890
\textit{Italic 1234567890}
\textbf{Bold 1234567890}
\textbf{\textit{BoldItalic 1234567890}}

\nocite{*}

\printbibliography

\end{document}

在此处输入图片描述

相关内容