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
|
% FixSmallCaps.sty
%%%%%%%%%%%%%%
% FROM: http://tex.stackexchange.com/a/262596
%
% Additional: http://tex.stackexchange.com/a/70240
%%%%%%%%%%%%%%
\ProvidesPackage{FixSmallCaps}
%[2017-03-23, Provides fake smallcaps ]
%%%%%%%%%%%%%%
% Fix Smallcaps in fonts that does not have it.
%%%%%%%%%%%%%%
% Usage:
% \usepackage{FixSmallCaps}
%%%%%%%%%%%%%%
% Qirks:
% * Problem with using other enviorments inside this.
% * teletext (textt) does not work as it should. (it is not
% mono-spaced).
%%%%%%%%%%%%%%
% Background:
% When dealing with fonts that do not have small caps
% it can be a hassle to use different text sizes for
% at different points in words to mimic small caps.
%
% This package redefines the behaviour of \textsc{}
% to mimic the small caps in fonts that do not have
% it, by scaling the lower case letters by to a factor
% of 0.75 of the original size and applys \uppercase.
%%%%%%%%%%%%%%
% NO COPYRIGHT
%%%%%%%%%%%%%%
\RequirePackage{xstring}
\RequirePackage{forloop}
\RequirePackage{relsize}
\newcounter{sccounter}
\newcounter{tempStringLength}
\renewcommand{\textsc}[1]{%
% this \betterfakesc command requires these two packages:
% xstring
% forloop
%
% First, we obtain the length of the input string.
\StrLen{#1}[\stringLength]%
%
% Our main forloop will be using a condition of “while less than \stringLength”,
% so we’ll need to increase \stringLength by 1 so the forloop will be able to iterate
% over the entire string. we’ll use a temporary counter tempStringLength to make
% this increase. That’s what the next three lines are about.
\setcounter{tempStringLength}{\stringLength}%
\addtocounter{tempStringLength}{1}%
\def\stringLength{\arabic{tempStringLength}}%
%
% Here is our main loop. We iterate over the characters in the input string,
% and the currentLetter is compared to the case rules we have defined. Basically
% if the currentLetter is any of the lowercase a-z letters, then we apply a
% “fake small caps” effect to it and output it.
\forloop[1]{sccounter}{1}{\value{sccounter}<\stringLength}{%
\StrChar{#1}{\value{sccounter}}[\currentLetter]%
%
\IfEqCase*{\currentLetter}{%
% The lines below are the rules. Obviously more could be added.
{a}{{\uppercase{\relscale{0.75}a}}}%
{b}{{\uppercase{\relscale{0.75}b}}}%
{c}{{\uppercase{\relscale{0.75}c}}}%
{d}{{\uppercase{\relscale{0.75}d}}}%
{e}{{\uppercase{\relscale{0.75}e}}}%
{f}{{\uppercase{\relscale{0.75}f}}}%
{g}{{\uppercase{\relscale{0.75}g}}}%
{h}{{\uppercase{\relscale{0.75}h}}}%
{i}{{\uppercase{\relscale{0.75}i}}}%
{j}{{\uppercase{\relscale{0.75}j}}}%
{k}{{\uppercase{\relscale{0.75}k}}}%
{l}{{\uppercase{\relscale{0.75}l}}}%
{m}{{\uppercase{\relscale{0.75}m}}}%
{n}{{\uppercase{\relscale{0.75}n}}}%
{o}{{\uppercase{\relscale{0.75}o}}}%
{p}{{\uppercase{\relscale{0.75}p}}}%
{q}{{\uppercase{\relscale{0.75}q}}}%
{r}{{\uppercase{\relscale{0.75}r}}}%
{s}{{\uppercase{\relscale{0.75}s}}}%
{t}{{\uppercase{\relscale{0.75}t}}}%
{u}{{\uppercase{\relscale{0.75}u}}}%
{v}{{\uppercase{\relscale{0.75}v}}}%
{w}{{\uppercase{\relscale{0.75}w}}}%
{x}{{\uppercase{\relscale{0.75}x}}}%
{y}{{\uppercase{\relscale{0.75}y}}}%
{z}{{\uppercase{\relscale{0.75}z}}}%
{å}{{\uppercase{\relscale{0.75}å}}}%
{ä}{{\uppercase{\relscale{0.75}ä}}}%
{ö}{{\uppercase{\relscale{0.75}ö}}}%
{ü}{{\uppercase{\relscale{0.75}ü}}}%
}%
% if our \currentLetter isn’t any of the letters we have rules for,
% then just output it now
[{\currentLetter}]%
}%
}%
|