Debian Codegraph @

texmf-dist/source/latex/stealcaps/stealcaps.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (C) 2018-2022 by Ruben Giannotti
4 % <ruben dot giannotti at gmx dot net>
5 % -------------------------------------------------------
6 %
7 % This work may be distributed and/or modified under the
8 % conditions of the LaTeX Project Public License, either
9 % version 1.3c of this license or (at your option) any
10 % later version. The latest version of this license is in
11 % http://www.latex-project.org/lppl.txt
12 % and version 1.3 or later is part of all distributions
13 % of LaTeX version 2005/12/01 or later.
14 %
15 % This work has the LPPL maintenance status `maintained'.
16 %
17 % The Current Maintainer of this work is Ruben Giannotti.
18 %
19 % This work consists of the files
20 % stealcaps.dtx
21 % stealcaps.ins
22 % and the derived file stealcaps.sty.
23 %
24 % \fi
25 %
26 % \iffalse
27 %<*driver>
28 \ProvidesFile{stealcaps.dtx}
29 %</driver>
30 %<package>\NeedsTeXFormat{LaTeX2e}
31 %<package>\ProvidesPackage{stealcaps}
32 %<*package>
33 [2022/11/07 v1.1 Steal small capitals (RG)]
34 %</package>
35 %
36 %<*driver>
37 \documentclass{ltxdoc}
38 \usepackage{amssymb,parskip}
39 \providecommand*\pkg{\textsf}
40 \providecommand*\vrs{\textsf}
41 \providecommand*\option{\textit}
42 \providecommand*\url{\texttt}
43 \providecommand*\email{\texttt}
44 \providecommand*\important{$\blacktriangleright$\space Important note:\space}
45 \EnableCrossrefs
46 \CodelineIndex
47 \begin{document}
48 \DocInput{stealcaps.dtx}
49 \end{document}
50 %</driver>
51 % \fi
52 %
53 % \CheckSum{59}
54 %
55 % \CharacterTable
56 % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
57 % Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
58 % Digits \0\1\2\3\4\5\6\7\8\9
59 % Exclamation \! Double quote \" Hash (number) \#
60 % Dollar \$ Percent \% Ampersand \&
61 % Acute accent \' Left paren \( Right paren \)
62 % Asterisk \* Plus \+ Comma \,
63 % Minus \- Point \. Solidus \/
64 % Colon \: Semicolon \; Less than \<
65 % Equals \= Greater than \> Question mark \?
66 % Commercial at \@ Left bracket \[ Backslash \\
67 % Right bracket \] Circumflex \^ Underscore \_
68 % Grave accent \` Left brace \{ Vertical bar \|
69 % Right brace \} Tilde \~}
70 %
71 %
72 % \changes{v1.0}{2018/01/21}{Initial version}
73 % \changes{v1.1}{2022/11/07}{Added the renewcaps macro for Xe(La)\TeX or Lua(La)\TeX}
74 %
75 % \GetFileInfo{stealcaps.dtx}
76 %
77 % \DoNotIndex{\newcommand,\newenvironment,\!,\@empty,\@gobble,\@gobbletwo}
78 % \DoNotIndex{\@ifpackageloaded,\@ifpackagewith,\@ifundefined,\@namedef}
79 % \DoNotIndex{\@nil,\@onlypreamble,\@tempa,\@tempb,\@tempswafalse,\def}
80 % \DoNotIndex{\@tempswatrue,\^,\-,\active,\begingroup,\catcode,\@car,\@cdr}
81 % \DoNotIndex{\edef,\else,\endgroup,\endinput,\expandafter,\fi,\if}
82 % \DoNotIndex{\if@tempswa,\ifcase,\ifnum,\ifx,\lccode,\let,\lowercase}
83 % \DoNotIndex{\MessageBreak,\next,\number,\numexpr,\or,\PackageError}
84 % \DoNotIndex{\PackageWarning,\PackageWarningNoLine,\strip@prefix,\@@end}
85 % \DoNotIndex{\relax,\space,\string,\DeclareOption,\ProcessOptions}
86 % \DoNotIndex{\meaning,\ifdefined,\csname,\chardef,\endcsname,\protect}
87 % \DoNotIndex{\input,\RequirePackage,\global,\ifcsname,\makeatother}
88 % \DoNotIndex{\@makeother,\the,\toks@}
89 %
90 % \title{The \pkg{stealcaps} package\thanks{This document
91 % corresponds to \pkg{stealcaps}~\fileversion, dated \filedate.}}
92 % \author{Ruben Giannotti\thanks{\email{ruben dot giannotti at gmx dot net}}}
93 %
94 % \maketitle
95 %
96 % This little package is mainly meant to be used
97 % when there is a (TrueType or OpenType) font
98 % that does not provide real small capitals.
99 % Some tend to use uppercased letters
100 % as a workaround -- it is a bad workaround!
101 % In fact, I consider it better practice
102 % to borrow, or steal the small capitals from another font.
103 % And this is exactly what the package does.
104 % This might also be useful in the rare case
105 % that someone does not like the present
106 % small capitals, and wants to change them,
107 % or likes those from another font better.
108 %
109 % However, to achieve the borrowing one does only need to load the package
110 % and specify the name of the target font via the \option{from} option:
111 %
112 % |\usepackage|[\option{from}=\(\langle\)\textit{font name}\(\rangle\)]\{stealcaps\}
113 %
114 % It works with both pdf\LaTeX and its successors Xe\LaTeX{} and Lua\LaTeX.
115 % In the first case you have to make sure the font name is NFSS compliant.
116 % Otherwise, it has to be \pkg{fontspec} compliant.
117 %
118 % As for \vrs{v1.1} in Xe\LaTeX{} and Lua\LaTeX{} you are able
119 % to use
120 %
121 % |\renewcaps{|\(\langle\)\textit{font name}\(\rangle\)|}|
122 %
123 % to override |\scshape| alltogether.
124 % This is mainly meant to be used if you have a single purpose font
125 % that provides only small capitals, e.g.:
126 %
127 % |\renewcaps{Cormorant SC}|.
128 %
129 % \StopEventually{}
130 %
131 % The implementation is rather simple and straightforward.
132 %
133 % As usual, we start by loading what is required:
134 %
135 % \begin{macrocode}
136 \RequirePackage{pgfopts}
137 \RequirePackage{iftex}
138 % \end{macrocode}
139 %
140 % We have to load \pkg{fontspec} in case Xe\LaTeX or Lua\LaTeX,
141 % hence not pdf\LaTeX is in use, to make sure the |\fontspec| command,
142 % used by this package, is guarantied to be defined.
143 %
144 % \begin{macrocode}
145 \ifPDFTeX\else
146 \RequirePackage{fontspec}
147 \fi
148 % \end{macrocode}
149 %
150 % Then we set up the only package option
151 % and commence its processing.
152 %
153 % \begin{macrocode}
154 \pgfkeys{
155 /stc/.cd,
156 from/.store in=\font@from@stc
157 }
158 \ProcessPgfOptions{/stc}
159 % \end{macrocode}
160 %
161 % To distinguish between the operating engines
162 % there are two macros to select the replacement font
163 % (one for \pkg{fontspec} powered ones
164 % and one for good old pdf\LaTeX),
165 % which then are |\let| to |\font@stc|
166 % according to the engine in use.
167 %
168 % \begin{macrocode}
169 \def\font@xe@or@lua@stc{\fontspec}
170 \def\font@pdf@stc{\fontfamily}
171 \def\selectfont@or@relax@stc{\relax}
172 \ifPDFTeX
173 \let\font@stc\font@pdf@stc
174 \let\selectfont@or@relax@stc\selectfont
175 \else
176 \let\font@stc\font@xe@or@lua@stc
177 \fi
178 % \end{macrocode}
179 %
180 % The replacement font is loaded by
181 % employing |\font@stc| inside a group
182 % and substituting the small captials fonts
183 % employing |\DeclareFontShape| with 'ssub'.
184 %
185 % \begin{macrocode}
186 \begingroup
187 \ifx\font@from@stc\@empty\else
188 \font@stc\font@from@stc\selectfont@or@relax@stc
189 \DeclareFontShape{\f@encoding}{\rmdefault}{m}{sc}{%
190 <-> ssub * \f@family/m/sc
191 }{}
192 \DeclareFontShape{\f@encoding}{\rmdefault}{bx}{sc}{%
193 <-> ssub * \f@family/bx/sc
194 }{}
195 \fi
196 \endgroup
197 % \end{macrocode}
198 %
199 % At last there is a user macro for XeTeX and LuaTeX environments
200 % to renew |\scshape| to a dedicated only small capitals TrueType
201 % or OpenType font, e.g. |\renewcaps{Cormorant SC}|.
202 %
203 % \begin{macrocode}
204 \newcommand*\renewcaps[1]{%
205 \ifPDFTeX
206 \typeout{%
207 You tried to use |\renewcaps| in pdfLaTeX,
208 which isn't needed.
209 Or did you mean to use XeLaTeX or LuaLaTeX?
210 }
211 \else
212 \providefontfamily\scshape{#1}%
213 \renewfontfamily\scshape{#1}%
214 \fi
215 }
216 % \end{macrocode}
217 %\Finale
218 \endinput