summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/slantsc/slantsc.dtx
blob: fd7feb5deb349489377511fabdd5f5290937efe5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
% \iffalse meta comment
% File: slantsc.dtx Copyright (C) 2003, 2012 Harald Harders
% \fi
%
% \iffalse
%
%<*driver>
\documentclass{ltxdoc}
\usepackage[T1]{fontenc}
\IfFileExists{slantsc.sty}{\usepackage{slantsc}
 \let\slantscSTYfound\active}{\GenericWarning{slantsc.dtx}{Package
 file slantsc.sty not found (Documentation will be messed up!^^J^^A
 Generate slantsc.sty by (La)TeXing slantsc.ins, process
 slantsc.dtx again)^^J}\stop}
\usepackage{longtable}
\GetFileInfo{slantsc.sty}
\title{The \texttt{slantsc} package}
\author{Harald Harders\\\texttt{harald.harders@gmx.de}}
\date{Version \fileversion, \filedate, printed \today}
\newlength{\tempdima}%
\makeatletter
\renewenvironment{table}[1][]{%
  \@float{table}[#1]%
  \centering%
  \setlength{\tempdima}{\abovecaptionskip}%
  \setlength{\abovecaptionskip}{\belowcaptionskip}%
  \setlength{\belowcaptionskip}{\tempdima}%
  }{%
\end@float
}
\makeatother
\EnableCrossrefs
\CodelineIndex
\DoNotIndex{\def,\edef,\let,\newcommand,\newenvironment,\newcounter}
\DoNotIndex{\setcounter,\space,\if,\else,\fi,\empty,\@empty,\ifx,\fi}
\DoNotIndex{\ifnum,\fi,\expandafter,\DeclareRobustCommand,\ProvidesPackage}
\DoNotIndex{\NeedsTeXFormat,\newif,\not@math@alphabet,\fontshape,\relax}
\DoNotIndex{\selectfont}
\CodelineNumbered
\RecordChanges
\CheckSum{146}
\begin{document}
 \DocInput{slantsc.dtx}
\end{document}
%</driver>
% \fi
%
% \changes{2.11}{2012/01/01}{Update e-mail address}%
% \changes{2.10}{2003/11/09}{State date and version explicitely in
%   \cs{ProvidesPackage}}%
%
% \maketitle
% \begin{abstract}
% \noindent
% This package enables the use of small capitals in different font
% shapes, e.g., slanted or bold slanted for all fonts that provide
% appropriate font shapes.
% The only prerequisite is that the corresponding |fd| file has to
% define the font shapes |scsl| resp.\ |scit| for slanted resp.\
% italic small capitals.
% \end{abstract}
%
% \tableofcontents
%
% \section*{Copyright}
% Copyright 2003, 2012 Harald Harders.
%
% This program can be redistributed and/or modified under the terms
% of the LaTeX Project Public License Distributed from \textsc{ctan}
% archives in directory macros/latex/base/lppl.txt; either
% version 1 of the License, or any later version.
%
%
% \section{The user interface}
%
% To use this package place
% \begin{verbatim}
% \usepackage{slantsc}
% \end{verbatim}
% in the preamble of your document. No options are necessary.
%
% In \LaTeX, you can combine different font parameters like a bold
% series with an italic shape,
% \begin{verbatim}
% {\bfseries\itshape bold italic text}
% \end{verbatim}
% to get {\bfseries\itshape bold italic text}.
% But you are not able to combine two font shapes.
%
% Since \emph{italic, slanted,} and \emph{small caps} are shapes, you
% are not able write in {\slshape\scshape slanted small capitals}, for
% instance.
% This problem is avoided by the package |smallcap|, available from the
% \textsc{ctan} network, which redefines small caps to be a font
% family rather than a shape.
% But what to do if your font provides small capitals in roman style
% and in sans serifs?
% You are not able to access the sans serif version, then.
%
% The |slantsc| package has a different approach.
% It preserves small caps to be a font shape, but it enables to
% combine the small caps shape with the other shapes (upright, italic,
% slanted).
% \DescribeMacro{\upshape}%
% \DescribeMacro{\itshape}%
% \DescribeMacro{\slshape}%
% \DescribeMacro{\scshape}%
% Thus, you use the normal font shape switching commands
% \cs{upshape}, \cs{itshape}, \cs{slshape}, and \cs{scshape}.
% The first three commands act as usual among themselves.
% But if you use the \cs{scshape} command, it just adds the
% information "`small capitals"' to the current font shape.
%
% For example, if the current font shape is italic and you use
% \cs{scshape}, the following text is written in italic small
% capitals:
% \begin{verbatim}
%\itshape This is italic text, \scshape now additionally in Small Capitals.
% \end{verbatim}
% This leads to:
% \begin{quote}
% \itshape This is italic text, \scshape now additionally in Small
% Capitals.
% \end{quote}
% If you are in a small-capitals area, using one of the other font
% switching commands does not affect the small capitals status, but
% the rest of the font shape:
% \begin{verbatim}
%\itshape\scshape This is italic Small Capitals text, \upshape now Upright.
% \end{verbatim}
% This leads to:
% \begin{quote}
% \itshape\scshape This is italic Small Capitals text, \upshape now
% Upright.
% \end{quote}
%
% As usual, the change of font shape is terminated by the end of the
% group, e.g., by using braces:
% \begin{verbatim}
%\itshape This is italic {\scshape with Small Capitals} and without.
% \end{verbatim}
% This leads to:
% \begin{quote}
% \itshape This is italic {\scshape with Small Capitals} and without.
% \end{quote}
% Sometimes, you may want to switch off small capitals without using a
% group.
% \DescribeMacro{\noscshape}%
% To be able to do so, this package provides the \cs{noscshape}
% command, which works as follows:
% \begin{verbatim}
%\itshape This is italic \scshape with Small Capitals \noscshape and without.
% \end{verbatim}
% This leads to:
% \begin{quote}
% \itshape This is italic \scshape with Small Capitals \noscshape and without.
% \end{quote}
%
% \DescribeMacro{\textup}%
% \DescribeMacro{\textit}%
% \DescribeMacro{\textsl}%
% \DescribeMacro{\textsc}%
% \DescribeMacro{\emph}%
% Instead of the font switching commands you may also use the
% \cs{text}\ldots commands \cs{textup}, \cs{textit}, \cs{textsl},
% \cs{textsc} as well as the \cs{emph} command, e.g.
% \begin{verbatim}
%This is \emph{the person \textsc{Harald Harders} who wrote} this
%documentation.
% \end{verbatim}
% which leads to:
% \begin{quote}
% This is \emph{the person \textsc{Harald Harders} who wrote} this
% documentation.
% \end{quote}
%
% \DescribeMacro{\shapedefault}%
% \changes{2.00}{2003/09/17}{Describe \cs{shapedefault} command}%
% If you want another default font than the default, you may redefine
% the \cs{shapedefault} command.
% If you, for instance, want to use an italic small caps font as
% default font, you may simply use 
% \begin{verbatim}
% \renewcommand\shapedefault{\scdefault\itdefault}
% \end{verbatim}
% or
% \begin{verbatim}
% \renewcommand\shapedefault{\scitdefault}
% \end{verbatim}
% in the preamble of your document.
% Both variants are equivalent.
% Notice, that you have to use the command \cs{scdefault} before the
% other command for combined font shapes.
% If you want an upright small caps font as default, just use:
% \begin{verbatim}
% \renewcommand\shapedefault{\scdefault}
% \end{verbatim}
% You may not use \cs{scdefault}\cs{updefault} as argument!
% To switch to the default font, you may use the \cs{defaultfont}
% command.
%
% \DescribeMacro{\fontshape}%
% \changes{2.00}{2003/09/17}{Describe \cs{fontshape} command}%
% If you want to set the font shape directly, using the \cs{fontshape}
% command, e.g.:
% \begin{verbatim}
% \fontshape{\scdefault\itdefault}\selectfont
% \end{verbatim}
% The argument of this command is used in the same way as for the
% \cs{shapedefault} command.
%
%
% \section{Using other fonts than European Modern}
%
% This package works with all fonts that provide slanted and italic
% versions of the small capitals.\footnote{If bold versions are also
% available, they are of course also supported.}
% It is important that these font shapes are declared in a specific
% way that |slantsc| can find them.
%
% |slantsc| uses two additional font shapes |scsl| and |scit|
% which are slanted small caps and italic small caps,
% respectively.\footnote{In this section, I assume that you haven't
% redefined the default values for the different shapes. If you have
% done so, you have do adobt all strings according to your changes.}
% These font shapes have to be declared in the corresponding file with
% the file name \meta{encoding}\meta{font family}|.fd|, e.g.,
% |t1lmr.fd| for the Latin Modern fonts.
% For instance, the Latin Modern font family (version 0.86) provides
% slanted small capitals.
% The corresponding entry in the |fd| file looks like this:
% \begin{verbatim}
%\DeclareFontShape{T1}{lmr}{m}{scsl}%
%     {<-> cork-lmcsco10}{}
% \end{verbatim}
% This command declares to use the font |cork-lmcsco10| for the
% encoding |T1|, the font family |lmr|, the font series |m| (normal)
% and the font shape |scsl| (slanted small caps).
%
% Unfortunately, Latin Modern does not contain the bold variant of the
% slanted small caps.
% But if it had it, the entry would look like that:
% \begin{verbatim}
%\DeclareFontShape{T1}{lmr}{bx}{scsl}%
%     {<-> ...}{}
% \end{verbatim}
%
% Since nearly no font family will contain real italic small caps
% variants, the best approach is to substitute them by slanted
% variants.
% This could be done for Latin Modern by the following commands:
% \begin{verbatim}
%\DeclareFontShape{T1}{lmr}{m}{scit}{<->ssub * lmr/m/scsl}{}
%\DeclareFontShape{T1}{lmr}{bx}{scit}{<->ssub * lmr/bx/scsl}{}
% \end{verbatim}
%
% With the OT1 encoded Computer Modern fonts, slanted small capitals
% are not available, since these fonts do not contain them.
% Nevertheless, the font encoding is not forced to T1 by this package
% because it works with all encodings, if the font shapes are
% present.
%
% \StopEventually{\PrintChanges \PrintIndex}
%
%
% \section{The implementation}
% \iffalse
%<*package>
% \fi
% Heading of the package:
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{slantsc}
  [2012/01/01  v2.11  Provide Slanted an Italic Small Caps]
%    \end{macrocode}
% More robust string comparisons.
%    \begin{macrocode}
\RequirePackage{ifthen}
%    \end{macrocode}
% Declare additional font shapes for European Computer Modern.
% I think, this should normally go to |t1cmr.fd|, but it is never
% read, since it is hardcoded to the format file.
%    \begin{macrocode}
\DeclareFontFamily{T1}{cmr}{}
\DeclareFontShape{T1}{cmr}{m}{scsl}%
{<5><6><7><8><9><10><10.95><12><14.4>%
  <17.28><20.74><24.88><29.86><35.83>genb*ecsc}{}
\DeclareFontShape{T1}{cmr}{bx}{scsl}%
{<5><6><7><8><9><10><10.95><12><14.4>%
  <17.28><20.74><24.88><29.86><35.83>genb*ecoc}{}
%    \end{macrocode}
% Since European Computer Modern does not have real italic Small Caps
% substitute them silently by slanted ones.
%    \begin{macrocode}
\DeclareFontShape{T1}{cmr}{m}{scit}{<->ssub * cmr/m/scsl}{}
\DeclareFontShape{T1}{cmr}{bx}{scit}{<->ssub * cmr/bx/scsl}{}
%    \end{macrocode}
% \begin{macro}{\scitdefault}
% \changes{2.00}{2003/09/17}{Use commands for combined shapes}%
% Default shortcut for italic small caps.
%    \begin{macrocode}
\providecommand*\scitdefault{\scdefault\itdefault}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\scsldefault}
% \changes{2.00}{2003/09/17}{Use commands for combined shapes}%
% Default shortcut for slanted small caps.
%    \begin{macrocode}
\providecommand*\scsldefault{\scdefault\sldefault}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\upshape}
% \changes{2.00}{2003/09/17}{Avoid using booleans because that causes
%   problems with explicit use of \cs{fontshape}}%
% Redefine the macro \cs{upshape} that switches to an upright font. 
% If small caps are ``on'', switch to ordinary small caps, otherwise
% switch to the normal upright font.
%    \begin{macrocode}
\DeclareRobustCommand\upshape{%
  \not@math@alphabet\upshape\relax
%    \end{macrocode}
% Font shape is with small caps.
%    \begin{macrocode}
  \ifthenelse{\equal{\f@shape}{\scdefault}\or
    \equal{\f@shape}{\scitdefault}\or\equal{\f@shape}{\scsldefault}}{%
    \fontshape\scdefault
  }{%
%    \end{macrocode}
% Current font shape is without small caps or not known. 
%    \begin{macrocode}
    \fontshape\updefault
  }%
  \selectfont
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\slshape}
% \changes{2.00}{2003/09/17}{Avoid using booleans because that causes
%   problems with explicit use of \cs{fontshape}}%
% Redefine the macro \cs{slshape} that switches to a slanted font. 
% If small caps are ``on'', switch to slanted small caps, otherwise
% switch to the normal slanted font.
%    \begin{macrocode}
\DeclareRobustCommand\slshape{%
  \not@math@alphabet\slshape\relax
%    \end{macrocode}
% Font shape is with small caps.
%    \begin{macrocode}
  \ifthenelse{\equal{\f@shape}{\scdefault}\or
    \equal{\f@shape}{\scitdefault}\or\equal{\f@shape}{\scsldefault}}{%
    \fontshape\scsldefault
  }{%
%    \end{macrocode}
% Current font shape is without small caps or not known. 
%    \begin{macrocode}
    \fontshape\sldefault
  }%
  \selectfont
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\itshape}
% \changes{2.00}{2003/09/17}{Avoid using booleans because that causes
%   problems with explicit use of \cs{fontshape}}%
% Redefine the macro \cs{itshape} that switches to an italic font. 
% If small caps are ``on'', switch to italic small caps, otherwise
% switch to the normal italic font.
%    \begin{macrocode}
\DeclareRobustCommand\itshape{%
  \not@math@alphabet\itshape\relax
%    \end{macrocode}
% Font shape is with small caps.
%    \begin{macrocode}
  \ifthenelse{\equal{\f@shape}{\scdefault}\or
    \equal{\f@shape}{\scitdefault}\or\equal{\f@shape}{\scsldefault}}{%
    \fontshape\scitdefault
  }{%
%    \end{macrocode}
% Current font shape is without small caps or not known. 
%    \begin{macrocode}
    \fontshape\itdefault
  }%
  \selectfont
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\scshape}
% \changes{2.00}{2003/09/17}{Avoid using booleans because that causes
%   problems with explicit use of \cs{fontshape}}%
% Redefine the macro \cs{scshape} that switches to small capitals.
% If the actual font is italic, switch to italic small caps, if it is
% slanted, switch to slanted small caps, otherwise switch to ordinary
% small caps.
%    \begin{macrocode}
\DeclareRobustCommand\scshape{%
  \not@math@alphabet\scshape\relax
%    \end{macrocode}
% Font shape is with small caps. 
% Nothing to do.
%    \begin{macrocode}
  \ifthenelse{\equal{\f@shape}{\scdefault}\or
    \equal{\f@shape}{\scitdefault}\or\equal{\f@shape}{\scsldefault}}{%
  }{%
%    \end{macrocode}
% Current font shape is without small caps or not known.
%
% If current font is italic, switch to italic small caps.
%    \begin{macrocode}
    \ifthenelse{\equal{\f@shape}{\itdefault}}{%
      \fontshape\scitdefault
    }{%
%    \end{macrocode}
% If current font is slanted, switch to slanted small caps.
%    \begin{macrocode}
      \ifthenelse{\equal{\f@shape}{\sldefault}}{%
        \fontshape\scsldefault
      }{%
%    \end{macrocode}
% If current font is either upright or unknown, switch to upright
% small caps.
%    \begin{macrocode}
        \fontshape\scdefault
      }%
    }%
  }%
  \selectfont
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\noscshape}
% \changes{2.00}{2003/09/17}{Avoid using booleans because that causes
%   problems with explicit use of \cs{fontshape}}%
% Normally, using one of the font-shape commands \cs{upshape},
% \cs{slshape}, \cs{itshape}, and \cs{scshape} switches from one font
% shape to another, forgetting the old font shape.
% The new approach is switches only between \cs{upshape},
% \cs{slshape}, and \cs{itshape}.
% \cs{scshape} is ``added'' to the other font shape information.
% Thus, you are not able to use either of the commands \cs{upshape},
% \cs{slshape}, and \cs{itshape} to switch off small caps again.
% Therefor, you may use the command \cs{noscshape} which preserves the
% used font shape but moves from small caps to ordinary characters.
%    \begin{macrocode}
\DeclareRobustCommand\noscshape{%
  \not@math@alphabet\noscshape\relax
%    \end{macrocode}
% Font shape is with small caps. 
%    \begin{macrocode}
  \ifthenelse{\equal{\f@shape}{\scdefault}\or
    \equal{\f@shape}{\scitdefault}\or\equal{\f@shape}{\scsldefault}}{%
%    \end{macrocode}
% If current font is italic small caps, switch to italic.
%    \begin{macrocode}
    \ifthenelse{\equal{\f@shape}{\scitdefault}}{%
      \fontshape\itdefault
    }{%
%    \end{macrocode}
% If current font is slanted small caps, switch to slanted.
%    \begin{macrocode}
      \ifthenelse{\equal{\f@shape}{\scsldefault}}{%
        \fontshape\sldefault
      }{%
%    \end{macrocode}
% If current font is upright small caps, switch to upright.
%    \begin{macrocode}
        \fontshape\updefault
      }%
    }%
  }{%
%    \end{macrocode}
% Current font shape is without small caps or not known.
% Nothing to do.
%    \begin{macrocode}
  }%
  \selectfont
}
%    \end{macrocode}
% \end{macro}
% \iffalse
%</package>
% \fi
% \Finale