Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % 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}
- \RequirePackage{adjustbox}
- \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}]%
- }%
- }%
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement