From e0c6872cf40896c7be36b11dcc744620f10adf1d Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 2 Sep 2019 13:46:59 +0900 Subject: Initial commit --- macros/latex/contrib/bxcalc/LICENSE | 21 ++ macros/latex/contrib/bxcalc/README-ja.md | 63 ++++++ macros/latex/contrib/bxcalc/README.md | 64 ++++++ macros/latex/contrib/bxcalc/bxcalc.sty | 49 +++++ macros/latex/contrib/bxcalc/bxcalcize.pdf | Bin 0 -> 120084 bytes macros/latex/contrib/bxcalc/bxcalcize.sty | 81 +++++++ macros/latex/contrib/bxcalc/bxcalcize.tex | 56 +++++ macros/latex/contrib/bxcalc/bxcalcux.pdf | Bin 0 -> 169738 bytes macros/latex/contrib/bxcalc/bxcalcux.sty | 303 ++++++++++++++++++++++++++ macros/latex/contrib/bxcalc/bxcalcux.tex | 86 ++++++++ macros/latex/contrib/bxcalc/sample-bxcalc.pdf | Bin 0 -> 49697 bytes macros/latex/contrib/bxcalc/sample-bxcalc.tex | 29 +++ 12 files changed, 752 insertions(+) create mode 100644 macros/latex/contrib/bxcalc/LICENSE create mode 100644 macros/latex/contrib/bxcalc/README-ja.md create mode 100644 macros/latex/contrib/bxcalc/README.md create mode 100644 macros/latex/contrib/bxcalc/bxcalc.sty create mode 100644 macros/latex/contrib/bxcalc/bxcalcize.pdf create mode 100644 macros/latex/contrib/bxcalc/bxcalcize.sty create mode 100644 macros/latex/contrib/bxcalc/bxcalcize.tex create mode 100644 macros/latex/contrib/bxcalc/bxcalcux.pdf create mode 100644 macros/latex/contrib/bxcalc/bxcalcux.sty create mode 100644 macros/latex/contrib/bxcalc/bxcalcux.tex create mode 100644 macros/latex/contrib/bxcalc/sample-bxcalc.pdf create mode 100644 macros/latex/contrib/bxcalc/sample-bxcalc.tex (limited to 'macros/latex/contrib/bxcalc') diff --git a/macros/latex/contrib/bxcalc/LICENSE b/macros/latex/contrib/bxcalc/LICENSE new file mode 100644 index 0000000000..fbe40a0146 --- /dev/null +++ b/macros/latex/contrib/bxcalc/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2018 Takayuki YATO (aka. "ZR") + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/macros/latex/contrib/bxcalc/README-ja.md b/macros/latex/contrib/bxcalc/README-ja.md new file mode 100644 index 0000000000..3c3395a57c --- /dev/null +++ b/macros/latex/contrib/bxcalc/README-ja.md @@ -0,0 +1,63 @@ +BXcalc パッケージ +================= + +LaTeX: calc パッケージの機能を拡張する + +本パッケージバンドルは、以下のパッケージからなる: + + * bxcalcize: calc 数式の適応範囲の拡大 + + * bxcalcux: 新しい長さ単位の追加 + +この他に、このバンドルは bxcalc パッケージを含む。このパッケージは単に内部 +で上記のパッケージを一括して読み込む。 + +### 前提環境 + + * フォーマット: LaTeX + * エンジン: 不問 + - 一部の機能は e-TeX 拡張を必要とする。 + * 依存パッケージ: + - calc + +### インストール + + - `*.sty` → $TEXMF/tex/latex/BXcalc + +### ライセンス + +本パッケージは MIT ライセンスの下で配布される。 + +bxcalc パッケージ ― 本体 +------------------------- + +本バンドルに含まれる他のパッケージを一括して読み込む。 + +bxcalcize パッケージ ― calc 数式の適応範囲の拡大 +------------------------------------------------- + +LaTeX 標準命令中の長さ指定でこれまで calc パッケージの数式の使用が +不可だった箇所を可能にする。 + +詳細は解説文書 bxcalcize.pdf を参照。 + +bxcalcux パッケージ ― 新しい長さ単位の追加 +------------------------------------------- + +ユーザが新しい長さ単位を定義して calc 数式で使えるようにする。 + +詳細は解説文書 bxcalcux.pdf を参照。 + +更新履歴 +-------- + + * Version 1.0a 〈2018/01/28〉 + - (試験的) `\usepTeXunits` 命令を追加。 + - バグ修正。 + + * Version 1.0 〈2017/05/21〉 + - 本バンドルとしての最初の公開版。(元々は BXjatool の一部だった。) + +-------------------- +Takayuki YATO (aka. "ZR") +https://github.com/zr-tex8r diff --git a/macros/latex/contrib/bxcalc/README.md b/macros/latex/contrib/bxcalc/README.md new file mode 100644 index 0000000000..19ede34ea6 --- /dev/null +++ b/macros/latex/contrib/bxcalc/README.md @@ -0,0 +1,64 @@ +BXcalc Package +============== + +LaTeX: To extend the functionality of the calc package + +This package bundle consists of the following packages: + + * bxcalcize: To make calc expressions available in more places. + + * bxcalcux: To add user-defined units to the calc syntax. + +In addition, this bundle provides the bxcalc package, which simply loads +the above-mentioned packages internally. + +### System requirement + + * TeX format: LaTeX. + * TeX engine: Anything. + - Some functions requires the e-TeX extension. + * Dependent packages: + - calc + +### Installation + + - `*.sty` → $TEXMF/tex/latex/BXcalc + +### License + +This package is distributed under the MIT License. + +bxcalc package ― main +---------------------- + +This package simply loads all other packages in this bundle. + +bxcalcize package ― to make calc expressions available in more places +---------------------------------------------------------------------- + +Some standard LaTeX commands involving length specification do not allow +the use of calc expressions. This package makes such uses possible. + +See the manual bxcalcize.pdf for detail. + +bxcalcux package ― to add user-defined units to the calc syntax +---------------------------------------------------------------- + +This package enables users to define new length units and use them in +calc expressions. + +See the manual bxcalcux.pdf for detail. + +Revision History +---------------- + + * Version 1.0a 〈2018/01/28〉 + - Bug fix. + + * Version 1.0 〈2017/05/21〉 + - The first public version as this bundle, which has been seperated + from the old BXjatool bundle. + +-------------------- +Takayuki YATO (aka. "ZR") +https://github.com/zr-tex8r diff --git a/macros/latex/contrib/bxcalc/bxcalc.sty b/macros/latex/contrib/bxcalc/bxcalc.sty new file mode 100644 index 0000000000..4dccf4bd60 --- /dev/null +++ b/macros/latex/contrib/bxcalc/bxcalc.sty @@ -0,0 +1,49 @@ +%% +%% This is file 'bxcalc.sty'. +%% +%% Copyright (c) 2018 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{bxcalc}[2018/01/28 v1.0a] +\def\bxqcz@pkgname{bxcalc} + +%--------------------------------------- main + +%% packages +\RequirePackage{calc}[] +\RequirePackage{bxcalcize}[2017/05/21]% v1.0 +\RequirePackage{bxcalcux}[2017/05/21]% v1.0 + +%--------------------------------------- \usepTeXunits + +\ifundef{\kanjiskip}{% + \newrobustcmd*{\usepTeXunits}{% + \DeclareCalcUnit{Q}{\dimexpr0.25mm\relax}% + \DeclareCalcUnit{H}{\dimexpr0.25mm\relax}% + \DeclareCalcUnit{trueQ}{\dimexpr0.25truemm\relax}% + \DeclareCalcUnit{trueH}{\dimexpr0.25truemm\relax}% + \ifdef{\zw}{% + \DeclareCalcUnit{zw}{\zw}%% + \DeclareCalcUnit{zh}{\zw}% + }{\ifdef{\jsZw}{% + \DeclareCalcUnit{zw}{\jsZw}%% + \DeclareCalcUnit{zh}{\jsZw}% + }{}}% + \ifdef{\zh}{% + \DeclareCalcUnit{zh}{\zh}% + }{}% + \let\usepTeXunits\relax + }% +}{%else + \newrobustcmd*{\usepTeXunits}{}% +} + +%--------------------------------------- all done +\endinput +%% EOF diff --git a/macros/latex/contrib/bxcalc/bxcalcize.pdf b/macros/latex/contrib/bxcalc/bxcalcize.pdf new file mode 100644 index 0000000000..7e82495516 Binary files /dev/null and b/macros/latex/contrib/bxcalc/bxcalcize.pdf differ diff --git a/macros/latex/contrib/bxcalc/bxcalcize.sty b/macros/latex/contrib/bxcalc/bxcalcize.sty new file mode 100644 index 0000000000..33342f7cc9 --- /dev/null +++ b/macros/latex/contrib/bxcalc/bxcalcize.sty @@ -0,0 +1,81 @@ +%% +%% This is file 'bxcalcize.sty'. +%% +%% Copyright (c) 2018 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}[2018/01/28 v1.0a] +\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 + +%% 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 \\[] (\@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 diff --git a/macros/latex/contrib/bxcalc/bxcalcize.tex b/macros/latex/contrib/bxcalc/bxcalcize.tex new file mode 100644 index 0000000000..dda2d534e5 --- /dev/null +++ b/macros/latex/contrib/bxcalc/bxcalcize.tex @@ -0,0 +1,56 @@ +\documentclass[a4paper]{article} +\usepackage[scale=0.75]{geometry} +\usepackage{shortvrb} +\MakeShortVerb{\|} +\newcommand{\PkgVersion}{1.0a} +\newcommand{\PkgDate}{2018/01/28} +\newcommand{\Pkg}[1]{\textsf{#1}} +\newcommand{\Meta}[1]{$\langle$\textit{#1}$\rangle$} +\newcommand{\Note}{\par\noindent \textbf{NB:}\quad} +\newcommand{\Means}{~:\quad} +\providecommand{\eTeX}{$\varepsilon$-{\TeX}} +%----------------------------------------------------------- +\begin{document} +\title{The \Pkg{bxcalcize} package} +\author{Takayuki YATO\quad (aka.~``ZR'')} +\date{v\PkgVersion \quad[\PkgDate]} +\maketitle + +%=========================================================== +\section{Overview} + +After loading \Pkg{calc}, most of the length specifications +in {\LaTeX} become aware of that package--- i.e.\ +\Pkg{calc} expressions can be written in place of +simple lengths. +However some commands remain \Pkg{calc}-unaware; for example +one cannot use expressions in the argument of |\hspace|. +This package patches to the {\LaTeX} kernel and eliminates +remaining \Pkg{calc}-unawareness +(as far as I know). + +\paragraph{Supported format} \LaTeX. +\paragraph{Supported engine} Any engine with {\eTeX} extensions. +\paragraph{Prerequisite packages} \Pkg{calc} package. + +%=========================================================== +\section{Package Loading} + +Use |\usepackage| as usual, with no options. +\begin{quote}\small\begin{verbatim} +\usepackage{bxcalcize} +\end{verbatim}\end{quote} + +%=========================================================== +\section{Usage} + +After loading the package, one can use \Pkg{calc} expressions +in the following places: +\begin{itemize} +\item the sole argument of |\hspace|(|*|), |\vspace|(|*|), +and |\addvspace|; +\item the sole optional argument of |\\|. +\end{itemize} + +%=========================================================== +\end{document} diff --git a/macros/latex/contrib/bxcalc/bxcalcux.pdf b/macros/latex/contrib/bxcalc/bxcalcux.pdf new file mode 100644 index 0000000000..3f0f7c4c0b Binary files /dev/null and b/macros/latex/contrib/bxcalc/bxcalcux.pdf differ diff --git a/macros/latex/contrib/bxcalc/bxcalcux.sty b/macros/latex/contrib/bxcalc/bxcalcux.sty new file mode 100644 index 0000000000..489d376a89 --- /dev/null +++ b/macros/latex/contrib/bxcalc/bxcalcux.sty @@ -0,0 +1,303 @@ +%% +%% This is file 'bxcalcux.sty'. +%% +%% Copyright (c) 2018 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{bxcalcux}[2018/01/28 v1.0a] +\def\bxcx@pkgname{bxcalcux} + +%% code guards +\edef\bxcx@restore@codes{% +\catcode33=\the\catcode33% +\catcode34=\the\catcode34% +\catcode63=\the\catcode63% +\endlinechar=\the\endlinechar% +\relax} +\catcode33=12 % +\catcode34=12 %<"> +\catcode63=12 % +\endlinechar\m@ne +\AtEndOfPackage{ +\bxcx@restore@codes +\let\bxcx@restore@codes\@undefined} + +%--------------------------------------- general + +%% packages +\RequirePackage{calc}[] +\RequirePackage{etoolbox}[] +\ifx\numdef\@undefined\endinput\fi + +%% unique tokens +\def\bxcx@end{\noexpand\bxcx@end@} +\def\bxcx@mark{\noexpand\bxcx@mark@} +\def\bxcx@mt{\noexpand\bxcx@mt@} + +%% variables +\let\bxcx@parsed\@empty % parsed token list +\let\bxcx@unit\@empty % unit string now holding +\let\bxcx@unitlc\@empty % unit string now holding, lowercased +\newcount\bxcx@arg@count % # of arguments remaining +\let\bxcx@mode\relax % current mode (N/L/U) +\let\bxcx@g@tempa\@empty % global temp +% \bxcx@arity\CS % arity of functions of which the + % argument should be also parsed +% \bxcx@lc/ % lowercase letter of an alphabet letter +% \bxcx@tl/ % tl that relates to unit +% \bxcx@mluf/ % is there a multichar unit ... ? + +%% Makes the array \bxcx@arity*. +\csdef{bxcx@arity\string\minof}{2} +\csdef{bxcx@arity\string\maxof}{2} +\csdef{bxcx@arity\string\ratio}{2} + +%% Makes the array \bxcx@lc/*. +\@tempcnta=65 +\@tempcntb=97 +\@whilenum\@tempcnta<91 \do{ + \lccode`!=\@tempcnta \lccode`?=\@tempcntb + \lowercase{ + \csdef{bxcx@lc/!}{?} + \csdef{bxcx@lc/?}{?} + } + \advance\@tempcnta\@ne + \advance\@tempcntb\@ne +} + +%% \bxcx@cond\ifXXX...\fi{}{} +\@gobbletwo\if\if \def\bxcx@cond#1\fi{ + #1\expandafter\@firstoftwo + \else \expandafter\@secondoftwo + \fi +} + +%--------------------------------------- unit registration + +%%<*> \newcalcunit{}{} +\newcommand*\newcalcunit[2]{ + \DeclareCalcUnit{#1}{\dimexpr#2\relax} +} + +%%<+> \DeclareCalcUnit{}{} +\newcommand*\DeclareCalcUnit[2]{ + \edef\bxcx@tempa{#1} + \expandafter\bxcx@check@unit@name\meaning\bxcx@tempa\bxcx@end + \bxcx@cond\ifx\bxcx@tempa\@empty\fi{}{%else + \expandafter\bxcx@decl@calc@unit@a\meaning\bxcx@tempa\bxcx@end{#2} + } +} +\def\bxcx@decl@calc@unit@a#1>#2#3\bxcx@end#4{ + \ifstrempty{#3}{ + \csdef{bxcx@tl/#2}{#4} + }{%else + \csdef{bxcx@mluf/\@nameuse{bxcx@lc/#2}}{t} + \let\bxcx@unitlc\@empty + \@tfor\bxcx@tempa:=#2#3\do{ + \eappto\bxcx@unitlc{\@nameuse{bxcx@lc/\bxcx@tempa}} + } + \csdef{bxcx@tl/\bxcx@unitlc}{#4} + } +} +\def\bxcx@check@unit@name#1>#2\bxcx@end{ + \@tfor\bxcx@tempb:=#2\do{ + \ifcsdef{bxcx@lc/\bxcx@tempb}{}{%else + \let\bxcx@tempa\@empty + } + } + \ifx\bxcx@tempa\@empty + \PackageError\bxcx@pkgname + {Illegal unit name '#2'} + \fi +} + +%--------------------------------------- parser + +%%<+> \CUXParseExpr\CS{} +\newcommand*\CUXParseExpr[2]{ + \bxcx@parse{#2} + \let#1=\bxcx@parsed +} + +%% \bxcx@parse +\def\bxcx@parse#1{ + \let\bxcx@parsed\@empty + \bxcx@clear@unit + \let\bxcx@mode=N\relax + \bxcx@parse@a#1@\bxcx@end +} +\def\bxcx@the#1{\expandafter\bxcx@thee\meaning#1} +{\lccode`?=`r \lowercase{\gdef\bxcx@thee#1? #2{#2}}} +\def\bxcx@parse@a{ +%\typeout{[\bxcx@the\bxcx@mode:\the\bxcx@arg@count:\bxcx@unitlc]\expandonce{\bxcx@parsed}} + \futurelet\bxcx@tok\bxcx@parse@b +} +\def\bxcx@parse@b{ +%\typeout{} + \bxcx@cond\ifx\bxcx@tok\@sptoken\fi{ + \bxcx@parse@space + }{\bxcx@cond\ifx\bxcx@tok\bgroup\fi{ + \bxcx@parse@group + }{\bxcx@cond\ifcat\relax\noexpand\bxcx@tok\fi{ + \bxcx@arg@count=\z@ + \bxcx@parse@cs + }{%else + \bxcx@arg@count=\z@ + \bxcx@parse@char + }}} +} +\expandafter\def\expandafter\bxcx@parse@space\space{ + \bxcx@parse@char{ } +} +\def\bxcx@parse@char#1{ + \bxcx@cond\if N\bxcx@mode\fi{ + \ifcsdef{bxcx@lc/#1}{ + \ifcsdef{bxcx@tl/#1}{ + \bxcx@add@unit{#1} + \let\bxcx@mode=L\relax + }{\ifcsdef{bxcx@mluf/\@nameuse{bxcx@lc/#1}}{ + \bxcx@addto@unit{#1} + \let\bxcx@mode=U\relax + }{%else + \appto\bxcx@parsed{#1} + \let\bxcx@mode=L\relax + }} + }{%else + \appto\bxcx@parsed{#1} + } + }{\bxcx@cond\if U\bxcx@mode\fi{ + \ifcsdef{bxcx@lc/#1}{ + \bxcx@addto@unit{#1} + \ifcsdef{bxcx@tl/\bxcx@unitlc}{ + \bxcx@add@unit{\bxcx@unitlc} + \bxcx@clear@unit + \let\bxcx@mode=L\relax + }{} + }{%else + \eappto\bxcx@parsed{\bxcx@unit} + \bxcx@clear@unit + \appto\bxcx@parsed{#1} + \let\bxcx@mode=N\relax + } + }{%else(L\bxcx@mode) + \appto\bxcx@parsed{#1} + \ifcsdef{bxcx@lc/#1}{}{%else + \let\bxcx@mode=N\relax + } + }} + \bxcx@parse@a +} +\def\bxcx@parse@cs#1{ +%\typeout{} + \bxcx@cond\ifx#1\bxcx@end\fi{ + \bxcx@parse@fin + }{%else + \ifcsdef{bxcx@arity\string#1}{ + \bxcx@arg@count=\@nameuse{bxcx@arity\string#1}\relax + }{} + \bxcx@cond\if U\bxcx@mode\fi{ + \eappto\bxcx@parsed{\bxcx@unit} + \bxcx@clear@unit + }{} + \appto\bxcx@parsed{#1} + \let\bxcx@mode=N\relax + \bxcx@parse@a + } +} +\def\bxcx@parse@group#1{ + \bxcx@cond\if U\bxcx@mode\fi{ + \eappto\bxcx@parsed{\bxcx@unit} + \bxcx@clear@unit + }{} + \bxcx@cond\ifnum\bxcx@arg@count>\z@\fi{ +%\typeout{} + \begingroup + \bxcx@parse{#1} + \global\let\bxcx@gtempa\bxcx@parsed + \endgroup + \expandafter\bxcx@parse@group@a\bxcx@gtempa\bxcx@end + \advance\bxcx@arg@count\m@ne + }{%else +%\typeout{} + \appto\bxcx@parsed{{#1}} + } + \let\bxcx@mode=N\relax + \bxcx@parse@a +} +\def\bxcx@parse@group@a#1\bxcx@end{ + \appto\bxcx@parsed{{#1}} +} +\def\bxcx@parse@fin{ + \expandafter\bxcx@parse@fin@a\bxcx@parsed\bxcx@end +} +\def\bxcx@parse@fin@a#1@\bxcx@end{ + \def\bxcx@parsed{#1} +} + +%% \bxcx@add@unit +\def\bxcx@add@unit#1{ +%\typeout{} + \expandafter\bxcx@add@unit@a\csname bxcx@tl/#1 + \endcsname\bxcx@end +} +\def\bxcx@add@unit@a#1\bxcx@end{ + \appto\bxcx@parsed{#1} +} + +%% \bxcx@clear@unit +\def\bxcx@clear@unit{ + \let\bxcx@unit\@empty + \let\bxcx@unitlc\@empty +} + +%% \bxcx@addto@unit +\def\bxcx@addto@unit#1{ + \appto\bxcx@unit{#1} + \eappto\bxcx@unitlc{\@nameuse{bxcx@lc/#1}} +} + +%--------------------------------------- apply the patch + +%% \bxcx@decl@patch\xxx{} +% Here xxx is setlength or addtolength; and gives a new +% definition to that command. The knows two macro +% arguments (#1 & #2) and \CUXxxx is the original definition +% of \xxx. +\def\bxcx@decl@patch#1{ + \expandafter\bxcx@decl@patch@a\csname + \expandafter\@gobble\string#1\space\expandafter\endcsname + \csname CUX\expandafter\@gobble\string#1\endcsname + #1 +} +\def\bxcx@decl@patch@a#1#2#3{ + \def\bxcx@tempa{\protect#1} + \bxcx@cond\ifx\bxcx@tempa#3\fi{ + \let#2=#1 + \def#1##1##2 + }{%else + \let#2=#3 + \DeclareRobustCommand*#3[2] + } +} + +%% Patch to \setlength. +\bxcx@decl@patch\setlength{ + \bxcx@parse{#2} + \CUXsetlength{#1}{\bxcx@parsed} +} + +%% Patch to \addtolength. +\bxcx@decl@patch\addtolength{ + \bxcx@parse{#2} + \CUXaddtolength{#1}{\bxcx@parsed} +} + +%--------------------------------------- all done +\endinput +%% EOF diff --git a/macros/latex/contrib/bxcalc/bxcalcux.tex b/macros/latex/contrib/bxcalc/bxcalcux.tex new file mode 100644 index 0000000000..b2933dbf1b --- /dev/null +++ b/macros/latex/contrib/bxcalc/bxcalcux.tex @@ -0,0 +1,86 @@ +\documentclass[a4paper]{article} +\usepackage[scale=0.75]{geometry} +\usepackage{shortvrb} +\MakeShortVerb{\|} +\newcommand{\PkgVersion}{1.0a} +\newcommand{\PkgDate}{2018/01/28} +\newcommand{\Pkg}[1]{\textsf{#1}} +\newcommand{\Meta}[1]{$\langle$\textit{#1}$\rangle$} +\newcommand{\Note}{\par\noindent \textbf{NB:}\quad} +\newcommand{\Means}{~:\quad} +\providecommand{\eTeX}{$\varepsilon$-{\TeX}} +%----------------------------------------------------------- +\begin{document} +\title{The \Pkg{bxcalcux} package} +\author{Takayuki YATO\quad (aka.~``ZR'')} +\date{v\PkgVersion \quad[\PkgDate]} +\maketitle + +%=========================================================== +\section{Overview} + +This package allows one to create a new unit of length +that can be used in length expressions +of the \Pkg{calc} package. +For example, +\begin{quote}\small\begin{verbatim} +\newcalcunit{thou}{0.07227pt}% thousandth of inch +\setlength{\lengthA}{10thou} +\end{verbatim}\end{quote} +will assign 0.72266\,pt to |\lengthA|.% +\footnote{Using \texttt{0.001in} instead of +\texttt{0.07227pt} will give rather inaccurate results, +since \texttt{0.001in} is evaluated to 0.7277\,pt.} + +\paragraph{Supported format} \LaTeX. +\paragraph{Supported engine} Any engine with {\eTeX} extension. +\paragraph{Prerequisite packages} +\Pkg{calc}, \Pkg{etoolbox}. + +%=========================================================== +\section{Package Loading} + +Use |\usepackage| as usual, with no options. +\begin{quote}\small\begin{verbatim} +\usepackage{bxcalcux} +\end{verbatim}\end{quote} + +%=========================================================== +\section{Usage} + +\begin{itemize} +\item |\newcalcunit{|\Meta{unit}|}{|\Meta{length}|}|\Means +Declares a new unit \Meta{unit} as equal to \Meta{length}. +The unit name must consist only of alphabets. +You can use relative units such as |0.5em| in \Meta{length}, +and such relative units are resolved +when \Pkg{calc} expressions are evaluated. + +\item |\DeclareCalcUnit{|\Meta{unit}|}{|\Meta{text}|}|\Means +\textsl{(for {\TeX}nicians)} +Declares a new unit \Meta{unit} as equal to the unit +expressed by a token list \Meta{text}, +which must form a ``unit of dimen'' (in {\TeX} terminology). +Here is an example. +\begin{quote}\small\begin{verbatim} +\DeclareCalcUnit{ls}{\baselineskip}% current line skip +\end{verbatim}\end{quote} + +\end{itemize} + +%=========================================================== +\section{Notices} + +\begin{itemize} +\item Usually unit names are treated as case-insensitive; +but as exception, unit names with a single letter are +case-sensitive. +\item You must not create a unit name that coincides +with a prefix of existing (built-in or created) units +or any keywords that could be used in \Pkg{calc} expressions +(such as |plus|, |fil|, etc.); otherwise unexpected +things would occur. +\end{itemize} + +%=========================================================== +\end{document} diff --git a/macros/latex/contrib/bxcalc/sample-bxcalc.pdf b/macros/latex/contrib/bxcalc/sample-bxcalc.pdf new file mode 100644 index 0000000000..bcfc5628a5 Binary files /dev/null and b/macros/latex/contrib/bxcalc/sample-bxcalc.pdf differ diff --git a/macros/latex/contrib/bxcalc/sample-bxcalc.tex b/macros/latex/contrib/bxcalc/sample-bxcalc.tex new file mode 100644 index 0000000000..48ed148710 --- /dev/null +++ b/macros/latex/contrib/bxcalc/sample-bxcalc.tex @@ -0,0 +1,29 @@ +\documentclass[a4paper]{article} +\usepackage{bxcalc} +% Declares new units +\newcalcunit{ls}{\baselineskip} +\newcalcunit{tm}{0.05em} +% +\title{Sample document of \textsf{bxcalc}} +\author{ZR} +\date{} +\begin{document} +\maketitle + +\section{Example 1} + +\noindent +The quick brown fox\\[1ex-1ls]% so line skip is 1ex +jump\hspace{6tm}s\hspace{12tm}ov\hspace{2tm}er\\[1ex-1ls] +\hspace*{3tm}t\hspace{4tm}he\hspace{9tm}lazy\hspace{4tm}dog. + +\section{Example 2} + +\noindent +AAAAAAAAAAAAAAAAAAAA\\[\heightof{A}-1ls+2tm] +A\hspace{\widthof{A}*18}A\\[\heightof{A}-1ls+2tm] +A\hspace{\widthof{A}*18}A\\[\heightof{A}-1ls+2tm] +A\hspace{\widthof{A}*18}A\\[\heightof{A}-1ls+2tm] +AAAAAAAAAAAAAAAAAAAA + +\end{document} -- cgit v1.2.3