summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/zhlineskip/zhlineskip.sty
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2018-10-29 20:26:44 +0000
committerKarl Berry <karl@freefriends.org>2018-10-29 20:26:44 +0000
commita4549586c1367aed58a4fe6ad910439aa9107f15 (patch)
tree6e63e2ab6878f3012b975843050ecff10e7ed01a /Master/texmf-dist/tex/latex/zhlineskip/zhlineskip.sty
parent860f0bfa3f46428c8f86b121aca88fadeca85647 (diff)
zhlineskip (29oct18)
git-svn-id: svn://tug.org/texlive/trunk@49019 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/zhlineskip/zhlineskip.sty')
-rw-r--r--Master/texmf-dist/tex/latex/zhlineskip/zhlineskip.sty214
1 files changed, 214 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/zhlineskip/zhlineskip.sty b/Master/texmf-dist/tex/latex/zhlineskip/zhlineskip.sty
new file mode 100644
index 00000000000..3d2686eeb2d
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/zhlineskip/zhlineskip.sty
@@ -0,0 +1,214 @@
+%
+% Copyright (C) 2018 by Ruixi Zhang <ruixizhang42@gmail.com>
+%
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3
+% of this license or (at your option) any later version.
+% The latest version of this license is in
+% http://www.latex-project.org/lppl.txt
+% and version 1.3 or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% This work has the LPPL maintenance status `maintained'.
+%
+% The Current Maintainer of this work is Ruixi Zhang.
+%
+% This work consists of the files zhlineskip.sty,
+% zhlineskip-man.tex,
+% zhlineskip-test.tex,
+% Latinmetrics.pdf,
+% CJKmetrics.pdf,
+% README.md
+% and the derived file zhlineskip-man.pdf.
+%
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{zhlineskip}[%
+ 2018/10/28 v1.0c Line spacing for CJK documents]
+
+\RequirePackage{kvoptions}
+\RequirePackage{xintexpr}
+\RequirePackage{etoolbox}
+
+\SetupKeyvalOptions{
+ family=ZhLS,
+ prefix=ZhLS@
+}
+\DeclareStringOption[1.5]{bodytextleadingratio}[1.5]
+\DeclareStringOption[1.48]{footnoteleadingratio}[1.48]
+\DeclareBoolOption[true]{restoremathleading}
+\DeclareBoolOption[false]{UseMSWordMultipleLineSpacing}
+\DeclareStringOption[1.15]{MSWordLineSpacingMultiple}[1.15]
+\DeclareStringOption[1.296875]{MSWordSinglespaceRatio}[1.296875]
+\DeclareDefaultOption{%
+ \PackageError{\@currname}{%
+ Unknown option `\CurrentOption'%
+ }{%
+ Available package options are:\MessageBreak
+ \space\space`bodytextleadingratio',\MessageBreak
+ \space\space`footnoteleadingratio',\MessageBreak
+ \space\space`restoremathleading',\MessageBreak
+ \space\space`UseMSWordMultipleLineSpacing',\MessageBreak
+ \space\space`MSWordLineSpacingMultiple',\MessageBreak
+ \space\space`MSWordSinglespaceRatio'%
+ }%
+}
+\ProcessKeyvalOptions*
+
+\begingroup
+ \normalsize
+ \@tempdima\f@size\p@
+ \@tempdimb\f@baselineskip
+ \edef\@tempnuma{\the\numexpr\@tempdima\relax}%
+ \ifZhLS@UseMSWordMultipleLineSpacing
+ \PackageWarningNoLine{\@currname}{%
+ Use Microsoft Word multiple line spacing\MessageBreak
+ Singlespace to fontsize ratio = `\ZhLS@MSWordSinglespaceRatio'\MessageBreak
+ Multiple = `\ZhLS@MSWordLineSpacingMultiple'%
+ }%
+ \xdef\ZhLS@targetbodyleading{%
+ \@tempnuma*\ZhLS@MSWordSinglespaceRatio*\ZhLS@MSWordLineSpacingMultiple
+ }%
+ \else
+ \xdef\ZhLS@targetbodyleading{%
+ \@tempnuma*\ZhLS@bodytextleadingratio
+ }%
+ \fi
+ \xdef\ZhLS@defaultbodyleading{\the\numexpr\@tempdimb\relax}%
+\endgroup
+\begingroup
+ \footnotesize
+ \@tempdima\f@size\p@
+ \@tempdimb\f@baselineskip
+ \edef\@tempnuma{\the\numexpr\@tempdima\relax}%
+ \ifZhLS@UseMSWordMultipleLineSpacing
+ \xdef\ZhLS@targetfootleading{%
+ \@tempnuma*\ZhLS@MSWordSinglespaceRatio*\ZhLS@MSWordLineSpacingMultiple
+ }%
+ \else
+ \xdef\ZhLS@targetfootleading{%
+ \@tempnuma*\ZhLS@footnoteleadingratio
+ }%
+ \fi
+ \xdef\ZhLS@defaultfootleading{\the\numexpr\@tempdimb\relax}%
+\endgroup
+\edef\ZhLS@bodylinespread{%
+ \xintthefloatexpr\xintexpr
+ \ZhLS@targetbodyleading/\ZhLS@defaultbodyleading\relax\relax
+}
+\edef\ZhLS@footlinespread{%
+ \xintthefloatexpr\xintexpr
+ \ZhLS@targetfootleading/\ZhLS@defaultfootleading\relax\relax
+}
+
+\linespread{\ZhLS@bodylinespread}\selectfont
+
+\patchcmd\@footnotetext
+ {\reset@font}
+ {\def\baselinestretch{\ZhLS@footlinespread}\reset@font}
+ {}{}
+\patchcmd\@mpfootnotetext
+ {\reset@font}
+ {\def\baselinestretch{\ZhLS@footlinespread}\reset@font}
+ {}{}
+\def\ZhLS@resetfootnotesep#1{%
+ \begingroup
+ \footnotesize
+ \linespread{#1}\selectfont
+ \global\footnotesep=\ht\strutbox
+ \endgroup
+}
+\ZhLS@resetfootnotesep{\ZhLS@footlinespread}
+
+\newcommand*\SetTextEnvironmentSinglespace[1]{%
+ \def\ZhLS@textlinespread{#1}%
+}
+\SetTextEnvironmentSinglespace{1}
+\newcommand*\RestoreTextEnvironmentLeading{%
+ \ZhLS@restoretextenvironmentleading
+}
+\def\ZhLS@restoretextenvironmentleading#1{%
+ \AtBeginEnvironment{#1}{%
+ \linespread{\ZhLS@textlinespread}\selectfont\ignorespaces
+ }%
+}
+
+\ifZhLS@restoremathleading
+ \RequirePackage{mathtools}
+ \newcommand*\SetMathEnvironmentSinglespace[1]{%
+ \def\ZhLS@mathlinespread{#1}%
+ }
+ \SetMathEnvironmentSinglespace{1}
+ \newcommand*\RestoreMathEnvironmentLeading{%
+ \ZhLS@restoremathenvironmentleading
+ }
+ \def\ZhLS@restoremathenvironmentleading#1{%
+ \AtBeginEnvironment{#1}{%
+ \linespread{\ZhLS@mathlinespread}\selectfont\ignorespaces
+ }%
+ }
+ \RestoreMathEnvironmentLeading{array}
+ \RestoreMathEnvironmentLeading{matrix}
+ \RestoreMathEnvironmentLeading{pmatrix}
+ \RestoreMathEnvironmentLeading{bmatrix}
+ \RestoreMathEnvironmentLeading{Bmatrix}
+ \RestoreMathEnvironmentLeading{vmatrix}
+ \RestoreMathEnvironmentLeading{Vmatrix}
+ \RestoreMathEnvironmentLeading{cases}
+ \RestoreMathEnvironmentLeading{aligned}
+ \RestoreMathEnvironmentLeading{alignedat}
+ \RestoreMathEnvironmentLeading{gathered}
+ \patchcmd\start@gather
+ {\collect@body}
+ {\linespread{\ZhLS@mathlinespread}\selectfont\collect@body}
+ {}{}
+ \patchcmd\start@align
+ {\collect@body}
+ {\linespread{\ZhLS@mathlinespread}\selectfont\collect@body}
+ {}{}
+ \patchcmd\start@multline
+ {\collect@body}
+ {\linespread{\ZhLS@mathlinespread}\selectfont\collect@body}
+ {}{}
+ \patchcmd\gather@split
+ {\spread@equation}
+ {\linespread{\ZhLS@mathlinespread}\selectfont\spread@equation}
+ {}{}
+ \RestoreMathEnvironmentLeading{matrix*}
+ \RestoreMathEnvironmentLeading{pmatrix*}
+ \RestoreMathEnvironmentLeading{bmatrix*}
+ \RestoreMathEnvironmentLeading{Bmatrix*}
+ \RestoreMathEnvironmentLeading{vmatrix*}
+ \RestoreMathEnvironmentLeading{Vmatrix*}
+ \RestoreMathEnvironmentLeading{cases*}
+ \RestoreMathEnvironmentLeading{dcases}
+ \RestoreMathEnvironmentLeading{dcases*}
+ \RestoreMathEnvironmentLeading{rcases}
+ \RestoreMathEnvironmentLeading{rcases*}
+ \RestoreMathEnvironmentLeading{drcases}
+ \RestoreMathEnvironmentLeading{drcases*}
+ \RestoreMathEnvironmentLeading{multlined}
+ \RestoreMathEnvironmentLeading{lgathered}
+ \RestoreMathEnvironmentLeading{rgathered}
+\else
+ \PackageWarningNoLine{\@currname}{%
+ Leading in multi-line math will be stretched%
+ }%
+ \newcommand*\SetMathEnvironmentSinglespace[1]{%
+ \PackageError{zhlineskip}{%
+ Cannot use \string\SetMathEnvironmentSinglespace\space here%
+ }{%
+ Try loading zhlineskip with option\MessageBreak
+ \space\space`restoremathleading=true'%
+ }%
+ }
+ \newcommand*\RestoreMathEnvironmentLeading[1]{%
+ \PackageError{zhlineskip}{%
+ Cannot use \string\RestoreMathEnvironmentLeading\space here%
+ }{%
+ Try loading zhlineskip with option\MessageBreak
+ \space\space`restoremathleading=true'%
+ }%
+ }
+\fi
+
+\endinput