pdf(la)tex
是否可以在文件正文中測試當前字體( for和)是否支援小型大寫字母xe(la)tex
?我想做的是這樣的:
\usepackage{xifthen}
...
\ifthenelse{<small caps are available with the current font>}{%
\textsc{my text}%
}{%
\uppercase{my text}%
}
答案1
編輯
好吧,正如大衛在評論中指出的那樣,僅僅查看\f@encoding/\f@family/\f@series/sc
是不夠的,因為這個命令是在替換期間定義的。因此,人們可能必須記錄是否發生替換:
\documentclass[11pt,a4paper]{scrartcl}
\makeatletter
\def\define@newfont{%
\begingroup
\let\typeout\@font@info
\escapechar\m@ne
\expandafter\expandafter\expandafter
\split@name\expandafter\string\font@name\@nil
\try@load@fontshape % try always
\expandafter\ifx
\csname\curr@fontshape\endcsname \relax
\expandafter\gdef\csname \curr@fontshape/sub\endcsname{}% new
\wrong@fontshape\else
\extract@font\fi
\endgroup}
\newcommand\testsc{%
\ifcsname \f@encoding/\f@family/\f@series/sc/sub\endcsname
no
\else
\ifcsname \f@encoding/\f@family/\f@series/sc\endcsname yes \else no \fi
\fi
\textsc{Aa}}
\makeatother
\begin{document}
\testsc
\bfseries \testsc
\scshape \testsc
\end{document}
編輯2
除了修補之外,\define@newfont
還可以修補\wrong@fontshape
:
\usepackage{etoolbox}
\makeatletter
\preto\wrong@fontshape{\expandafter\gdef\csname \curr@fontshape/sub\endcsname{}}
....