%% %% This is file `typog.sty', %% generated with the docstrip utility. %% %% The original source files were: %% %% typog.dtx (with options: `package') %% %% This is a generated file. %% %% Copyright (C) 2024 by Ch. L. Spiel %% %% This work may be distributed and/or modified under the conditions %% of the LaTeX Project Public License, either version 1.3c of this %% license or (at your option) any later version. The latest version %% of this license is in %% https://www.latex-project.org/lppl.txt %% and version 1.3c or later is part of all distributions of LaTeX %% version 2003/12/01 or later. %% %% This work has the LPPL maintenance status `maintained'. %% %% The Current Maintainer of this work is Ch. L. Spiel. %% %% This work consists of the files typog.dtx and typog.ins %% and the derived files typog.sty, slant-angle.mp, %% crooked-paragraphs.mp, smooth-parshapes.mp, title.mp, %% typog-example.tex, typog-minimal-test.tex, %% typog-without-microtype-test.tex %% typog-grep.pl.in, typog-grep.pl, %% typog-grep.pod, and teximan2latex.sed. %% %% \NeedsTeXFormat{LaTeX2e}[2005/12/01] \ProvidesPackage{typog} [2024/07/08 v0.4 TypoGraphic extensions] \RequirePackage{etoolbox} \RequirePackage{everyhook} \RequirePackage{xkeyval} \newcommand*{\typog@TYPOG}{} \newcommand*{\typoglogo}{\textsf{T\itcorr*{-5}\textsl{y}poG}} \newif\iftypog@debug \newcommand*{\typog@typeout}[1]{\typeout{typog: #1}} \newcommand*{\typog@debug@typeout}[1]{\iftypog@debug\typog@typeout{#1}\fi} \newcounter{typog@@iteration} \ExplSyntaxOn \let\typog@trim@spaces=\tl_trim_spaces:o \ExplSyntaxOff \newcommand{\typog@register@pdfsubstitute}[1]{% \AtBeginDocument{% \ifdefined\pdfstringdefDisableCommands \pdfstringdefDisableCommands{#1}% \fi}} \newif\iftypog@microtype@preloaded \ifdefined\MT@MT \typog@typeout{package microtype preloaded}% \typog@microtype@preloadedtrue \def\typog@require@preloaded@microtype{\relax} \else \typog@microtype@preloadedfalse \def\typog@require@preloaded@microtype {\PackageError{typog}% {package microtype not (pre-)loaded}% {package microtype must be loaded before package typog}} \fi \newif\iftypog@microtype@loaded \AtBeginDocument{ \ifdefined\MT@MT \typog@typeout{package microtype loaded}% \typog@microtype@loadedtrue \def\typog@require@microtype{\relax} \else \typog@microtype@loadedfalse \def\typog@require@microtype {\PackageError{typog}% {package microtype not loaded}% {require package microtype before package typog}}% \fi } \newmuskip\typog@config@mathitalicscorrection \newdimen{\typog@adjust@labelitemi} \newdimen{\typog@adjust@labelitemii} \newdimen{\typog@adjust@labelitemiii} \newdimen{\typog@adjust@labelitemiv} \newdimen{\typog@adjust@lowercase@labelitemi} \newdimen{\typog@adjust@lowercase@labelitemii} \newdimen{\typog@adjust@lowercase@labelitemiii} \newdimen{\typog@adjust@lowercase@labelitemiv} \newdimen{\typog@adjust@uppercase@labelitemi} \newdimen{\typog@adjust@uppercase@labelitemii} \newdimen{\typog@adjust@uppercase@labelitemiii} \newdimen{\typog@adjust@uppercase@labelitemiv} \newlength{\typog@config@textitalicscorrection} \newlength{\typog@config@ligaturekern} \newlength{\typog@config@raisecapitaldash} \newlength{\typog@config@raisecapitalguillemets} \newlength{\typog@config@raisecapitalhyphen} \newlength{\typog@config@raisecapitaltimes} \newlength{\typog@config@raiseguillemets} \newlength{\typog@config@raisefiguredash} \newlength{\typog@config@slashkern} \newcommand*{\typog@config@breakpenalty}{\exhyphenpenalty} \newlength{\typog@dim@unit} \setlength{\typog@dim@unit}{.001em} \newcommand*{\typog@config@trackingttspacing}{300, 90, 60} \newcommand*{\typog@default@shrink@i}{5} \newcommand*{\typog@default@shrink@ii}{10} \newcommand*{\typog@default@shrink@iii}{20} \newcommand*{\typog@shrink@i}{} \newcommand*{\typog@shrink@ii}{} \newcommand*{\typog@shrink@iii}{} \newcommand*{\typog@default@stretch@i}{5} \newcommand*{\typog@default@stretch@ii}{10} \newcommand*{\typog@default@stretch@iii}{20} \newcommand*{\typog@stretch@i}{} \newcommand*{\typog@stretch@ii}{} \newcommand*{\typog@stretch@iii}{} \def\typog@one@of@three#1,#2,#3\relax{\typog@trim@spaces{#1}} \def\typog@two@of@three#1,#2,#3\relax{\typog@trim@spaces{#2}} \def\typog@three@of@three#1,#2,#3\relax{\typog@trim@spaces{#3}} \newcommand*{\typog@triple@get@i}[1]{\expandafter\typog@one@of@three #1\relax} \newcommand*{\typog@triple@get@ii}[1]{\expandafter\typog@two@of@three #1\relax} \newcommand*{\typog@triple@get@iii}[1]{\expandafter\typog@three@of@three #1\relax} \newcommand*{\typog@set@shrink@limits} {\edef\typog@@star{*}% \edef\typog@@limit{\typog@triple@get@i{\typog@config@shrinklimits}}% \unless\ifx\typog@@limit\typog@@star\edef\typog@shrink@i{\number\typog@@limit}\fi \edef\typog@@limit{\typog@triple@get@ii{\typog@config@shrinklimits}}% \unless\ifx\typog@@limit\typog@@star\edef\typog@shrink@ii{\number\typog@@limit}\fi \edef\typog@@limit{\typog@triple@get@iii{\typog@config@shrinklimits}}% \unless\ifx\typog@@limit\typog@@star\edef\typog@shrink@iii{\number\typog@@limit}\fi} \newcommand*{\typog@set@stretch@limits} {\edef\typog@@star{*}% \edef\typog@@limit{\typog@triple@get@i{\typog@config@stretchlimits}}% \unless\ifx\typog@@limit\typog@@star\edef\typog@stretch@i{\number\typog@@limit}\fi \edef\typog@@limit{\typog@triple@get@ii{\typog@config@stretchlimits}}% \unless\ifx\typog@@limit\typog@@star\edef\typog@stretch@ii{\number\typog@@limit}\fi \edef\typog@@limit{\typog@triple@get@iii{\typog@config@stretchlimits}}% \unless\ifx\typog@@limit\typog@@star\edef\typog@stretch@iii{\number\typog@@limit}\fi} \DeclareOptionX{breakpenalty}% {\renewcommand*{\typog@config@breakpenalty}{#1}} \DeclareOptionX{debug}{\typog@debugtrue} \DeclareOptionX{mathitalicscorrection}[.4mu]% {\typog@config@mathitalicscorrection=#1\relax}% \DeclareOptionX{nodebug}{\typog@debugfalse} \DeclareOptionX{textitalicscorrection}[.02em]% {\setlength{\typog@config@textitalicscorrection}{#1}} \DeclareOptionX{ligaturekern}[.033333em]% {\setlength{\typog@config@ligaturekern}{#1}} \DeclareOptionX{lowercaselabelitemadjustments}% {\typog@debug@typeout{lowercaselabelitemadjustments={#1}} \def\typog@@do##1{\addtocounter{typog@@iteration}{1} \global\setlength{\csname typog@adjust@lowercase@labelitem\romannumeral\thetypog@@iteration\endcsname}{##1}} \setcounter{typog@@iteration}{0} \forcsvlist{\typog@@do}{#1}} \newcommand*{\typog@config@lowercaselabelitemadjustments} {\the\typog@adjust@lowercase@labelitemi,\space \the\typog@adjust@lowercase@labelitemii,\space \the\typog@adjust@lowercase@labelitemiii,\space \the\typog@adjust@lowercase@labelitemiv} \DeclareOptionX{raisecapitaldash}[\z@]% {\setlength{\typog@config@raisecapitaldash}{#1}} \DeclareOptionX{raisecapitalguillemets}[\z@]% {\setlength{\typog@config@raisecapitalguillemets}{#1}} \DeclareOptionX{raisecapitalhyphen}[\z@]% {\setlength{\typog@config@raisecapitalhyphen}{#1}} \DeclareOptionX{raisecapitaltimes}[\z@]% {\setlength{\typog@config@raisecapitaltimes}{#1}} \DeclareOptionX{raiseguillemets}[\z@]% {\setlength{\typog@config@raiseguillemets}{#1}} \DeclareOptionX{raisefiguredash}[\z@]% {\setlength{\typog@config@raisefiguredash}{#1}} \DeclareOptionX{raise*}[\z@]% {\setlength{\typog@config@raisecapitaldash}{#1}% \setlength{\typog@config@raisecapitalhyphen}{#1}% \setlength{\typog@config@raisecapitaltimes}{#1}% \setlength{\typog@config@raisefiguredash}{#1}} \DeclareOptionX{shrinklimits}% [\typog@default@shrink@i, \typog@default@shrink@ii, \typog@default@shrink@iii]% {\typog@require@preloaded@microtype \ifx\@onlypreamble\@notprerr \PackageWarning{typog}{option `shrinklimits' can only be used in the preamble}% \else \edef\typog@config@shrinklimits{#1}% \typog@set@shrink@limits \fi} \DeclareOptionX{slashkern}[.05em]% {\setlength{\typog@config@slashkern}{#1}} \DeclareOptionX{stretchlimits}% [\typog@default@stretch@i, \typog@default@stretch@ii, \typog@default@stretch@iii]% {\typog@require@preloaded@microtype \ifx\@onlypreamble\@notprerr \PackageWarning{typog}{option `stretchlimits' can only be used in the preamble}% \else \edef\typog@config@stretchlimits{#1}% \typog@set@stretch@limits \fi} \DeclareOptionX{trackingttspacing}[\typog@config@trackingttspacing]% {\typog@require@preloaded@microtype \ifx\@onlypreamble\@notprerr \PackageWarning{typog}{option `trackingttspacing' can only be used in the preamble}% \else \typog@debug@typeout{trackingttspacing=#1}% \SetTracking[outer spacing={#1}]{encoding=*, family=tt*}{0}% \fi} \DeclareOptionX{uppercaselabelitemadjustments}% {\typog@debug@typeout{uppercaselabelitemadjustments={#1}} \def\typog@@do##1{\addtocounter{typog@@iteration}{1} \setlength{\csname typog@adjust@uppercase@labelitem\romannumeral\thetypog@@iteration\endcsname}{##1}} \setcounter{typog@@iteration}{0} \forcsvlist{\typog@@do}{#1}} \newcommand*{\typog@config@uppercaselabelitemadjustments} {\the\typog@adjust@uppercase@labelitemi,\space \the\typog@adjust@uppercase@labelitemii,\space \the\typog@adjust@uppercase@labelitemiii,\space \the\typog@adjust@uppercase@labelitemiv} \newcommand*{\typog@initialize@options} {\ExecuteOptionsX{ ligaturekern, mathitalicscorrection, textitalicscorrection, raisecapitaldash, raisecapitalhyphen, raisecapitaltimes, raiseguillemets, raisecapitalguillemets, raisefiguredash, slashkern} \ifdefined\MT@MT \unless\ifx\@onlypreamble\@notprerr \ExecuteOptionsX{shrinklimits, stretchlimits} \fi \fi} \typog@initialize@options \ProcessOptionsX \NewDocumentEnvironment{typogsetup}{m} {\def\typog@@arg{#1}% \ifx\typog@@arg\empty \typog@initialize@options \else \setkeys{typog}{#1}% \fi \ignorespaces} {\ignorespacesafterend} \NewDocumentCommand{\typogget}{m}{\csname typog@config@#1\endcsname} \ExplSyntaxOn \cs_generate_variant:Nn \seq_set_split:Nnn {Nne} \cs_new:Npn \typog_get_nth_csname:cnn #1#2#3 { \seq_set_split:Nne \l_tmpa_seq {,} {\cs:w typog@config@#2 \cs_end:} \cs_gset:cpn {#1} {\seq_item:Nn \l_tmpa_seq {#3}} } \cs_new:Npn \typog_get_nth_dimen:nnn #1#2#3 { \seq_set_split:Nne \l_tmpa_seq {,} {\cs:w typog@config@#2 \cs_end:} \dim_set:Nn {#1} {\seq_item:Nn \l_tmpa_seq {#3}} } \NewDocumentCommand{\typoggetnth}{m m m}{ \token_if_dim_register:NTF {#1} { \typog_get_nth_dimen:nnn {#1} {#2} {#3} } { \typog_get_nth_csname:cnn {#1} {#2} {#3} } } \ExplSyntaxOff \ExplSyntaxOn \newcommand*{\typog@round@dim@to@tenths}[1] {\fp_to_decimal:n {round(10 * \dim_to_fp:n{#1} / 1\p@) / 10}} \ExplSyntaxOff \newcommand*{\typog@formatsizeinfo}[3] {#1#3\kernedslash #2#3} \NewDocumentCommand{\fontsizeinfo}{s m} {\global\expandafter\edef\csname typog@fontsize@#2\endcsname {\typog@round@dim@to@tenths{\fontdimen6\font}}% \global\expandafter\edef\csname typog@linespacing@#2\endcsname {\typog@round@dim@to@tenths{\baselineskip}}% \protected\expandafter\gdef\csname #2\endcsname {\@ifnextchar*{\typog@formatsizeinfo {\csname typog@fontsize@#2\endcsname}% {\csname typog@linespacing@#2\endcsname}% {}% no unit \ignorespaces % eat spaces after star \@gobble} % consume the star itself {\typog@formatsizeinfo {\csname typog@fontsize@#2\endcsname}% {\csname typog@linespacing@#2\endcsname}% {\,pt}% decorative unit `pt' }}} \newcommand*{\typog@default@inspect@id@prefix}{a-} \newcounter{typog@inspect@count} \define@key[typog]{typoginspect}{tracingboxes}[\maxdimen]% {\def\typog@@typoginspect@tracingboxes{#1}} \NewDocumentEnvironment{typoginspect}{O{} m} {\def\typog@@typoginspect@tracingboxes{\m@ne}% \setkeys[typog]{typoginspect}{#1}% \edef\typog@@arg{#2}% \ifx\typog@@arg\empty \stepcounter{typog@inspect@count}% \edef\typog@@id{\typog@default@inspect@id@prefix \arabic{typog@inspect@count}}% \else \edef\typog@@id{\typog@trim@spaces{\typog@@arg}}% \fi \typeout{}% \hbadness=\m@ne \vbadness=\m@ne \tracingnone \tracingpages=\@ne \tracingparagraphs=\@ne \showboxbreadth=\typog@@typoginspect@tracingboxes \showboxdepth=\typog@@typoginspect@tracingboxes} {\typeout{}% \ignorespacesafterend} \NewDocumentEnvironment{typoginspectpar}{m} {\typoginspect{#1}} {\par\endtypoginspect} \newcommand*{\typog@allowhyphenation} {\ifvmode \relax \else \nobreak \hskip\z@skip \fi} \unless\ifdefined\allowhyphenation \let\allowhyphenation=\typog@allowhyphenation \fi \NewDocumentCommand{\breakpoint}{s} {\discretionary{}{}{}% \IfBooleanTF{#1}% {\ignorespaces}% {\typog@allowhyphenation}} \typog@register@pdfsubstitute{ \def\breakpoint#1{\if*\detokenize{#1}\ignorespaces\fi}% } \NewDocumentEnvironment{hyphenmin}{o m} {\lefthyphenmin=\IfNoValueTF{#1}{#2}{#1}% \righthyphenmin=#2} {} \newcommand*{\typog@hyphen}{\char`-} \NewDocumentCommand{\nolig}{s o} {\dimen0=\IfNoValueTF{#2}{\typog@config@ligaturekern}{#2\typog@dim@unit}% \IfBooleanTF{#1}% {\kern\dimen0\ignorespaces}% {\discretionary{\typog@hyphen}{}{\kern\dimen0}% \typog@allowhyphenation \IfNoValueF{#2}{\ignorespaces}}} \typog@register@pdfsubstitute{ \RenewExpandableDocumentCommand{\nolig}{s o m}{% \ifx\typog@TYPOG#3\typog@TYPOG \relax \else \ifx\relax#3\relax \relax \else \PackageError{typog} {Missing third argument of \nolig} {Append empty group or \relax after macro invocation} \fi \fi} } \newcommand*{\typog@itcorr@text@unconditional}[1] {\kern#1\typog@config@textitalicscorrection} \newcommand*{\typog@itcorr@text}[1] {\def\typog@@strength{#1}% \dimen0=\fontdimen1\font \ifdim\dimen0=\z@ \typog@itcorr@text@unconditional{\typog@@strength}% \else \kern\typog@@strength\dimen0 \fi} \newcommand*{\typog@itcorr@math}[1] {\mkern#1\typog@config@mathitalicscorrection} \NewDocumentCommand{\itcorr}{s m} {\ifmmode \typog@itcorr@math{#2}% \else \IfBooleanTF{#1}% {\typog@itcorr@text{#2}}% {\typog@itcorr@text@unconditional{#2}}% \fi} \typog@register@pdfsubstitute{ \RenewExpandableDocumentCommand{\itcorr}{s m}{} } \newcommand*{\typog@forwardslash}{\char`/} \NewDocumentCommand{\kernedslash}{s} {\hspace*{\typog@config@slashkern}% \typog@forwardslash \IfBooleanTF{#1}% {\hspace*{\typog@config@slashkern}\ignorespaces}% {\typog@breakpoint\typog@allowhyphenation\hspace*{\typog@config@slashkern}}} \typog@register@pdfsubstitute{ \def\kernedslash#1{\if*\detokenize{#1}/\ignorespaces\else/#1\fi}% } \NewDocumentCommand{\kernedhyphen}{s O{0} m m} {\ifmmode \mspace{\muexpr(#3 mu) * 18 / 1000}% \raisebox{#2\typog@dim@unit}{$\m@th\mathord{-}$}% \mspace{\muexpr(#4 mu) * 18 / 1000}% \else \def\typog@@auto{*}% \def\typog@@optarg{#2}% \hspace*{#3\typog@dim@unit}% \raisebox{\ifx\typog@@optarg\typog@@auto \typog@config@raisecapitalhyphen \else \typog@@optarg\typog@dim@unit \fi}{\typog@hyphen}% \hspace{#4\typog@dim@unit}% \IfBooleanT{#1}{\nobreak}% \fi} \typog@register@pdfsubstitute{ \RenewExpandableDocumentCommand{\kernedhyphen}{s o m m}{-} } \NewDocumentCommand{\leftkernedhyphen}{s O{0} m} {\IfBooleanTF{#1}% {\kernedhyphen*[#2]{#3}{0}\ignorespaces}% {\kernedhyphen[#2]{#3}{0}}} \typog@register@pdfsubstitute{ \RenewExpandableDocumentCommand{\leftkernedhyphen}{s o m}{-} } \NewDocumentCommand{\rightkernedhyphen}{s O{0} m} {\IfBooleanTF{#1}% {\kernedhyphen*[#2]{0}{#3}\ignorespaces}% {\kernedhyphen[#2]{0}{#3}}} \typog@register@pdfsubstitute{ \RenewExpandableDocumentCommand{\rightkernedhyphen}{s o m}{-} } \newcommand*{\typog@breakpoint} {\penalty\typog@config@breakpenalty} \NewDocumentCommand{\capitalhyphen}{s} {\raisebox{\typog@config@raisecapitalhyphen}{\typog@hyphen}% \IfBooleanTF{#1}% {\ignorespaces}% {\typog@breakpoint\typog@allowhyphenation}} \typog@register@pdfsubstitute{ \def\capitalhyphen#1{% \if*\detokenize{#1}% -\ignorespaces \else -#1% \fi} } \NewDocumentCommand{\capitalendash}{s} {\raisebox{\typog@config@raisecapitaldash}{\textendash}% \IfBooleanTF{#1}% {\ignorespaces}% {\typog@breakpoint\typog@allowhyphenation}} \let\capitaldash=\capitalendash \typog@register@pdfsubstitute{ \def\capitalendash#1{% \if*\detokenize{#1}% \textendash\ignorespaces \else \textendash#1% \fi} \let\capitaldash=\capitalendash } \NewDocumentCommand{\capitalemdash}{s} {\raisebox{\typog@config@raisecapitaldash}{\textemdash}% \IfBooleanTF{#1}% {\ignorespaces}% {\typog@breakpoint\typog@allowhyphenation}} \typog@register@pdfsubstitute{ \def\capitalemdash#1{% \if*\detokenize{#1}% \textemdash\ignorespaces \else \textemdash#1% \fi} } \NewDocumentCommand{\figuredash}{s} {\raisebox{\typog@config@raisefiguredash}{\textendash}% \IfBooleanTF{#1}% {\ignorespaces}% {\typog@breakpoint\typog@allowhyphenation}} \typog@register@pdfsubstitute{\let\figuredash=\capitaldash} \NewDocumentCommand{\capitaltimes}{} {\ifmmode \mathbin{\raisebox{\typog@config@raisecapitaltimes}{$\m@th\times$}}% \else \raisebox{\typog@config@raisecapitaltimes}{\texttimes}% \fi} \typog@register@pdfsubstitute{ \RenewExpandableDocumentCommand{\capitaltimes}{}{\texttimes} } \NewDocumentCommand{\singleguillemetleft}{} {\typog@allowhyphenation \raisebox{\typog@config@raiseguillemets}{\guilsinglleft}} \typog@register@pdfsubstitute{\let\singleguillemetleft\guilsinglleft} \NewDocumentCommand{\singleguillemetright}{} {\raisebox{\typog@config@raiseguillemets}{\guilsinglright}% \typog@allowhyphenation} \typog@register@pdfsubstitute{\let\singleguillemetright\guilsinglright} \NewDocumentCommand{\doubleguillemetleft}{} {\typog@allowhyphenation \raisebox{\typog@config@raiseguillemets}{\guillemotleft}} \typog@register@pdfsubstitute{\let\doubleguillemetleft\guillemotleft} \NewDocumentCommand{\doubleguillemetright}{} {\raisebox{\typog@config@raiseguillemets}{\guillemotright}% \typog@allowhyphenation} \typog@register@pdfsubstitute{\let\doubleguillemetright\guillemotright} \NewDocumentCommand{\Singleguillemetleft}{} {\typog@allowhyphenation \raisebox{\typog@config@raisecapitalguillemets}{\guilsinglleft}} \typog@register@pdfsubstitute{\let\Singleguillemetleft\guilsinglleft} \NewDocumentCommand{\Singleguillemetright}{} {\raisebox{\typog@config@raisecapitalguillemets}{\guilsinglright}% \typog@allowhyphenation} \typog@register@pdfsubstitute{\let\Singleguillemetright\guilsinglright} \NewDocumentCommand{\Doubleguillemetleft}{} {\typog@allowhyphenation \raisebox{\typog@config@raisecapitalguillemets}{\guillemotleft}} \typog@register@pdfsubstitute{\let\Doubleguillemetleft\guillemotleft} \NewDocumentCommand{\Doubleguillemetright}{} {\raisebox{\typog@config@raisecapitalguillemets}{\guillemotright}% \typog@allowhyphenation} \typog@register@pdfsubstitute{\let\Doubleguillemetright\guillemotright} \newcommand*{\@typog@uppercase@adjust@labelitem}[1] {\@typog@maybe@patch@itemize \ifstrequal{#1}{*} {\setlength{\typog@adjust@labelitemi} {\typog@adjust@uppercase@labelitemi} \setlength{\typog@adjust@labelitemii} {\typog@adjust@uppercase@labelitemii} \setlength{\typog@adjust@labelitemiii} {\typog@adjust@uppercase@labelitemiii} \setlength{\typog@adjust@labelitemiv} {\typog@adjust@uppercase@labelitemiv}} {\ifcase #1% 0 \relax % outside of any itemize environment \or % 1 \setlength{\typog@adjust@labelitemi} {\typog@adjust@uppercase@labelitemi} \or % 2 \setlength{\typog@adjust@labelitemii} {\typog@adjust@uppercase@labelitemii} \or % 3 \setlength{\typog@adjust@labelitemiii} {\typog@adjust@uppercase@labelitemiii} \or % 4 \setlength{\typog@adjust@labelitemiv} {\typog@adjust@uppercase@labelitemiv} \else \PackageError{typog} {Itemize level out of range} {Valid levels are 1, 2, 3, 4, and *} \fi}} \newcommand*{\@typog@lowercase@adjust@labelitem}[1] {\@typog@maybe@patch@itemize \ifstrequal{#1}{*} {\setlength{\typog@adjust@labelitemi} {\typog@adjust@lowercase@labelitemi} \setlength{\typog@adjust@labelitemii} {\typog@adjust@lowercase@labelitemii} \setlength{\typog@adjust@labelitemiii} {\typog@adjust@lowercase@labelitemiii} \setlength{\typog@adjust@labelitemiv} {\typog@adjust@lowercase@labelitemiv}} {\ifcase #1% 0 \relax % outside of any itemize environment \or % 1 \setlength{\typog@adjust@labelitemi} {\typog@adjust@lowercase@labelitemi} \or % 2 \setlength{\typog@adjust@labelitemii} {\typog@adjust@lowercase@labelitemii} \or % 3 \setlength{\typog@adjust@labelitemiii} {\typog@adjust@lowercase@labelitemiii} \or % 4 \setlength{\typog@adjust@labelitemiv} {\typog@adjust@lowercase@labelitemiv} \else \PackageError{typog} {Itemize level out of range} {Valid levels are 1, 2, 3, 4, and *} \fi}} \newcommand*{\@typog@noadjust@labelitem}[1] {\ifstrequal{#1}{*} {\setlength{\typog@adjust@labelitemi}{\z@} \setlength{\typog@adjust@labelitemii}{\z@} \setlength{\typog@adjust@labelitemiii}{\z@} \setlength{\typog@adjust@labelitemiv}{\z@}} {\ifcase #1% 0 \relax % outside of any itemize environment \or % 1 \setlength{\typog@adjust@labelitemi}{\z@} \or % 2 \setlength{\typog@adjust@labelitemii}{\z@} \or % 3 \setlength{\typog@adjust@labelitemiii}{\z@} \or % 4 \setlength{\typog@adjust@labelitemiv}{\z@} \else \PackageError{typog} {Itemize level out of range} {Valid levels are 1, 2, 3, 4, and *} \fi}} \NewDocumentCommand{\uppercaseadjustlabelitems}{m} {\AfterPreamble{% \ifblank{#1} {\@typog@uppercase@adjust@labelitem{\@itemdepth}} {\forcsvlist{\@typog@uppercase@adjust@labelitem}{#1}}% \ignorespaces}} \NewDocumentCommand{\lowercaseadjustlabelitems}{m} {\AfterPreamble{% \ifblank{#1} {\@typog@lowercase@adjust@labelitem{\@itemdepth}} {\forcsvlist{\@typog@lowercase@adjust@labelitem}{#1}}% \ignorespaces}} \NewDocumentCommand{\noadjustlabelitems}{m} {\ifblank{#1} {\@typog@noadjust@labelitem{\@itemdepth}} {\forcsvlist{\@typog@noadjust@labelitem}{#1}}% \ignorespaces} \newcommand*{\@typog@itemize@patch} {\letcs{\@typog@old@itemitem}{\@itemitem} \edef\@itemitem{@typog@labelitem\romannumeral\the\@itemdepth} \expandafter\def\csname\@itemitem\endcsname {\raisebox{\csname typog@adjust@labelitem\romannumeral\the\@itemdepth\endcsname} {\@typog@old@itemitem}}} \newcommand*{\@typog@patch@itemize} {\ifdefined\enit@itemize@i \patchcmd{\enit@itemize@i} {\expandafter} {\@typog@itemize@patch\expandafter} {\typog@debug@typeout{patching enumitem \string\enit@itemize@i\space succeeded}} {\PackageError{typog} {Patching enumitem macro \string\enit@itemize@i\space failed} {}} \else \patchcmd{\itemize} {\expandafter} {\@typog@itemize@patch\expandafter} {\typog@debug@typeout{patching \string\itemize\space succeeded}} {\PackageError{typog} {Patching plain LaTeX macro \string\itemize\space failed} {}} \fi} \newbool{@typog@itemize@has@been@patched} \newcommand*{\@typog@maybe@patch@itemize} {\ifbool{@typog@itemize@has@been@patched} {\relax} {\@typog@patch@itemize \booltrue{@typog@itemize@has@been@patched}}} \newcommand*{\typog@hairline@width}{.125pt} \newcommand*{\typogadjuststairsfor}[5] {\dimen0=1pt% \count0=#3\relax \unless\ifodd\count0 \advance\count0 by 1% \fi \setcounter{typog@@iteration}{1}% \setbox0=\hbox{#4}% \setbox1=\hbox{}% \loop \ifnum\thetypog@@iteration=\numexpr\count0 / 2\relax \dimen1=2\dimen0 \else \dimen1=\dimen0 \fi \dimen2=\dimexpr#2 * (\thetypog@@iteration - \count0 / 2)\relax \setbox1=\hbox{\unhbox1\raisebox{\dimen2}{\kern\dimen1 #5\kern\dimen1}}% \addtocounter{typog@@iteration}{1}% \unless\ifnum\thetypog@@iteration>\count0 \repeat \mbox{\rlap{\raisebox{\fpeval{#1}\ht0}{\rule{\wd1}{\typog@hairline@width}}}\box1}} \NewDocumentCommand{\typogadjuststairs}{O{.5} m m m} {\begingroup \unless\ifdim #2>\z@ \PackageError{typog} {\string\typogadjuststairs\space non-positive step-size} {step-size must be a positive dimension}% \fi \ifnum #3<1 \PackageError{typog} {\string\typogadjuststairs\space too few number-of-steps} {number-of-steps must at least be 1}% \fi \ifblank{#4} {\PackageError{typog} {sample must not be empty} {supply either some uppercase or some lowercase letters}} {}% \def\arraystretch{1}% \begin{tabular}{@{}c@{}} \typogadjuststairsfor{#1}{#2}{#3}{#4}{\labelitemi} \\ \typogadjuststairsfor{#1}{#2}{#3}{#4}{\labelitemii} \\ \typogadjuststairsfor{#1}{#2}{#3}{#4}{\labelitemiii} \\ \typogadjuststairsfor{#1}{#2}{#3}{#4}{\labelitemiv} \end{tabular} \endgroup} \newcommand*{\typog@uppercase@adjusted@labelitems} {\hbox{\raisebox{\typog@adjust@uppercase@labelitemi}{\labelitemi}% \raisebox{\typog@adjust@uppercase@labelitemii}{\labelitemii}% \raisebox{\typog@adjust@uppercase@labelitemiii}{\labelitemiii}% \raisebox{\typog@adjust@uppercase@labelitemiv}{\labelitemiv}}} \NewDocumentCommand{\typoguppercaseadjustcheck}{O{.5} m} {\setbox0=\hbox{#2}% \setbox1=\typog@uppercase@adjusted@labelitems \mbox{\rlap{\raisebox{\fpeval{#1}\ht0} {\rule{\wd1}{\typog@hairline@width}}}% \box1}} \newcommand*{\typog@lowercase@adjusted@labelitems} {\hbox{\raisebox{\typog@adjust@lowercase@labelitemi}{\labelitemi}% \raisebox{\typog@adjust@lowercase@labelitemii}{\labelitemii}% \raisebox{\typog@adjust@lowercase@labelitemiii}{\labelitemiii}% \raisebox{\typog@adjust@lowercase@labelitemiv}{\labelitemiv}}} \NewDocumentCommand{\typoglowercaseadjustcheck}{O{.5} m} {\setbox0=\hbox{#2}% \setbox1=\typog@lowercase@adjusted@labelitems \mbox{\rlap{\raisebox{\fpeval{#1}\ht0} {\rule{\wd1}{\typog@hairline@width}}}% \box1}} \NewDocumentEnvironment{lastlineraggedleftpar}{} {\lastlinefit=0% \setlength{\leftskip}{\z@ \@plus 1fil}% \setlength{\rightskip}{-\leftskip}% \setlength{\parfillskip}{\leftskip}} {\par} \let\lastlineflushrightpar=\lastlineraggedleftpar \let\endlastlineflushrightpar=\endlastlineraggedleftpar \NewDocumentEnvironment{lastlinecenteredpar}{} {\lastlinefit=0% \setlength{\leftskip}{\z@ \@plus .5fil}% \setlength{\rightskip}{-\leftskip}% \setlength{\parfillskip}{\z@ \@plus 1fil}} {\par} \NewDocumentEnvironment{shortenpar}{} {\advance\looseness by -1 \ifnum\tracingparagraphs>0 \typeout{@ looseness \the\looseness}% \fi} {\par} \NewDocumentEnvironment{prolongpar}{} {\finalhyphendemerits=100000001 \advance\looseness by 1 \ifnum\tracingparagraphs>0 \typeout{@ looseness \the\looseness}% \fi} {\par} \newcommand*{\typog@covernextindentpar@zero@parindent}{2em} \newcommand*{\typog@covernextindentpar@nonzero@parindent}{2\parindent} \NewDocumentEnvironment{covernextindentpar}{o} {\IfNoValueTF{#1} {\ifdim\parindent=\z@ \dimen0=\dimexpr\linewidth - \typog@covernextindentpar@zero@parindent \else \dimen0=\dimexpr\linewidth - \typog@covernextindentpar@nonzero@parindent \fi} {\dimen0=\dimexpr\linewidth - (#1)}% \parfillskip=\dimen0 \@minus \dimen0 \relax} {\par} \newcommand*{\typog@openlastlinepar@zero@parindent}{2em} \newcommand*{\typog@openlastlinepar@nonzero@parindent}{2\parindent} \NewDocumentEnvironment{openlastlinepar}{o} {\IfNoValueTF{#1} {\ifdim\parindent=\z@ \skip0=\typog@openlastlinepar@zero@parindent \@plus 1fil \@minus \typog@openlastlinepar@zero@parindent \else \skip0=\typog@openlastlinepar@nonzero@parindent \@plus 1fil \@minus \typog@openlastlinepar@nonzero@parindent \fi} {\dimen0=\dimexpr#1\relax \skip0=\dimen0 \@plus 1fil \@minus \dimen0} \parfillskip=\skip0} {\par} \newcommand*{\widespacestrength}{1.} \newcommand*{\widespacescale}{1.125} \NewDocumentCommand{\widespace}{s} {\IfBooleanTF{#1}% {\dimen0=\widespacescale\fontdimen2\font}% {\ifdim\fontdimen7\font=\z@ \dimen0=\widespacescale\fontdimen2\font \else \dimen0=\dimexpr\fontdimen2\font + \widespacestrength\fontdimen7\font \fi}% \hskip \glueexpr\dimen0 \@plus \widespacescale\fontdimen3\font \@minus \widespacescale\fontdimen4\font \ignorespaces} \newcommand*{\narrowspacestrength}{.5} \newcommand*{\narrowspacescale}{.9375} \NewDocumentCommand{\narrowspace}{s} {\IfBooleanTF{#1}% {\dimen0=\narrowspacescale\fontdimen2\font}% {\ifdim\fontdimen7\font=\z@ \dimen0=\narrowspacescale\fontdimen2\font \else \dimen0=\dimexpr\fontdimen2\font - \narrowspacestrength\fontdimen7\font \fi}% \hskip \glueexpr\dimen0 \@plus \narrowspacescale\fontdimen3\font \@minus \narrowspacescale\fontdimen4\font \ignorespaces} \NewDocumentEnvironment{loosespacing}{O{1}} {\dimen2=\fontdimen2\font \ifcase #1 \spaceskip=\z@ \or % 1 +5% \spaceskip=1.05\dimen2 \@plus .5\dimen2 \@minus .1\dimen2 \or % 2 +10% \spaceskip=1.1\dimen2 \@plus .5\dimen2 \@minus .1\dimen2 \or % 3 +20% \spaceskip=1.2\dimen2 \@plus .6\dimen2 \@minus .2\dimen2 \else % >= 4 +30% \spaceskip=1.3\dimen2 \@plus .8\dimen2 \@minus .3\dimen2 \fi \ignorespaces} {\ignorespacesafterend} \NewDocumentEnvironment{tightspacing}{O{1}} {\dimen2=\fontdimen2\font \ifcase #1 \spaceskip=\z@ \or % 1 -1.25% \spaceskip=.9875\dimen2 \@plus .0125\dimen2 \@minus .5\dimen2 \or % 2 -2.5% \spaceskip=.975\dimen2 \@plus .025\dimen2 \@minus .5\dimen2 \or % 3 -5% \spaceskip=.95\dimen2 \@plus .05\dimen2 \@minus .5\dimen2 \else % >= 4 -10% \spaceskip=.9\dimen2 \@plus .1\dimen2 \@minus .5\dimen2 \fi \ignorespaces} {\ignorespacesafterend} \NewDocumentEnvironment{setfonttracking}{m} {\edef\MT@letterspace@{#1}% \lsstyle \ignorespaces} {\ignorespacesafterend} \newcommand*{\typog@setup@font@expansion} {\SetExpansion [context = typog@shrink1, shrink = \typog@shrink@i, stretch = 0]% {encoding = {*}}% {} \SetExpansion [context = typog@shrink2, shrink = \typog@shrink@ii, stretch = 0]% {encoding = {*}}% {} \SetExpansion [context = typog@shrink3, shrink = \typog@shrink@iii, stretch = 0]% {encoding = {*}}% {} \SetExpansion [context = typog@stretch1, shrink = 0, stretch = \typog@stretch@i]% {encoding = {*}}% {} \SetExpansion [context = typog@stretch2, shrink = 0, stretch = \typog@stretch@ii]% {encoding = {*}}% {} \SetExpansion [context = typog@stretch3, shrink = 0, stretch = \typog@stretch@iii]% {encoding = {*}}% {} \SetExpansion [context = typog@expand1, shrink = \typog@shrink@i, stretch = \typog@stretch@i]% {encoding = {*}}% {} \SetExpansion [context = typog@expand2, shrink = \typog@shrink@ii, stretch = \typog@stretch@ii]% {encoding = {*}}% {} \SetExpansion [context = typog@expand3, shrink = \typog@shrink@iii, stretch = \typog@stretch@iii]% {encoding = {*}}% {}} \newcommand*{\typog@test@microtype@expansion@feature} {\ifMT@expansion \typog@typeout{microtype preloaded -- font expansion features available}% \def\typog@require@microtype@expansion{\relax} \typog@setup@font@expansion \else \PackageWarning{typog}{microtype preloaded,\space but font expansion is disabled}% \def\typog@require@microtype@expansion {\PackageError{typog} {microtype font expansion disabled} {pass option `expansion' to package microtype}} \fi} \iftypog@microtype@preloaded \typog@test@microtype@expansion@feature \else \def\typog@require@microtype@expansion {\PackageError{typog}% {package microtype not (pre-)loaded, % which is required for typog's font expansion}% {require package microtype before package typog}} \fi \NewDocumentEnvironment{setfontshrink}{O{1}} {\typog@require@microtype@expansion \ifcase#1% 0 \relax \or % 1 \microtypecontext{expansion=typog@shrink1}% \or % 2 \microtypecontext{expansion=typog@shrink2}% \else % >= 3 \microtypecontext{expansion=typog@shrink3}% \fi \ignorespaces} {\ignorespacesafterend} \NewDocumentEnvironment{setfontstretch}{O{1}} {\typog@require@microtype@expansion \ifcase#1% 0 \relax \or % 1 \microtypecontext{expansion=typog@stretch1}% \or % 2 \microtypecontext{expansion=typog@stretch2}% \else % >= 3 \microtypecontext{expansion=typog@stretch3}% \fi \ignorespaces} {\ignorespacesafterend} \NewDocumentEnvironment{setfontexpand}{O{1}} {\typog@require@microtype@expansion \ifcase#1% 0 \relax \or % 1 \microtypecontext{expansion=typog@expand1}% \or % 2 \microtypecontext{expansion=typog@expand2}% \else % >= 3 \microtypecontext{expansion=typog@expand3}% \fi \ignorespaces} {\ignorespacesafterend} \NewDocumentEnvironment{nofontexpansion}{} {\ifdefined\microtypesetup \microtypesetup{expansion=false}% \fi \ignorespaces} {\ignorespacesafterend} \let\nofontexpand=\nofontexpansion \let\endnofontexpand=\endnofontexpansion \NewDocumentEnvironment{nocharprotrusion}{} {\ifdefined\microtypesetup \microtypesetup{protrusion=false}% \fi \ignorespaces} {\ignorespacesafterend} \newcommand*{\typog@scaled@emergencystretch}[1] {\emergencystretch=\ifdim\linewidth=\z@ #1% \else \dimexpr (#1) * \linewidth / \textwidth \fi} \NewDocumentCommand{\slightlysloppy}{O{1}} {\ifcase #1% 0 % \tolerance=200 % \emergencystretch=\z@ % \hfuzz=.1\p@ % \vfuzz=\hfuzz \fussy \or % 1 \pretolerance=165% \tolerance=330% \typog@scaled@emergencystretch{.375em}% \hfuzz=.15\p@ \vfuzz=\hfuzz \or % 2 \pretolerance=265% \tolerance=530% \typog@scaled@emergencystretch{.75em}% \hfuzz=.15\p@ \vfuzz=\hfuzz \or % 3 \pretolerance=435% \tolerance=870% \typog@scaled@emergencystretch{1.125em}% \hfuzz=.2\p@ \vfuzz=\hfuzz \or % 4 \pretolerance=705% \tolerance=1410% \typog@scaled@emergencystretch{1.5em}% \hfuzz=.3\p@ \vfuzz=\hfuzz \or % 5 \pretolerance=1155% \tolerance=2310% \typog@scaled@emergencystretch{1.875em}% \hfuzz=.35\p@ \vfuzz=\hfuzz \or % 6 \pretolerance=1880% \tolerance=3760% \typog@scaled@emergencystretch{2.25em}% \hfuzz=.4\p@ \vfuzz=\hfuzz \or % 7 \pretolerance=3065% \tolerance=6130% \typog@scaled@emergencystretch{2.625em}% \hfuzz=.45\p@ \vfuzz=\hfuzz \else % >= 8 % \tolerance=9999 % \emergencystretch=3em % \hfuzz=.5\p@ % \vfuzz=\hfuzz \sloppy \fi \ignorespaces} \NewDocumentEnvironment{slightlysloppypar}{O{1}} {\par\slightlysloppy[#1]\ignorespaces} {\par} \ExplSyntaxOn \newcommand*{\typog@geometric@mean}[2] {\fp_to_int:n {sqrt((#1) * (#2))}} \ExplSyntaxOff \newcounter{typog@mean@penalty} \NewDocumentCommand{\vtietop}{O{3}} {\setcounter{typog@mean@penalty} {\typog@geometric@mean{\@M}{\clubpenalty}}% \typog@debug@typeout{vtietop: penalties \the\@M--\the\value{typog@mean@penalty}--\the\clubpenalty}% \unless\ifnum\clubpenalty<\@M \PackageWarning{typog}{vtietop: clubpenalty=\the\clubpenalty\space>= 10000}% \fi \ifcase#1% 0 \relax \or % 1 \relax \or % 2 \clubpenalties 3 \@M \value{typog@mean@penalty} \clubpenalty \or % 3 \clubpenalties 4 \@M \@M \value{typog@mean@penalty} \clubpenalty \or % 4 \clubpenalties 5 \@M \@M \@M \value{typog@mean@penalty} \clubpenalty \or % 5 \clubpenalties 6 \@M \@M \@M \@M \value{typog@mean@penalty} \clubpenalty \or % 6 \clubpenalties 7 \@M \@M \@M \@M \@M \value{typog@mean@penalty} \clubpenalty \or % 7 \clubpenalties 8 \@M \@M \@M \@M \@M \value{typog@mean@penalty} \clubpenalty \or % 8 \clubpenalties 9 \@M \@M \@M \@M \@M \value{typog@mean@penalty} \clubpenalty \else % >= 9 \clubpenalties 10 \@M \@M \@M \@M \@M \@M \@M \@M \value{typog@mean@penalty} \clubpenalty \fi} \NewDocumentEnvironment{vtietoppar}{O{3}} {\vtietop[#1]} {\par \ignorespacesafterend} \NewDocumentCommand{\splicevtietop}{O{3}} {\let\typog@old@item=\@item \def\@item[##1]{\typog@old@item[##1]\vtietop[#1]}% \ignorespaces} \ifdefined\SetEnumitemKey \SetEnumitemKey{vtietop}{first=\splicevtietop} \fi \NewDocumentCommand{\vtiebot}{O{3}} {\setcounter{typog@mean@penalty} {\typog@geometric@mean{\@M}{\widowpenalty}}% \typog@debug@typeout{vtiebot: penalties \the\@M--\the\value{typog@mean@penalty}--\the\widowpenalty}% \unless\ifnum\widowpenalty<\@M \PackageWarning{typog}{vtiebot: widowpenalty=\the\widowpenalty\space>= 10000}% \fi \ifcase#1% 0 \relax \or % 1 \relax \or % 2 \widowpenalties 3 \@M \value{typog@mean@penalty} \widowpenalty \or % 3 \widowpenalties 4 \@M \@M \value{typog@mean@penalty} \widowpenalty \or % 4 \widowpenalties 5 \@M \@M \@M \value{typog@mean@penalty} \widowpenalty \or % 5 \widowpenalties 6 \@M \@M \@M \@M \value{typog@mean@penalty} \widowpenalty \or % 6 \widowpenalties 7 \@M \@M \@M \@M \@M \value{typog@mean@penalty} \widowpenalty \or % 7 \widowpenalties 8 \@M \@M \@M \@M \@M \@M \value{typog@mean@penalty} \widowpenalty \or % 8 \widowpenalties 9 \@M \@M \@M \@M \@M \@M \@M \value{typog@mean@penalty} \widowpenalty \else % >= 9 \widowpenalties 10 \@M \@M \@M \@M \@M \@M \@M \@M \value{typog@mean@penalty} \widowpenalty \fi} \NewDocumentEnvironment{vtiebotpar}{O{3}} {\vtiebot[#1]} {\par \ignorespacesafterend} \NewDocumentCommand{\typog@vtiebotdisp}{m} {\setcounter{typog@mean@penalty} {\typog@geometric@mean{\@M}{\displaywidowpenalty}}% \typog@debug@typeout{vtiebotdisp: penalties \the\@M--\the\value{typog@mean@penalty}--\the\displaywidowpenalty}% \unless\ifnum\displaywidowpenalty<\@M \PackageWarning{typog}{vtiebotdisp: displaywidowpenalty=\the\displaywidowpenalty\space>= 10000}% \fi \ifcase#1% 0 \relax \or % 1 \relax \or % 2 \displaywidowpenalties 3 \@M \value{typog@mean@penalty} \displaywidowpenalty \or % 3 \displaywidowpenalties 4 \@M \@M \value{typog@mean@penalty} \displaywidowpenalty \or % 4 \displaywidowpenalties 5 \@M \@M \@M \value{typog@mean@penalty} \displaywidowpenalty \or % 5 \displaywidowpenalties 6 \@M \@M \@M \@M \value{typog@mean@penalty} \displaywidowpenalty \or % 6 \displaywidowpenalties 7 \@M \@M \@M \@M \@M \value{typog@mean@penalty} \displaywidowpenalty \or % 7 \displaywidowpenalties 8 \@M \@M \@M \@M \@M \@M \value{typog@mean@penalty} \displaywidowpenalty \or % 8 \displaywidowpenalties 9 \@M \@M \@M \@M \@M \@M \@M \value{typog@mean@penalty} \displaywidowpenalty \else % >= 9 \displaywidowpenalties 10 \@M \@M \@M \@M \@M \@M \@M \@M \value{typog@mean@penalty} \displaywidowpenalty \fi} \NewDocumentEnvironment{vtiebotdisp}{O{3}} {\typog@vtiebotdisp{#1}} {\ignorespacesafterend} \NewDocumentEnvironment{vtiebotdisptoppar}{O{3}o} {\postdisplaypenalty=\@M \predisplaypenalty=10001% in accordance with package `widows-and-orphans' \edef\typog@@top@lines{\IfNoValueTF{#2}{#1}{#2}}% \edef\typog@@after@display@math{\vtietop[\typog@@top@lines]}% \PushPostHook{display}{\aftergroup\typog@@after@display@math}% \vtiebotdisp[#1]} {\par \PopPostHook{display}% \ignorespacesafterend} \newenvironment*{breakabledisplay}[1][3] {\allowdisplaybreaks[#1]} {\ignorespacesafterend} \newcommand*{\typog@setbaselineskip@iter@limit}{10} \newcommand*{\typog@setbaselineskip@relative@error}{.001} \ExplSyntaxOn \cs_new:Npn \typog@setbaselineskip #1 { \int_set:Nn \l_tmpa_int {1} \int_set:Nn \l_tmpb_int {\typog@setbaselineskip@iter@limit} \dim_set:Nn \l_tmpa_dim {\glueexpr #1} \typog@debug@typeout{\string\setbaselineskip:\space initial\space baselineskip:\space \the\baselineskip} \typog@debug@typeout{\string\setbaselineskip:\space target\space baselineskip:\space \dim_use:N \l_tmpa_dim} \dim_compare:nNnTF {\baselineskip} > {\c_zero_dim} {} { \PackageError{typog} {\string\setbaselineskip:\space baselineskip\space not\space positive} {} } \dim_compare:nNnTF {\l_tmpa_dim} > {\c_zero_dim} {} { \PackageError{typog} {\string\setbaselineskip:\space target\space baselineskip\space must\space be\space positive} {} } \skip_if_eq:nnTF {\l_tmpa_dim} {\glueexpr #1} {} { \PackageWarning{typog} {\string\setbaselineskip:\space argument\space is\space a\space skip;\space will\space ignore\space glue} {} } \fp_set:Nn \l_tmpa_fp {\l_tmpa_dim / \baselineskip} \fp_until_do:nNnn {abs(\l_tmpa_dim / \baselineskip - 1)} < {\typog@setbaselineskip@relative@error} { \setstretch{\fp_use:N \l_tmpa_fp} \fp_set:Nn \l_tmpa_fp {\l_tmpa_fp * \l_tmpa_dim / \baselineskip} \int_incr:N \l_tmpa_int \int_compare:nNnTF {\l_tmpa_int} > {\l_tmpb_int} { \PackageError{typog} {\string\setbaselineskip:\space excessive\space number\space of\space iterations:\space \int_use:N \l_tmpa_int\space >\space \int_use:N \l_tmpb_int} {} } {} } \typog@debug@typeout{\string\setbaselineskip:\space final\space \string\setstretch\space argument:\space \fp_use:N \l_tmpa_fp} \typog@debug@typeout{\string\setbaselineskip:\space final\space baselineskip:\space \the\baselineskip} } \cs_new:Npn \setbaselineskip #1 { \AfterPreamble{\typog@setbaselineskip{#1}} \ignorespaces } \cs_new:Npn \resetbaselineskip { \AfterPreamble{\setstretch{1}} } \dim_new:N \typogfontsize \AfterEndPreamble{ \dim_set:Nn \typogfontsize {\fontdimen6\font} \typog@debug@typeout{\string\typogfontsize = \dim_use:N \typogfontsize\space (at\space begin\space of\space document)} } \cs_new:Npn \setbaselineskippercentage #1 { \AfterPreamble{ \dim_compare:nNnTF {\typogfontsize} > {\c_zero_dim} { \typog@setbaselineskip{ \fp_eval:n {(#1) / 100} \typogfontsize} } { \PackageError{typog} {\string\setbaselineskippercentage:\space \string\typogfontsize <= 0} {Maybe\space \string\typogfontsize\space is\space uninitialized?} } } \ignorespaces } \cs_new:Npn \setleading #1 { \AfterPreamble{ \dim_compare:nNnTF {\typogfontsize} > {\c_zero_dim} { \typog@setbaselineskip{\typogfontsize + \dimexpr #1} } { \PackageError{typog} {\string\setleading:\space \string\typogfontsize <= 0} {Maybe\space \string\typogfontsize\space is\space uninitialized?} } } \ignorespaces } \cs_new:Npn \setleadingpercentage #1 { \AfterPreamble{ \dim_compare:nNnTF {\typogfontsize} > {\c_zero_dim} { \typog@setbaselineskip{ \fp_eval:n {1 + (#1) / 100} \typogfontsize} } { \PackageError{typog} {\string\setleadingpercentage:\space \string\typogfontsize <= 0} {Maybe\space \string\typogfontsize\space is\space uninitialized?} } } \ignorespaces } \ExplSyntaxOff \ExplSyntaxOn \cs_new_eq:NN \typog@repeat \prg_replicate:nn \newcommand*{\typog@mod}[2]{\int_mod:nn{#1}{#2}} \ExplSyntaxOff \newcommand*{\typog@triplet@max@lines}{99} \define@key[typog]{smoothraggedrightshapetriplet}{leftskip}% {\def\typog@@triplet@leftskip{#1}} \define@key[typog]{smoothraggedrightshapetriplet}{parindent}% {\def\typog@@triplet@parindent{#1}} \NewDocumentEnvironment{smoothraggedrightshapetriplet}{O{} m m m} {\def\typog@@triplet@leftskip{\z@}% \def\typog@@triplet@parindent{\z@}% \setkeys*[typog]{smoothraggedrightshapetriplet}{#1}% \skip0=\typog@@triplet@leftskip\relax \skip1=#2\relax \skip2=#3\relax \skip3=#4\relax \typog@debug@typeout{smoothraggedrightshapetriplet: skip0=\the\skip0}% \typog@debug@typeout{smoothraggedrightshapetriplet: skip1=\the\skip1}% \typog@debug@typeout{smoothraggedrightshapetriplet: skip2=\the\skip2}% \typog@debug@typeout{smoothraggedrightshapetriplet: skip3=\the\skip3}% \unless\ifnum\typog@mod{\typog@triplet@max@lines}{3}=0 \PackageError{typog} {Line number of triplet generator\space (\typog@triplet@max@lines) not divisible by 3} {} \fi \edef\typog@@triplet@linespecs{% \glueexpr \skip0 + \typog@@triplet@parindent\relax \glueexpr \skip1 - \typog@@triplet@parindent\relax \skip0 \skip2 \skip0 \skip3 \typog@repeat{\numexpr\typog@triplet@max@lines / 3 - 1} {\skip0 \skip1 \skip0 \skip2 \skip0 \skip3}} \parshape=\typog@triplet@max@lines\typog@@triplet@linespecs\relax} {\par} \newcommand*{\typog@quintuplet@max@lines}{95} \define@key[typog]{smoothraggedrightshapequintuplet}{leftskip} {\def\typog@@quintuplet@leftskip{#1}} \define@key[typog]{smoothraggedrightshapequintuplet}{parindent} {\def\typog@@quintuplet@parindent{#1}} \NewDocumentEnvironment{smoothraggedrightshapequintuplet}{O{} m m m m m} {\def\typog@@quintuplet@leftskip{\z@}% \def\typog@@quintuplet@parindent{\z@}% \setkeys*[typog]{smoothraggedrightshapequintuplet}{#1}% \skip0=\typog@@quintuplet@leftskip \skip1=#2\relax \skip2=#3\relax \skip3=#4\relax \skip4=#5\relax \skip5=#6\relax \typog@debug@typeout{smoothraggedrightshapequintuplet: skip0=\the\skip0}% \typog@debug@typeout{smoothraggedrightshapequintuplet: skip1=\the\skip1}% \typog@debug@typeout{smoothraggedrightshapequintuplet: skip2=\the\skip2}% \typog@debug@typeout{smoothraggedrightshapequintuplet: skip3=\the\skip3}% \typog@debug@typeout{smoothraggedrightshapequintuplet: skip4=\the\skip4}% \typog@debug@typeout{smoothraggedrightshapequintuplet: skip5=\the\skip5}% \unless\ifnum\typog@mod{\typog@quintuplet@max@lines}{5}=0 \PackageError{typog} {Line number of quintuplet generator\space (\typog@quintuplet@max@lines) not divisible by 5} {} \fi \edef\typog@@quintuplet@linespecs{% \glueexpr \skip0 + \typog@@quintuplet@parindent\relax \glueexpr \skip1 - \typog@@quintuplet@parindent\relax \skip0 \skip2 \skip0 \skip3 \skip0 \skip4 \skip0 \skip5 \typog@repeat{\numexpr\typog@quintuplet@max@lines / 5 - 1} {\skip0 \skip1 \skip0 \skip2 \skip0 \skip3 \skip0 \skip4 \skip0 \skip5}} \parshape=\typog@quintuplet@max@lines\typog@@quintuplet@linespecs\relax} {\par} \newcommand*{\typog@septuplet@max@lines}{98} \define@key[typog]{smoothraggedrightshapeseptuplet}{leftskip}% {\def\typog@@septuplet@leftskip{#1}} \define@key[typog]{smoothraggedrightshapeseptuplet}{parindent}% {\def\typog@@septuplet@parindent{#1}} \NewDocumentEnvironment{smoothraggedrightshapeseptuplet}{O{} m m m m m m m} {\def\typog@@septuplet@leftskip{\z@}% \def\typog@@septuplet@parindent{\z@}% \setkeys*[typog]{smoothraggedrightshapeseptuplet}{#1}% \skip0=\typog@@septuplet@leftskip \skip1=#2\relax \skip2=#3\relax \skip3=#4\relax \skip4=#5\relax \skip5=#6\relax \skip6=#7\relax \skip7=#8\relax \typog@debug@typeout{smoothraggedrightshapeseptuplet: skip0=\the\skip0}% \typog@debug@typeout{smoothraggedrightshapeseptuplet: skip1=\the\skip1}% \typog@debug@typeout{smoothraggedrightshapeseptuplet: skip2=\the\skip2}% \typog@debug@typeout{smoothraggedrightshapeseptuplet: skip3=\the\skip3}% \typog@debug@typeout{smoothraggedrightshapeseptuplet: skip4=\the\skip4}% \typog@debug@typeout{smoothraggedrightshapeseptuplet: skip5=\the\skip5}% \typog@debug@typeout{smoothraggedrightshapeseptuplet: skip6=\the\skip6}% \typog@debug@typeout{smoothraggedrightshapeseptuplet: skip7=\the\skip7}% \unless\ifnum\typog@mod{\typog@septuplet@max@lines}{7}=0 \PackageError{typog} {Line number of septuplet generator\space (\typog@septuplet@max@lines) not divisible by 7} {} \fi \edef\typog@@septuplet@linespecs{% \glueexpr \skip0 + \typog@@septuplet@parindent\relax \glueexpr \skip1 - typog@@septuplet@parindent\relax \skip0 \skip2 \skip0 \skip3 \skip0 \skip4 \skip0 \skip5 \skip0 \skip6 \skip0 \skip7 \typog@repeat{\numexpr\typog@septuplet@max@lines / 7 - 1} {\skip0 \skip1 \skip0 \skip2 \skip0 \skip3 \skip0 \skip4 \skip0 \skip5 \skip0 \skip6 \skip0 \skip7}} \parshape=\typog@septuplet@max@lines\typog@@septuplet@linespecs\relax} {\par} \newcommand*{\smoothraggedrightfuzzfactor}{1.0} \newcommand*{\smoothraggedrightgenerator}{triplet} \newlength{\smoothraggedrightleftskip} \newlength{\smoothraggedrightparindent} \newlength{\smoothraggedrightragwidth} \setlength{\smoothraggedrightragwidth}{2em} \newdimen{\typog@fuzzwidth} \define@key[typog]{smoothraggedrightpar}{linewidth}% {\def\typog@@linewidth{#1}} \NewDocumentEnvironment{smoothraggedrightpar}{O{}} {\edef\typog@@linewidth{\linewidth}% \setkeys[typog]{smoothraggedrightpar}{#1}% \edef\typog@@generatorchoice{% \ifnum\pdf@strcmp{\smoothraggedrightgenerator}{triplet}=\z@ 0% \else \ifnum\pdf@strcmp{\smoothraggedrightgenerator}{quintuplet}=\z@ 1% \else \ifnum\pdf@strcmp{\smoothraggedrightgenerator}{septuplet}=\z@ 2% \else \PackageError{typog} {smoothraggedright: unknown generator name} {valid generator names are triplet, quintuplet, and septuplet}% \fi \fi \fi}% \let\typog@@smoothraggedrightleftskip=\smoothraggedrightleftskip \ifnum\@listdepth>0 \addtolength{\typog@@smoothraggedrightleftskip}{\leftmargin}% \fi \typog@fuzzwidth=\smoothraggedrightfuzzfactor\smoothraggedrightragwidth \ifcase\typog@@generatorchoice \typog@fuzzwidth=.25\smoothraggedrightragwidth \typog@debug@typeout{smoothraggedright: generator=triplet, typog@fuzzwidth=\the\typog@fuzzwidth}% \smoothraggedrightshapetriplet[leftskip=\typog@@smoothraggedrightleftskip, parindent=\glueexpr\smoothraggedrightparindent + \parindent, #1]% {\glueexpr \typog@@linewidth - \smoothraggedrightragwidth + \glueexpr \z@ \@plus \typog@fuzzwidth\relax}% (1) {\glueexpr \typog@@linewidth \@minus \typog@fuzzwidth}% (3) {\glueexpr (\typog@@linewidth * 2 - \smoothraggedrightragwidth) / 2 + \glueexpr \z@ \@plus \typog@fuzzwidth \@minus \typog@fuzzwidth\relax}% (2) \or \typog@fuzzwidth=.125\smoothraggedrightragwidth \typog@debug@typeout{smoothraggedright: generator=quintuplet, typog@fuzzwidth=\the\typog@fuzzwidth}% \smoothraggedrightshapequintuplet[leftskip=\typog@@smoothraggedrightleftskip, parindent=\glueexpr\smoothraggedrightparindent + \parindent, #1]% {\glueexpr (\typog@@linewidth * 4 - \smoothraggedrightragwidth * 3) / 4 + \glueexpr \z@ \@plus \typog@fuzzwidth \@minus \typog@fuzzwidth\relax}% (2) {\glueexpr \typog@@linewidth \@minus \typog@fuzzwidth\relax}% (5) {\glueexpr (\typog@@linewidth * 2 - \smoothraggedrightragwidth) / 2 + \glueexpr \z@ \@plus \typog@fuzzwidth \@minus \typog@fuzzwidth\relax}% (3) {\glueexpr (\typog@@linewidth * 4 - \smoothraggedrightragwidth) / 4 + \glueexpr \z@ \@plus \typog@fuzzwidth \@minus \typog@fuzzwidth\relax}% (4) {\glueexpr \typog@@linewidth - \smoothraggedrightragwidth + \glueexpr \z@ \@plus \typog@fuzzwidth\relax}% (1) \or \typog@fuzzwidth=.08333\smoothraggedrightragwidth \typog@debug@typeout{smoothraggedright: generator=septuplet, typog@fuzzwidth=\the\typog@fuzzwidth}% \smoothraggedrightshapeseptuplet[leftskip=\typog@@smoothraggedrightleftskip, parindent=\glueexpr\smoothraggedrightparindent + \parindent, #1]% {\glueexpr (\typog@@linewidth * 3 - \smoothraggedrightragwidth * 2) / 3 + \glueexpr \z@ \@plus \typog@fuzzwidth \@minus \typog@fuzzwidth\relax}% (3) {\glueexpr (\typog@@linewidth * 6 - \smoothraggedrightragwidth) / 6 + \glueexpr \z@ \@plus \typog@fuzzwidth \@minus \typog@fuzzwidth\relax}% (6) {\glueexpr \typog@@linewidth - \smoothraggedrightragwidth + + \glueexpr \z@ \@plus \typog@fuzzwidth\relax}% (1) {\glueexpr (\typog@@linewidth * 3 - \smoothraggedrightragwidth) / 3 + \glueexpr \z@ \@plus \typog@fuzzwidth \@minus \typog@fuzzwidth\relax}% (5) {\glueexpr (\typog@@linewidth * 6 - \smoothraggedrightragwidth * 5) / 6 + \glueexpr \z@ \@plus \typog@fuzzwidth \@minus \typog@fuzzwidth\relax}% (2) {\glueexpr \typog@@linewidth \@minus \typog@fuzzwidth\relax}% (7) {\glueexpr (\typog@@linewidth * 2 - \smoothraggedrightragwidth) / 2 + \glueexpr \z@ \@plus \typog@fuzzwidth \@minus \typog@fuzzwidth\relax}% (4) \fi} {\ifcase\typog@@generatorchoice \endsmoothraggedrightshapetriplet \or \endsmoothraggedrightshapequintuplet \or \endsmoothraggedrightshapeseptuplet \fi} \NewDocumentEnvironment{smoothraggedright}{O{}} {\PushPostHook{par}{\hskip-\parindent\smoothraggedrightpar[#1]\relax}} {\par\PopPostHook{par}} \endinput %% %% End of file `typog.sty'.