如何将 \textsc 字体更改为小型大写字母?

如何将 \textsc 字体更改为小型大写字母?

我正在尝试更改\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,请使用sectstytitlesec(网站上有几个问题涉及该问题)。

相关内容