在 lineno 的 linenumbers 环境中将旧式数字更改为内衬数字

在 lineno 的 linenumbers 环境中将旧式数字更改为内衬数字

我在文档中使用旧式数字,但我更喜欢在行号环境(lineno\linenumbers环境)中使用行号。如何强制执行此操作(不更改为其他字体)?

\documentclass{article}
\usepackage{fontspec,lineno}
    \setmainfont[Numbers=OldStyle]{Linux Libertine O}
    \renewcommand\linenumberfont{\normalfont\scriptsize\rmfamily}

\begin{document}
\begin{linenumbers}
\noindent Continual delighted\linelabel{1stword} as elsewhere am convinced unfeeling. Introduced stimulated attachment no by projection. To loud lady whom my mile sold four. Need miss all four case fine age tell. He families my pleasant speaking it bringing\linelabel{2ndword} it thoughts. View busy dine oh in knew if even. Boy these along far own other equal old fanny charm. Difficulty invitation put introduced\linelabel{3rdword} see middletons nor preference.
\end{linenumbers}
\vspace{\baselineskip}
\noindent I like the words I find in line \lineref{1stword}, \lineref{2ndword}, and \lineref{3rdword}.
\end{document}

在此处输入图片描述

答案1

如果只是更改数字,请使用命令fontspec\addfontfeatures{Numbers={Lining, Monospaced}}请参阅fontspec手动的)(您甚至可能不需要指定Monospaced,但指定它也没有坏处。)\normalfont并且\rmfamily也不是必需的。

\documentclass{article}
\usepackage{fontspec,lineno}
    \setmainfont[Numbers=OldStyle]{Linux Libertine O}
    \renewcommand{\linenumberfont}{\scriptsize\addfontfeatures{Numbers={Lining, Monospaced}}}

\begin{document}
\begin{linenumbers}
\noindent Continual delighted\linelabel{1stword} as elsewhere am convinced unfeeling. 
Introduced stimulated attachment no by projection. To loud lady whom my mile sold
four. Need miss all four case fine age tell. He families my pleasant speaking it
bringing\linelabel{2ndword} it thoughts. View busy dine oh in knew if even. Boy these
along far own other equal old fanny charm. Difficulty invitation put 
introduced\linelabel{3rdword} see middletons nor preference.
\end{linenumbers}
\vspace{\baselineskip}
\noindent I like the words I find in line \lineref{1stword}, \lineref{2ndword}, and
\lineref{3rdword}.
\end{document}

输出

答案2

对于 Type 1 字体(pdflatex)用户,以下内容可行:

\documentclass{article}
\usepackage[osf]{libertine}
\usepackage[T1]{fontenc}
\usepackage{lineno}

\renewcommand\linenumberfont{\fontfamily{LinuxLibertineT-TLF}\scriptsize\selectfont}

\begin{document}
\begin{linenumbers}
\noindent Continual delighted\linelabel{1stword} as elsewhere am convinced unfeeling. Introduced stimulated attachment no by projection. To loud lady whom my mile sold four. Need miss all four case fine age tell. He families my pleasant speaking it bringing\linelabel{2ndword} it thoughts. View busy dine oh in knew if even. Boy these along far own other equal old fanny charm. Difficulty invitation put introduced\linelabel{3rdword} see middletons nor preference.
\end{linenumbers}
\vspace{\baselineskip}
\noindent I like the words I find in line \lineref{1stword}, \lineref{2ndword}, and \lineref{3rdword}.
\end{document}

相关内容