View difference between Paste ID: 9RxccGQL and PKBxquxa
SHOW: | | - or go back to the newest paste.
1
% FixSmallCaps.sty
2
%%%%%%%%%%%%%%
3
% FROM: http://tex.stackexchange.com/a/262596
4
%
5
% Additional: http://tex.stackexchange.com/a/70240
6
%%%%%%%%%%%%%%
7
8
9
\ProvidesPackage{FixSmallCaps}
10
%[2017-03-23, Provides fake smallcaps ]
11
%%%%%%%%%%%%%%
12
% Fix Smallcaps in fonts that does not have it.
13
%%%%%%%%%%%%%%
14
% Usage:
15
% \usepackage{FixSmallCaps}
16
%%%%%%%%%%%%%%
17
% Qirks:
18
% * Problem with using other enviorments inside this.
19
% * teletext (textt) does not work as it should. (it is not
20
%   mono-spaced).
21
%%%%%%%%%%%%%%
22
% Background:
23
% When dealing with fonts that do not have small caps
24
% it can be a hassle to use different text sizes for
25
% at different points in words to mimic small caps.
26
%
27
% This package redefines the behaviour of \textsc{}
28
% to mimic the small caps in fonts that do not have
29
% it, by scaling the lower case letters by to a factor
30
% of 0.75 of the original size and applys \uppercase.
31
%%%%%%%%%%%%%%
32
% NO COPYRIGHT
33
%%%%%%%%%%%%%%
34
35
\RequirePackage{xstring}
36
\RequirePackage{forloop}
37
\RequirePackage{relsize}
38-
\RequirePackage{adjustbox}
38+
39
\newcounter{sccounter}
40
\newcounter{tempStringLength}
41
42
43
\renewcommand{\textsc}[1]{%
44
    % this \betterfakesc command requires these two packages:
45
    %   xstring
46
    %   forloop
47
    %
48
    % First, we obtain the length of the input string.
49
    \StrLen{#1}[\stringLength]%
50
    %
51
    % Our main forloop will be using a condition of “while less than \stringLength”,
52
    % so we’ll need to increase \stringLength by 1 so the forloop will be able to iterate 
53
    % over the entire string. we’ll use a temporary counter tempStringLength to make
54
    % this increase. That’s what the next three lines are about.
55
    \setcounter{tempStringLength}{\stringLength}%
56
    \addtocounter{tempStringLength}{1}%
57
    \def\stringLength{\arabic{tempStringLength}}%
58
    %
59
    % Here is our main loop. We iterate over the characters in the input string,
60
    % and the currentLetter is compared to the case rules we have defined. Basically
61
    % if the currentLetter is any of the lowercase a-z letters, then we apply a 
62
    % “fake small caps” effect to it and output it.
63
    \forloop[1]{sccounter}{1}{\value{sccounter}<\stringLength}{%
64
        \StrChar{#1}{\value{sccounter}}[\currentLetter]%
65
        %
66
        \IfEqCase*{\currentLetter}{%
67
          % The lines below are the rules. Obviously more could be added.
68
          {a}{{\uppercase{\relscale{0.75}a}}}%
69
          {b}{{\uppercase{\relscale{0.75}b}}}%
70
          {c}{{\uppercase{\relscale{0.75}c}}}%
71
          {d}{{\uppercase{\relscale{0.75}d}}}%
72
          {e}{{\uppercase{\relscale{0.75}e}}}%
73
          {f}{{\uppercase{\relscale{0.75}f}}}%
74
          {g}{{\uppercase{\relscale{0.75}g}}}%
75
          {h}{{\uppercase{\relscale{0.75}h}}}%
76
          {i}{{\uppercase{\relscale{0.75}i}}}%
77
          {j}{{\uppercase{\relscale{0.75}j}}}%
78
          {k}{{\uppercase{\relscale{0.75}k}}}%
79
          {l}{{\uppercase{\relscale{0.75}l}}}%
80
          {m}{{\uppercase{\relscale{0.75}m}}}%
81
          {n}{{\uppercase{\relscale{0.75}n}}}%
82
          {o}{{\uppercase{\relscale{0.75}o}}}%
83
          {p}{{\uppercase{\relscale{0.75}p}}}%
84
          {q}{{\uppercase{\relscale{0.75}q}}}%
85
          {r}{{\uppercase{\relscale{0.75}r}}}%
86
          {s}{{\uppercase{\relscale{0.75}s}}}%
87
          {t}{{\uppercase{\relscale{0.75}t}}}%
88
          {u}{{\uppercase{\relscale{0.75}u}}}%
89
          {v}{{\uppercase{\relscale{0.75}v}}}%
90
          {w}{{\uppercase{\relscale{0.75}w}}}%
91
          {x}{{\uppercase{\relscale{0.75}x}}}%
92
          {y}{{\uppercase{\relscale{0.75}y}}}%
93
          {z}{{\uppercase{\relscale{0.75}z}}}%
94
          {å}{{\uppercase{\relscale{0.75}å}}}%
95
          {ä}{{\uppercase{\relscale{0.75}ä}}}%
96
          {ö}{{\uppercase{\relscale{0.75}ö}}}%
97
          {ü}{{\uppercase{\relscale{0.75}ü}}}%
98
        }%
99
        % if our \currentLetter isn’t any of the letters we have rules for,
100
        % then just output it now
101
        [{\currentLetter}]%
102
    }%
103
}%