使用 LuaLaTeX 和 fontspec 时重新定义标准字体大小命令

使用 LuaLaTeX 和 fontspec 时重新定义标准字体大小命令

如何在使用 LuaLaTeX 和 fontspec 时重新定义标准字体大小命令(、、\small等)?\normalsize\large

根据我在网上搜索到的内容,我做了以下事情:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Calibri}
  \renewcommand{\footnotesize}{\fontsize{9bp}{11bp}\selectfont}
  \renewcommand{\small}{\fontsize{10bp}{12bp}\selectfont}
  \renewcommand{\normalsize}{\fontsize{11bp}{13bp}\selectfont}
  \renewcommand{\large}{\fontsize{13bp}{15bp}\selectfont}
\usepackage{soul}

\begin{document}
% HEADING
\begin{flushleft}\small
  Keywords: some, relevant, words, here.
\end{flushleft}
\begin{center}\large
  \textbf{The title is very important}\\[1ex]
  \ul{A. U. Thor}\footnote{An address, Country}
\end{center}

% MAIN TEXT
filler filler filler filler filler filler filler filler

filler filler filler filler filler filler filler filler filler 
filler filler 
\end{document}

使用我安装的 Calibri 字体,编译效果确实很好。但是,我收到以下警告(如果不存在重新定义则不会出现):

LaTeX Font Warning: Font shape `TU/Calibri(1)/m/n' undefined
(Font)              using `TU/lmr/m/n' instead on input line 13.
(load luc: /home/equaeghe/.texlive/texmf-var/luatex-cache/generic/font/otl/lmroman12-regular.luc)
LaTeX Font Warning: Font shape `OML/cmm/m/it' in size <13.04874> not available
(Font)              size <12> substituted on input line 20.
LaTeX Font Warning: Font shape `OML/cmm/m/it' in size <6.52437> not available
(Font)              size <7> substituted on input line 20.
LaTeX Font Warning: Font shape `OMS/cmsy/m/n' in size <13.04874> not available
(Font)              size <12> substituted on input line 20.
LaTeX Font Warning: Font shape `OMS/cmsy/m/n' in size <6.52437> not available
(Font)              size <7> substituted on input line 20.
LaTeX Font Warning: Font shape `OT1/cmr/m/n' in size <13.04874> not available
(Font)              size <12> substituted on input line 20.
LaTeX Font Warning: Font shape `OT1/cmr/m/n' in size <6.52437> not available
(Font)              size <7> substituted on input line 20.
LaTeX Font Warning: Font shape `OML/cmm/m/it' in size <4.51686> not available
(Font)              size <5> substituted on input line 20.
LaTeX Font Warning: Font shape `OMS/cmsy/m/n' in size <4.51686> not available
(Font)              size <5> substituted on input line 20.
LaTeX Font Warning: Font shape `OT1/cmr/m/n' in size <4.51686> not available
(Font)              size <5> substituted on input line 20.
LaTeX Font Warning: Size substitutions with differences
(Font)              up to 1.04874pt have occurred.
LaTeX Font Warning: Some font shapes were not available, defaults substituted.

我认为

  1. 不应存在​​对lmr和的引用,并且cm
  2. 应该有一种方法可以获得(更接近)我要求的实际尺寸。

答案1

Calibri(1)由于字体系列未定义,因此您的示例未产生有关警告。

关于数学字体的警告是意料之中的;您可以通过加载来删除它们fix-cm

\footnotesize标准 10pt 选项中的定义是

% size10.clo, line 66:
\newcommand\footnotesize{%
   \@setfontsize\footnotesize\@viiipt{9.5}%
   \abovedisplayskip 6\p@ \@plus2\p@ \@minus4\p@
   \abovedisplayshortskip \z@ \@plus\p@
   \belowdisplayshortskip 3\p@ \@plus\p@ \@minus2\p@
   \def\@listi{\leftmargin\leftmargini
               \topsep 3\p@ \@plus\p@ \@minus\p@
               \parsep 2\p@ \@plus\p@ \@minus\p@
               \itemsep \parsep}%
   \belowdisplayskip \abovedisplayskip
}

如果您不需要脚注中的数学或列表或使用 的任何内容\footnotesize,您可以坚持仅对字体大小进行简单的重新定义。由于您设置的是 11bp 大小,因此使用 11pt 选项加载文章,然后修补以使用bp而不是是有意义的pt

\documentclass[11pt]{article}
\usepackage{fontspec,fix-cm}

\usepackage{soul}
\usepackage{regexpatch}

\setmainfont{Calibri}

\makeatletter
\newdimen\bp@ \bp@=1bp
\xpatchcmd{\normalsize}{\@xipt{13.6}}{{11bp}{13bp}}{}{}
\xpatchcmd*{\normalsize}{\p@}{\bp@}{}{}
\xpatchcmd{\small}{\@xpt\@xiipt}{{10bp}{12bp}}{}{}
\xpatchcmd{\small}{\p@}{\bp@}{}{}
\xpatchcmd{\footnotesize}{\@ixpt{11}}{{9bp}{11bp}}{}{}
\xpatchcmd*{\footnotesize}{\p@}{\bp@}{}{}
\renewcommand\large{\@setfontsize\large{13bp}{15bp}}
\makeatother

\begin{document}

% HEADING
\begin{flushleft}\small
  Keywords: some, relevant, words, here.
\end{flushleft}
\begin{center}\large
  \textbf{The title is very important}\\[1ex]
  \ul{A. U. Thor}\footnote{An address, Country}
\end{center}

% MAIN TEXT
filler filler filler filler filler filler filler filler

filler filler filler filler filler filler filler filler filler 
filler filler 

{\footnotesize footnotesize\par}

\end{document}

在此处输入图片描述

相关内容