我正在尝试更改\textsc
以使用其他字体生成小写字母。该字体pajp
用于正文,但没有小写字母。该字体paj
包含小写字母,但我不想使用该字体中的任何其他内容。
当前和编辑过的 MWE:
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{pdftexcmds}
\renewcommand{\sfdefault}{paj}
\makeatletter
\let\scshape\relax % to avoid a warning
\DeclareRobustCommand\scshape{%
\not@math@alphabet\scshape\relax
\ifnum\pdf@strcmp{\f@family}{\familydefault}=\z@
\fontfamily{paj}%
\fi
\fontshape\scdefault\selectfont}
\makeatother
\begin{document}
% This font contains small caps that I want to use
% Shows T1/paj/m/sc is defined
\usefont{T1}{paj}{m}{sc}
\fontsize{14pt}{1em}\selectfont
Lorem ipsum dolor (small caps)
% This font is used for everything else and doesn't contain small caps
% Shows T1/pajp/m/n is defined
% When using this \scshape and \textsc don't work
\usefont{T1}{pajp}{m}{n}
\fontsize{14pt}{1em}\selectfont
Lorem ipsum dolor (regular)\\
% Set the default family
\renewcommand{\familydefault}{pjap}
\fontfamily{\familydefault}\selectfont
% This doesn't work
%\fontfamily{pajp}\selectfont
%This is the standard small caps font:
%{\fontshape\scdefault\selectfont Small Caps}
This is the new one: {\scshape Small Caps}
This is the new one: \textsc{Small Caps}
\sffamily
Let's try \textsc{Small Caps}
\end{document}
第一张图片来自上面的 MWE。它可以工作。如果我使用注释掉\usefont{T1}{pajp}{m}{n}
或\fontfamily{pajp}\selectfont
选择常规字体,则会生成第二张图片。它没有像小写字母那样的正确字体。
在后一种情况下,错误消息是:
LaTeX Font Warning: Font shape `T1/pajp/m/sc' undefined
(Font) using `T1/pajp/m/n' instead on input line 41.
LaTeX Font Warning: Font shape `T1/pajp/m/sc' undefined
(Font) using `T1/pajp/m/n' instead on input line 43.
答案1
的替换文本\scdefault
应为适合第四个参数的字符串\usefont
;其默认值为sc
。您的paj
是姓氏。
重新定义\scshape
:
\makeatletter
\let\scshape\relax % to avoid a warning
\DeclareRobustCommand\scshape{%
\not@math@alphabet\scshape\relax
\ifnum\pdf@strcmp{\f@family}{\familydefault}=\z@
\fontfamily{qbk}%
\fi
\fontshape\scdefault\selectfont}
\makeatother
这需要包pdftexcmds
。
重新定义后\scshape
,衬线字体上下文将与
\usefont{<current encoding>}{paj}{<current weight>}{sc}
完整的代码,其中一些视觉冲突的字体仅作为示例使用;使用您最喜欢的字体。
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{pdftexcmds}
\renewcommand{\sfdefault}{qag} % TeX Gyre Adventor has small caps
\makeatletter
\let\scshape\relax % to avoid a warning
\DeclareRobustCommand\scshape{%
\not@math@alphabet\scshape\relax
\ifnum\pdf@strcmp{\f@family}{\familydefault}=\z@
\fontfamily{qbk}%
\fi
\fontshape\scdefault\selectfont}
\makeatother
\begin{document}
This is the standard small caps font:
{\fontshape\scdefault\selectfont Small Caps}
This is the new one: {\scshape Small Caps}
This is the new one: \textsc{Small Caps}
\sffamily
Let's try \textsc{Small Caps}
\end{document}
要指定 使用的字体\section
,请使用sectsty
或titlesec
(网站上有几个问题涉及该问题)。