diff options
Diffstat (limited to 'macros/latex/contrib/bxcalc/bxcalcize.sty')
-rw-r--r-- | macros/latex/contrib/bxcalc/bxcalcize.sty | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/macros/latex/contrib/bxcalc/bxcalcize.sty b/macros/latex/contrib/bxcalc/bxcalcize.sty new file mode 100644 index 0000000000..ebb119ae01 --- /dev/null +++ b/macros/latex/contrib/bxcalc/bxcalcize.sty @@ -0,0 +1,89 @@ +%% +%% This is file 'bxcalcize.sty'. +%% +%% Copyright (c) 2018-2020 Takayuki YATO (aka. "ZR") +%% GitHub: https://github.com/zr-tex8r +%% Twitter: @zr_tex8r +%% +%% This package is distributed under the MIT License. +%% + +%% package declaration +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{bxcalcize}[2020/09/25 v1.1] +\def\bxcy@pkgname{bxcalcize} + +%% code guards +\edef\bxcy@restore@codes{% +\catcode45=\the\catcode45% +\catcode46=\the\catcode46% +\catcode47=\the\catcode47% +\endlinechar=\the\endlinechar% +\relax} +\catcode45=12 % <-> +\catcode46=12 % <.> +\catcode47=12 % </> +\endlinechar\m@ne +\AtEndOfPackage{ +\bxcy@restore@codes +\let\bxcy@restore@codes\relax} + + +%--------------------------------------- general + +%% packages +\RequirePackage{calc}[] +\RequirePackage{etoolbox}[] +\ifx\numdef\@undefined\endinput\fi + +% check kernel version +\@ifl@t@r\fmtversion{2020/10/01}{% + \PackageWarningNoLine\bxcy@pkgname + {Functionality of this package is already\MessageBreak + provided by LaTeX}% + \endinput +}{} + +%% variables +\newdimen\bxcy@resdim + +%--------------------------------------- patches to standard commands + +%% to \hspace / \vspace +\csdef{hspace }{ + \@ifstar{\bxcy@with@calc\@hspacer} + {\bxcy@with@calc\@hspace} +} +\csdef{vspace }{ + \@ifstar{\bxcy@with@calc\@vspacer} + {\bxcy@with@calc\@vspace} +} + +%% to \addvspace +\let\bxcy@org@addvspace\addvspace +\def\addvspace{ + \bxcy@with@calc\bxcy@org@addvspace +} + +%% to \\[<len>] (\@newline) +\patchcmd{\@newline}{ + \@gnewline{\vskip#1} +}{ + \setlength\bxcy@resdim{#1} + \edef\bxcy@tmpa{{\vskip\the\bxcy@resdim}} + \expandafter\@gnewline\bxcy@tmpa +}{}{% failure + \PackageWarningNoLine\bxcy@pkgname + {Patch to \string\@newline\space failed.} +} + +%% \bxcy@with@calc +\def\bxcy@with@calc#1#2{ + \setlength\bxcy@resdim{#2} + \edef\bxcy@tmpa{{\the\bxcy@resdim}} + \expandafter#1\bxcy@tmpa +} + +%--------------------------------------- all done +\endinput +%% EOF |