| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% Copyright (C) 2018-2023 by F. Pantigny |
| 4 |
% ----------------------------------- |
| 5 |
% |
| 6 |
% This file may be distributed and/or modified under the |
| 7 |
% conditions of the LaTeX Project Public License, either version 1.3 |
| 8 |
% of this license or (at your option) any later version. |
| 9 |
% The latest version of this license is in: |
| 10 |
% |
| 11 |
% http://www.latex-project.org/lppl.txt |
| 12 |
% |
| 13 |
% and version 1.3 or later is part of all distributions of LaTeX |
| 14 |
% version 2005/12/01 or later. |
| 15 |
% |
| 16 |
% \fi |
| 17 |
% \iffalse |
| 18 |
\def\myfileversion{1.2a} |
| 19 |
\def\myfiledate{2023/02/08} |
| 20 |
% |
| 21 |
% |
| 22 |
%<*batchfile> |
| 23 |
\begingroup |
| 24 |
\input l3docstrip.tex |
| 25 |
\keepsilent |
| 26 |
\usedir{tex/latex/cascade} |
| 27 |
\preamble |
| 28 |
|
| 29 |
Copyright (C) 2018-2023 by F. Pantigny |
| 30 |
----------------------------------- |
| 31 |
|
| 32 |
This file may be distributed and/or modified under the |
| 33 |
conditions of the LaTeX Project Public License, either version 1.3 |
| 34 |
of this license or (at your option) any later version. |
| 35 |
The latest version of this license is in: |
| 36 |
|
| 37 |
http://www.latex-project.org/lppl.txt |
| 38 |
|
| 39 |
and version 1.3 or later is part of all distributions of LaTeX |
| 40 |
version 2005/12/01 or later. |
| 41 |
|
| 42 |
\endpreamble |
| 43 |
\askforoverwritefalse |
| 44 |
\endgroup |
| 45 |
%</batchfile> |
| 46 |
% |
| 47 |
%<@@=cascade> |
| 48 |
%<*driver> |
| 49 |
\documentclass[dvipsnames]{l3doc}% option dvipsnames is for xcolor (loaded by tikz) |
| 50 |
\usepackage{xltxtra} |
| 51 |
\usepackage{geometry} |
| 52 |
\geometry{left=2.8cm,right=2.8cm,top=2.5cm,bottom=2.5cm,papersize={21cm,29.7cm}} |
| 53 |
\setlength{\fboxsep}{0pt} |
| 54 |
\usepackage{tikz} |
| 55 |
\usetikzlibrary{calc} |
| 56 |
\usepackage{cascade} |
| 57 |
\hfuzz=5cm |
| 58 |
\def\interitem{\vskip 7mm plus 2 mm minus 3mm} |
| 59 |
\def\emphase{\bgroup\color{RoyalPurple}\let\next=} |
| 60 |
\fvset{commandchars=\~\#\@,formatcom={\color{gray}}} |
| 61 |
\parindent 0pt |
| 62 |
\skip\footins = 2\bigskipamount |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
\begin{document} |
| 67 |
\DocInput{cascade.dtx} |
| 68 |
\end{document} |
| 69 |
%</driver> |
| 70 |
% \fi |
| 71 |
% \title{The package \pkg{cascade}\thanks{This document corresponds to the |
| 72 |
% version~\myfileversion\space of \pkg{cascade}, at the date of~\myfiledate.}} |
| 73 |
% \author{F. Pantigny \\ \texttt{[email protected]}} |
| 74 |
% |
| 75 |
% \maketitle |
| 76 |
% |
| 77 |
% \begin{abstract} |
| 78 |
% The LaTeX package \pkg{cascade} provides a command |\Cascade| to do |
| 79 |
% constructions to present mathematical demonstrations with successive braces |
| 80 |
% for the deductions. The package \pkg{cascade} provides also a command |
| 81 |
% |\Edacsac| which creates similar structures but with |
| 82 |
% braces going backwards. |
| 83 |
% \end{abstract} |
| 84 |
% |
| 85 |
% |
| 86 |
% |
| 87 |
% \vspace{1cm} |
| 88 |
% \section{The command \textbackslash Cascade} |
| 89 |
% |
| 90 |
% The package \pkg{cascade} provides a command |\Cascade| which allows |
| 91 |
% constructions like the following where the size of the right brace is computed |
| 92 |
% on only a part of the LaTeX elements composed on the left. |
| 93 |
% \begin{center} |
| 94 |
% \Cascade{$\det(A) = \begin{vmatrix}3&4\\ -1&7\end{vmatrix}\neq 0$} |
| 95 |
% {and, therefore, $A$ is inversible} |
| 96 |
% {} |
| 97 |
% {yet $AX=Y$} |
| 98 |
% hence, $X = A^{-1}Y$ |
| 99 |
% \end{center} |
| 100 |
% |
| 101 |
% \medskip |
| 102 |
% \begin{Verbatim} |
| 103 |
% ~emphase#\Cascade@{$\det(A) = \begin{vmatrix}3&4\\ -1&7\end{vmatrix}\neq 0$} |
| 104 |
% {and, therefore, $A$ is inversible} |
| 105 |
% {} |
| 106 |
% {yet $AX=Y$} |
| 107 |
% hence, $X = A^{-1}Y$ |
| 108 |
% \end{Verbatim} |
| 109 |
% |
| 110 |
% |
| 111 |
% \interitem |
| 112 |
% The command |\Cascade| takes its four arguments as follow : |
| 113 |
% \begin{center} |
| 114 |
% \Cascade{\fbox{\hbox to 2cm{\vrule height 18 pt depth 5 pt width 0pt\hfil \texttt{\#1}\hfil}}}% |
| 115 |
% {\fbox{\hbox to 3cm{\vrule height 10 pt depth 12 pt width 0pt\hfil \texttt{\#2}\hfil}}}% |
| 116 |
% {\fbox{\hbox to 2.5cm{\vrule height 15 pt depth 14 pt width 0pt\hfil \texttt{\#3}\hfil}}}% |
| 117 |
% {\fbox{\hbox to 1.7cm{\vrule height 12 pt depth 5 pt width 0pt\hfil \texttt{\#4}\hfil}}} |
| 118 |
% \end{center} |
| 119 |
% |
| 120 |
% \interitem |
| 121 |
% The commands |\Cascade| can be nested as in the following example : |
| 122 |
% \begin{center} |
| 123 |
% \Cascade{\ShortCascade{$(BH) \perp (AC)$}{$(OC) \perp (AC)$}} |
| 124 |
% {hence\enskip $(BH) \parallel (OC)$} |
| 125 |
% {\ShortCascade{$(CH) \perp (AB)$}{$(OB) \perp (AB)$}} |
| 126 |
% {hence\enskip $(CH) \parallel (OB)$} |
| 127 |
% hence $(OBHC)$ is a parallelogram |
| 128 |
% \end{center} |
| 129 |
% |
| 130 |
% \interitem |
| 131 |
% For the legibility of such constructions, a simplified version of |\Cascade| |
| 132 |
% is available, named |\ShortCascade|. |
| 133 |
% |
| 134 |
% The code |\ShortCascade{X}{Y}| is merely a shortcut for the code |
| 135 |
% |\Cascade{}{X}{}{Y}|. |
| 136 |
% |
| 137 |
% \medskip |
| 138 |
% The preceding example can be coded with two commands |\ShortCascade| and an |
| 139 |
% encompassing command |\Cascade|: |
| 140 |
% \begin{Verbatim} |
| 141 |
% ~emphase#\Cascade@{~emphase#\ShortCascade@{$(BH) \perp (AC)$} |
| 142 |
% {$(OC) \perp (AC)$}} |
| 143 |
% {hence\enskip $(BH) \parallel (OC)$} |
| 144 |
% {~emphase#\ShortCascade@{$(CH) \perp (AB)$} |
| 145 |
% {$(OB) \perp (AB)$}} |
| 146 |
% {hence\enskip $(CH) \parallel (OB)$} |
| 147 |
% hence $(OBHC)$ is a parallelogram |
| 148 |
% \end{Verbatim} |
| 149 |
% |
| 150 |
% |
| 151 |
% \bigskip |
| 152 |
% \section{The option t} |
| 153 |
% |
| 154 |
% With the option |t| in the encompassing command |\Cascade|, a whole strucutre |
| 155 |
% of nested commands |\Cascade| is aligned on the top line. |
| 156 |
% |
| 157 |
% When the key |t| is used, if we wish to add some text after the structure, we |
| 158 |
% have to put that text between angle brackets in order to have that text |
| 159 |
% aligned with the last brace. |
| 160 |
% |
| 161 |
% \begin{Verbatim} |
| 162 |
% \begin{enumerate} |
| 163 |
% \item \Cascade~emphase#[t]@{\ShortCascade{$(BH) \perp (AC)$}{$(OC) \perp (AC)$}} |
| 164 |
% {hence\enskip $(BH) \parallel (OC)$} |
| 165 |
% {\Cascade{}{$(CH) \perp (AB)$}{}{$(OB) \perp (AB)$}} |
| 166 |
% {hence\enskip $(CH) \parallel (OB)$} |
| 167 |
% ~emphase#<hence $(OBHC)$ is a parallelogram>@ |
| 168 |
% \end{enumerate} |
| 169 |
% \end{Verbatim} |
| 170 |
% |
| 171 |
% |
| 172 |
% \begin{enumerate} |
| 173 |
% \item \Cascade[t]{\ShortCascade{$(BH) \perp (AC)$}{$(OC) \perp (AC)$}} |
| 174 |
% {hence\enskip $(BH) \parallel (OC)$} |
| 175 |
% {\Cascade{}{$(CH) \perp (AB)$}{}{$(OB) \perp (AB)$}} |
| 176 |
% {hence\enskip $(CH) \parallel (OB)$} |
| 177 |
% <hence $(OBHC)$ is a parallelogram> |
| 178 |
% \end{enumerate} |
| 179 |
% |
| 180 |
% |
| 181 |
% |
| 182 |
% \bigskip |
| 183 |
% \section{Other options} |
| 184 |
% |
| 185 |
% \begin{itemize} |
| 186 |
% \item The option |space-between| is a TeX dimension described on the following |
| 187 |
% figure. Its initial value is $0.5$~em. It applies to the current command |
| 188 |
% |\Cascade| but also to the possible nested commands. |
| 189 |
% |
| 190 |
% \item The option |interline| can be used to \emph{increase} the ``interline'' |
| 191 |
% showed in the following picture. The initial value of |interline| is $0$~pt |
| 192 |
% and applies only to the current command |\Cascade|. |
| 193 |
% |
| 194 |
% \item The option |interline-all| changes the default value of |interline| used |
| 195 |
% by the current command |\Cascade| and all the possible nested commands |
| 196 |
% |\Cascade|. |
| 197 |
% \end{itemize} |
| 198 |
% |
| 199 |
% \vspace{1cm} |
| 200 |
% |
| 201 |
% \begin{center} |
| 202 |
% \Cascade{\fbox{\hbox to 2cm{\vrule height 18 pt depth 5 pt width 0pt\hfil \texttt{\#1}\hfil |
| 203 |
% \tikz[remember picture] \coordinate (one) at (0,0) ;}}}% |
| 204 |
% {\fbox{\vtop{\hbox to 3cm{\tikz[remember picture] \coordinate (two) at (0,0) ; |
| 205 |
% \vrule height 10 pt depth 12 pt width 0pt\hfil \texttt{\#2}\hfil} |
| 206 |
% \hbox{\tikz[remember picture] \coordinate (three) at (0,0) ;}}}}% |
| 207 |
% {\fbox{\vbox{\hbox{\tikz[remember picture] \coordinate (four) at (0,0) ;}% |
| 208 |
% \hbox to 2.5cm{\vrule height 15 pt depth 14 pt width 0pt\hfil \texttt{\#3}\hfil}}}}% |
| 209 |
% {\fbox{\hbox to 1.7cm{\vrule height 12 pt depth 5 pt width 0pt\hfil \texttt{\#4}\hfil}}} |
| 210 |
% \begin{tikzpicture}[remember picture,overlay,blue] |
| 211 |
% \draw (one) to ++(0,1cm) coordinate (A) to ++(0,2mm) ; |
| 212 |
% \draw (two) to ++(0,1cm) coordinate (B) to ++(0,2mm) ; |
| 213 |
% \draw (A) -- (B) ; |
| 214 |
% \draw[<-] (A) -- ++(-1mm,0) ; |
| 215 |
% \draw[<-] (B) -- ++(1mm,0) ; |
| 216 |
% \path (B) node [right=2mm] {\texttt{space-between}} ; |
| 217 |
% \draw (three) to ++(-3cm,0) coordinate (C) to ++(-2mm,0) ; |
| 218 |
% \draw (four) -| coordinate (D) (C) ; |
| 219 |
% \draw (D) to ++(-2mm,0) ; |
| 220 |
% \draw[<-] (C) -- ++(0,1mm) ; |
| 221 |
% \draw[<-] (D) -- ++(0,-1mm) ; |
| 222 |
% \path ($(C)!0.5!(D)$) node [left=2mm] {the ``interline''} ; |
| 223 |
% \end{tikzpicture} |
| 224 |
% \end{center} |
| 225 |
% |
| 226 |
% \begin{Verbatim} |
| 227 |
% \Cascade[~emphase#interline=4mm@]{\ShortCascade{A}{B}}{E}{\ShortCascade{C}{D}}{F} G |
| 228 |
% \end{Verbatim} |
| 229 |
% |
| 230 |
% \begin{center} |
| 231 |
% \Cascade[interline=4mm]{\ShortCascade{A}{B}}{E}{\ShortCascade{C}{D}}{F} G |
| 232 |
% \end{center} |
| 233 |
% |
| 234 |
% \bigskip |
| 235 |
% \begin{Verbatim} |
| 236 |
% \Cascade[~emphase#interline-all=4mm@]{\ShortCascade{A}{B}}{E}{\ShortCascade{C}{D}}{F} G |
| 237 |
% \end{Verbatim} |
| 238 |
% |
| 239 |
% \begin{center} |
| 240 |
% \Cascade[interline-all=4mm]{\ShortCascade{A}{B}}{E}{\ShortCascade{C}{D}}{F} G |
| 241 |
% \end{center} |
| 242 |
% |
| 243 |
% \interitem |
| 244 |
% The options can also be given at the document level with the command |
| 245 |
% |\CascadeOptions|. In this case, the scope of the declarations is the current |
| 246 |
% TeX group (these declarations are ``semi-global''). |
| 247 |
% |
| 248 |
% \bigskip |
| 249 |
% \section{The command \textbackslash Edacsac} |
| 250 |
% |
| 251 |
% The command |\Edacsac| (\textsl{cascade} written in reverse) is similar to the |
| 252 |
% command |\Cascade| but with braces going backwards. The key |t| is not available in that command. |
| 253 |
% |
| 254 |
% \begin{Verbatim} |
| 255 |
% Singularity |
| 256 |
% ~emphase#\Edacsac@ |
| 257 |
% {elementary} |
| 258 |
% { |
| 259 |
% ~emphase#\Edacsac@ |
| 260 |
% {non-degenerate elementary} |
| 261 |
% {~emphase#\ShortEdacsac@{hyperbolic}{non-hyperbolic}} |
| 262 |
% {degenerate elementary} |
| 263 |
% {} |
| 264 |
% } |
| 265 |
% {non-elementary} |
| 266 |
% {~emphase#\ShortEdacsac@{Nilpotent}{Higher order}} |
| 267 |
% \end{Verbatim} |
| 268 |
% |
| 269 |
% |
| 270 |
% Singularity |
| 271 |
% \Edacsac |
| 272 |
% {elementary} |
| 273 |
% { |
| 274 |
% \Edacsac |
| 275 |
% {non-degenerate elementary} |
| 276 |
% {\ShortEdacsac{hyperbolic}{non-hyperbolic}} |
| 277 |
% {degenerate elementary} |
| 278 |
% {} |
| 279 |
% } |
| 280 |
% {non-elementary} |
| 281 |
% {\ShortEdacsac{nilpotent}{higher order}} |
| 282 |
% |
| 283 |
% |
| 284 |
% |
| 285 |
% \bigskip |
| 286 |
% \section{Technical remark} |
| 287 |
% |
| 288 |
% The package \pkg{cascade} is designed to provide by default results similar to |
| 289 |
% the those given by the environments of \pkg{amsmath} --- and \pkg{mathtools} |
| 290 |
% --- especially |{aligned}|. |
| 291 |
% |
| 292 |
% \bigskip |
| 293 |
% \begin{BVerbatim}[baseline=c,boxwidth=10cm] |
| 294 |
% \[\left.\begin{aligned} |
| 295 |
% & A = \sqrt{a^2+b^2} \\ |
| 296 |
% & B = \frac{ax+b}{cx+d} |
| 297 |
% \end{aligned}\right\}\] |
| 298 |
% \end{BVerbatim} |
| 299 |
% $\left.\begin{aligned} |
| 300 |
% & A = \sqrt{a^2+b^2} \\ |
| 301 |
% & B = \frac{ax+b}{cx+d} |
| 302 |
% \end{aligned}\right\}$ |
| 303 |
% |
| 304 |
% \bigskip |
| 305 |
% \begin{BVerbatim}[baseline=c,boxwidth=10cm] |
| 306 |
% \ShortCascade{$\displaystyle A = \sqrt{a^2+b^2}$} |
| 307 |
% {$B = \dfrac{ax+b}{cx+d}$} |
| 308 |
% \end{BVerbatim} |
| 309 |
% \ShortCascade{$\displaystyle A = \sqrt{a^2+b^2}$}{$B = \dfrac{ax+b}{cx+d}$} |
| 310 |
% |
| 311 |
% \interitem |
| 312 |
% The package \pkg{cascade} constructs the braces with the classical pair |
| 313 |
% |\left|-|\right| of TeX. However, the extensible delimiters, in TeX, cannot |
| 314 |
% take all sizes. We give, in the following example, the braces obtained when |
| 315 |
% surrounding vertical rules from $6$~mm to $17$~mm (the code uses the L3 |
| 316 |
% programming layer). |
| 317 |
% |
| 318 |
% \begin{Verbatim} |
| 319 |
% \int_step_inline:nnnn 6 1 {17} { $\left.\hbox{\vrule height ~#1 mm}\right\}$\quad } |
| 320 |
% \end{Verbatim} |
| 321 |
% |
| 322 |
% \medskip |
| 323 |
% \begin{center} |
| 324 |
% \ExplSyntaxOn |
| 325 |
% \int_step_inline:nnnn 6 1 {17} { $\left.\hbox{\vrule height #1 mm}\right\}$\quad} |
| 326 |
% \ExplSyntaxOff |
| 327 |
% \end{center} |
| 328 |
% |
| 329 |
% |
| 330 |
% \newgeometry{left=4cm} |
| 331 |
% |
| 332 |
% \section{Implementation} |
| 333 |
% |
| 334 |
% \begin{macrocode} |
| 335 |
\RequirePackage{l3keys2e} |
| 336 |
\ProvidesExplPackage |
| 337 |
{cascade} |
| 338 |
{\myfiledate} |
| 339 |
{\myfileversion} |
| 340 |
{Easy presentation of demonstrations in cascades} |
| 341 |
% \end{macrocode} |
| 342 |
% |
| 343 |
% |
| 344 |
% \interitem |
| 345 |
% \iffalse |
| 346 |
%% |
| 347 |
%% The following macro is the same as the macro of amsmath |
| 348 |
% \fi |
| 349 |
% \DescribeMacro{\spread@equation} |
| 350 |
% We will use the command |\spread@equation| of \pkg{amsmath} to increase the |
| 351 |
% interline in the commands |\Cascade|. When used, this command becomes no-op |
| 352 |
% (in the current TeX group). |
| 353 |
% |
| 354 |
% Nevertheless, we want the extension \pkg{cascade} available without |
| 355 |
% \pkg{amsmath}. That's why we give a definition of |\spread@equation| (this |
| 356 |
% definition will be loaded only if \pkg{amsmath} --- or \pkg{mathtools} --- has |
| 357 |
% not been loaded yet). |
| 358 |
% \begin{macrocode} |
| 359 |
\cs_if_free:NT \spread@equation |
| 360 |
{ |
| 361 |
\cs_set_protected:Npn \spread@equation |
| 362 |
{ |
| 363 |
\openup \jot |
| 364 |
\cs_set_protected:Npn \spread@equation { } |
| 365 |
} |
| 366 |
} |
| 367 |
% \end{macrocode} |
| 368 |
% Don't put |\cs_set_eq:NN \spread@equation \prog_do_nothing:| in the last line |
| 369 |
% because this would raise errors with nested environments. |
| 370 |
% |
| 371 |
% |
| 372 |
% \iffalse |
| 373 |
%% |
| 374 |
%% The following registers will be used for the options. |
| 375 |
% \fi |
| 376 |
% \interitem |
| 377 |
% The dimension |\l_@@_interline_dim| will be the value of the vertical space |
| 378 |
% added between the two boxes connected by the brace. |
| 379 |
% \begin{macrocode} |
| 380 |
\dim_new:N \l_@@_interline_dim |
| 381 |
% \end{macrocode} |
| 382 |
% |
| 383 |
% \medskip |
| 384 |
% The dimension |\l_@@_interline_all_dim| is the default value of |
| 385 |
% |\l_@@_interline_dim|. This default value can be modified with the option |
| 386 |
% |interline-all|. Therefore, when modified in the options of a command |
| 387 |
% |\Cascade|, this value will affect all the possible nested commands. |
| 388 |
% \begin{macrocode} |
| 389 |
\dim_new:N \l_@@_interline_all_dim |
| 390 |
% \end{macrocode} |
| 391 |
% |
| 392 |
% \medskip |
| 393 |
% The dimension |\l_@@_space_between_dim| is the horizontal space inserted |
| 394 |
% between the two elements of the same row of the construction. |
| 395 |
% \begin{macrocode} |
| 396 |
\dim_new:N \l_@@_space_between_dim |
| 397 |
\dim_set:Nn \l_@@_space_between_dim { 0.5 em } |
| 398 |
% \end{macrocode} |
| 399 |
% |
| 400 |
% \medskip |
| 401 |
% \begin{macrocode} |
| 402 |
\bool_new:N \l_@@_t_bool |
| 403 |
\bool_new:N \l_@@_main_command_bool |
| 404 |
\bool_new:N \l_@@_nested_command_bool |
| 405 |
\bool_new:N \l_@@_first_argument_bool |
| 406 |
% \end{macrocode} |
| 407 |
% |
| 408 |
% \interitem |
| 409 |
% \iffalse |
| 410 |
%% |
| 411 |
%% This set of options will be used by \Cascade and \ShortCascade |
| 412 |
% \fi |
| 413 |
% The set of keys |cascade/command| will be used by the command |\Cascade|. |
| 414 |
% \begin{macrocode} |
| 415 |
\keys_define:nn { cascade / command } |
| 416 |
{ |
| 417 |
% \end{macrocode} |
| 418 |
% The key |t| means that the command |\Cascade| will be aligned upwards. |
| 419 |
% \begin{macrocode} |
| 420 |
t .code:n = |
| 421 |
\bool_if:NTF \l_@@_t_bool |
| 422 |
{ \msg_error:nn { cascade } { t~option~already~set } } |
| 423 |
{ \bool_set_true:N \l_@@_t_bool } , |
| 424 |
t .value_forbidden:n = true , |
| 425 |
% \end{macrocode} |
| 426 |
% The option |interline| is the vertical space added between the two items |
| 427 |
% connected by a~brace. |
| 428 |
% \begin{macrocode} |
| 429 |
interline .dim_set:N = \l_@@_interline_dim, |
| 430 |
interline .value_required:n = true , |
| 431 |
% \end{macrocode} |
| 432 |
% |
| 433 |
% The option |interline-all| will change the value of |interline| for all the |
| 434 |
% commands |\Cascade|, even the nested commands. |
| 435 |
% \begin{macrocode} |
| 436 |
interline-all .code:n = |
| 437 |
{ |
| 438 |
\dim_set:Nn \l_@@_interline_all_dim { #1 } |
| 439 |
\dim_set:Nn \l_@@_interline_dim { #1 } |
| 440 |
} , |
| 441 |
interline-all .value_required:n = true , |
| 442 |
% \end{macrocode} |
| 443 |
% |
| 444 |
% \medskip |
| 445 |
% The option |space-between| is the horizontal space inserted between the two |
| 446 |
% elements of the same row of the construction. |
| 447 |
% \begin{macrocode} |
| 448 |
space-between .dim_set:N = \l_@@_space_between_dim , |
| 449 |
space-between .value_required:n = true |
| 450 |
} |
| 451 |
% \end{macrocode} |
| 452 |
% |
| 453 |
% \iffalse |
| 454 |
%% |
| 455 |
%% This set of options will be used by \CascadeOptions |
| 456 |
% \fi |
| 457 |
% \medskip |
| 458 |
% The set of keys |cascade/global| will be used for the command |
| 459 |
% |\CascadeOptions| (which fixes the options at a ``global'' level). |
| 460 |
% |
| 461 |
% \begin{macrocode} |
| 462 |
\keys_define:nn { cascade / global } |
| 463 |
{ |
| 464 |
interline-all .dim_set:N = \l_@@_interline_all_dim , |
| 465 |
interline-all .value_required:n = true , |
| 466 |
space-between .dim_set:N = \l_@@_space_between_dim , |
| 467 |
space-between .value_required:n = true |
| 468 |
} |
| 469 |
% \end{macrocode} |
| 470 |
% |
| 471 |
% \medskip |
| 472 |
% \begin{macrocode} |
| 473 |
\cs_new_protected:Npn \@@_initialisation: |
| 474 |
{ |
| 475 |
\box_clear_new:N \l_@@_box_one |
| 476 |
\box_clear_new:N \l_@@_box_two |
| 477 |
\box_clear_new:N \l_@@_box_three |
| 478 |
\box_clear_new:N \l_@@_box_four |
| 479 |
\dim_zero_new:N \l_@@_top_dim |
| 480 |
\dim_zero_new:N \l_@@_bottom_dim |
| 481 |
} |
| 482 |
% \end{macrocode} |
| 483 |
% |
| 484 |
% \medskip |
| 485 |
% \DescribeMacro{\CascadeOptions} |
| 486 |
% The command |\CascadeOptions| is the command to set the options of the |
| 487 |
% \pkg{cascade} at the document level (these options are set in a local way in |
| 488 |
% the sense of the TeX groups). |
| 489 |
% \begin{macrocode} |
| 490 |
\NewDocumentCommand \CascadeOptions { m } |
| 491 |
{ \keys_set:nn { cascade / global } { #1 } } |
| 492 |
% \end{macrocode} |
| 493 |
% |
| 494 |
% \iffalse |
| 495 |
%% |
| 496 |
%% The command \Cascade is defined with \NewDocumentCommand of L3. |
| 497 |
% \fi |
| 498 |
% \interitem |
| 499 |
% \DescribeMacro{\Cascade} |
| 500 |
% The command |\Cascade| is the main command of this package. |
| 501 |
% |
| 502 |
% \begin{macrocode} |
| 503 |
\NewDocumentCommand \Cascade { O { } m m m m D < > { } } |
| 504 |
{ |
| 505 |
\if_mode_math: |
| 506 |
\msg_error:nn { cascade } { math~mode } |
| 507 |
\fi: |
| 508 |
\mode_leave_vertical: |
| 509 |
% \end{macrocode} |
| 510 |
% The dimension |\g_@@_yoffset_dim| will be used by the option~|t|. |
| 511 |
% \begin{macrocode} |
| 512 |
\bool_if:NF \l_@@_nested_command_bool |
| 513 |
{ |
| 514 |
\dim_gzero_new:N \g_@@_yoffset_dim |
| 515 |
\bool_set_true:N \l_@@_first_argument_bool |
| 516 |
} |
| 517 |
\group_begin: |
| 518 |
|
| 519 |
\spread@equation |
| 520 |
\dim_set_eq:NN \l_@@_interline_dim \l_@@_interline_all_dim |
| 521 |
\keys_set:nn { cascade / command } { #1 } |
| 522 |
\tl_if_empty:nF { #6 } |
| 523 |
{ |
| 524 |
\bool_if:NF \l_@@_t_bool |
| 525 |
{ \msg_error:nn { cascade } { angular~argument~without~t } } |
| 526 |
} |
| 527 |
\@@_initialisation: |
| 528 |
\hbox_set:Nn \l_@@_box_one |
| 529 |
{ |
| 530 |
\bool_set_true:N \l_@@_first_argument_bool |
| 531 |
\bool_set_true:N \l_@@_nested_command_bool |
| 532 |
#2 |
| 533 |
} |
| 534 |
\hbox_set:Nn \l_@@_box_two { #3 } |
| 535 |
\hbox_set:Nn \l_@@_box_three |
| 536 |
{ |
| 537 |
\bool_set_false:N \l_@@_first_argument_bool |
| 538 |
\bool_set_true:N \l_@@_nested_command_bool |
| 539 |
#4 |
| 540 |
} |
| 541 |
\hbox_set:Nn \l_@@_box_four { #5 } |
| 542 |
% \end{macrocode} |
| 543 |
% |
| 544 |
% \medskip |
| 545 |
% The dimension |\l_@@_top_dim| is the space that we will have to add before the |
| 546 |
% main construction to make up for the ``|\smash[t]|'' of the box |#1|. |
| 547 |
% \begin{macrocode} |
| 548 |
\dim_set:Nn \l_@@_top_dim |
| 549 |
{ |
| 550 |
\dim_max:nn |
| 551 |
\c_zero_dim |
| 552 |
{ \box_ht:N \l_@@_box_one - \box_ht:N \l_@@_box_two } |
| 553 |
} |
| 554 |
% \end{macrocode} |
| 555 |
% The dimension |\l_@@_bottom_dim| is the space that we will have to add after |
| 556 |
% the main construction to make up for the ``|\smash[b]|'' of the box |#3|. |
| 557 |
% \begin{macrocode} |
| 558 |
\dim_set:Nn \l_@@_bottom_dim |
| 559 |
{ |
| 560 |
\dim_max:nn |
| 561 |
\c_zero_dim |
| 562 |
{ \box_dp:N \l_@@_box_three - \box_dp:N \l_@@_box_four } |
| 563 |
} |
| 564 |
% \end{macrocode} |
| 565 |
% |
| 566 |
% \medskip |
| 567 |
% We do the ``|\smash[t]|'' of box |#1| and the ``|\smash[b]|'' of box |#3|. |
| 568 |
% \begin{macrocode} |
| 569 |
\box_set_ht:Nn \l_@@_box_one \c_zero_dim |
| 570 |
\box_set_dp:Nn \l_@@_box_three \c_zero_dim |
| 571 |
% \end{macrocode} |
| 572 |
% |
| 573 |
% \medskip |
| 574 |
% We can now construct the box. |
| 575 |
% \begin{macrocode} |
| 576 |
\vbox_set:Nn \l_tmpa_box |
| 577 |
{ |
| 578 |
\skip_vertical:N \l_@@_top_dim |
| 579 |
\vbox_top:n |
| 580 |
{ |
| 581 |
\@@_the_vcenter:nn { #2 } { #4 } |
| 582 |
% \end{macrocode} |
| 583 |
% We update |\g_@@_yoffset_dim|. |
| 584 |
% \begin{macrocode} |
| 585 |
\bool_if:NT \l_@@_first_argument_bool |
| 586 |
{ |
| 587 |
\dim_set:Nn \l_tmpa_dim { \box_ht_plus_dp:N \l_tmpb_box } |
| 588 |
\l_tmpa_dim = 0.5\l_tmpa_dim |
| 589 |
\dim_add:Nn \l_tmpa_dim { \the \fontdimen 22 \textfont2 } |
| 590 |
\dim_sub:Nn \l_tmpa_dim |
| 591 |
{ \dim_max:nn { \box_ht:N \l_@@_box_two } { \box_ht:N \strutbox } } |
| 592 |
\dim_gadd:Nn \g_@@_yoffset_dim \l_tmpa_dim |
| 593 |
} |
| 594 |
% \end{macrocode} |
| 595 |
% \begin{macrocode} |
| 596 |
\hbox |
| 597 |
{ |
| 598 |
\c_math_toggle_token |
| 599 |
\left . |
| 600 |
\box_use_drop:N \l_tmpb_box |
| 601 |
\right \} |
| 602 |
\c_math_toggle_token |
| 603 |
\bool_if:NT \l_@@_t_bool |
| 604 |
{ |
| 605 |
\bool_if:NF \l_@@_nested_command_bool |
| 606 |
{ |
| 607 |
\tl_if_empty:nF { #6 } |
| 608 |
{ |
| 609 |
\skip_horizontal:n \l_@@_space_between_dim |
| 610 |
#6 |
| 611 |
} |
| 612 |
} |
| 613 |
} |
| 614 |
} |
| 615 |
\skip_vertical:N \l_@@_bottom_dim |
| 616 |
} |
| 617 |
} |
| 618 |
\bool_if:NTF \l_@@_nested_command_bool |
| 619 |
{ \box_use_drop:N \l_tmpa_box } |
| 620 |
{ |
| 621 |
% \end{macrocode} |
| 622 |
% We are in the main command |\Cascade| and, if the option~|t| is in force, we |
| 623 |
% have now to take into account that key. |
| 624 |
% \begin{macrocode} |
| 625 |
\bool_if:NTF \l_@@_t_bool |
| 626 |
{ \box_move_down:nn \g_@@_yoffset_dim { \box_use:N \l_tmpa_box } } |
| 627 |
{ \box_use_drop:N \l_tmpa_box } |
| 628 |
} |
| 629 |
\group_end: |
| 630 |
} |
| 631 |
% \end{macrocode} |
| 632 |
% |
| 633 |
% \bigskip |
| 634 |
% The following macro is only for the legibility of the code. |
| 635 |
% \begin{macrocode} |
| 636 |
\cs_new_protected:Npn \@@_the_vcenter:nn #1 #2 |
| 637 |
{ |
| 638 |
\hbox_set:Nn \l_tmpb_box |
| 639 |
{ |
| 640 |
\c_math_toggle_token |
| 641 |
\vcenter |
| 642 |
{ |
| 643 |
\halign |
| 644 |
{ |
| 645 |
\hfil ## \cr |
| 646 |
\hbox |
| 647 |
{ |
| 648 |
\tl_if_empty:nF { #1 } |
| 649 |
{ |
| 650 |
\box_use_drop:N \l_@@_box_one |
| 651 |
\skip_horizontal:n \l_@@_space_between_dim |
| 652 |
} |
| 653 |
\box_use:N \l_@@_box_two |
| 654 |
\strut |
| 655 |
} |
| 656 |
\cr |
| 657 |
\noalign { \skip_vertical:n \l_@@_interline_dim } |
| 658 |
\hbox |
| 659 |
{ |
| 660 |
\tl_if_empty:nF { #2 } |
| 661 |
{ |
| 662 |
\box_use_drop:N \l_@@_box_three |
| 663 |
\skip_horizontal:n \l_@@_space_between_dim |
| 664 |
} |
| 665 |
\box_use_drop:N \l_@@_box_four |
| 666 |
\strut |
| 667 |
} |
| 668 |
\cr |
| 669 |
} |
| 670 |
} |
| 671 |
\c_math_toggle_token |
| 672 |
} |
| 673 |
} |
| 674 |
% \end{macrocode} |
| 675 |
% |
| 676 |
% \bigskip |
| 677 |
% The command |\Edacsac|. The code is simpler because we don't need the |
| 678 |
% |\halign| and we don't have the key |t|. |
| 679 |
% |
| 680 |
% \begin{macrocode} |
| 681 |
\NewDocumentCommand \Edacsac { O { } m m m m } |
| 682 |
{ |
| 683 |
\if_mode_math: |
| 684 |
\msg_error:nn { cascade } { math~mode } |
| 685 |
\fi: |
| 686 |
\mode_leave_vertical: |
| 687 |
\group_begin: |
| 688 |
\spread@equation |
| 689 |
\dim_set_eq:NN \l_@@_interline_dim \l_@@_interline_all_dim |
| 690 |
\keys_set:nn { cascade / command } { #1 } |
| 691 |
\@@_initialisation: |
| 692 |
\hbox_set:Nn \l_@@_box_one { #2 } |
| 693 |
\hbox_set:Nn \l_@@_box_two { #3 } |
| 694 |
\hbox_set:Nn \l_@@_box_three { #4 } |
| 695 |
\hbox_set:Nn \l_@@_box_four { #5 } |
| 696 |
\dim_set:Nn \l_@@_top_dim |
| 697 |
{ |
| 698 |
\dim_max:nn |
| 699 |
\c_zero_dim |
| 700 |
{ \box_ht:N \l_@@_box_two - \box_ht:N \l_@@_box_one } |
| 701 |
} |
| 702 |
\dim_set:Nn \l_@@_bottom_dim |
| 703 |
{ |
| 704 |
\dim_max:nn |
| 705 |
\c_zero_dim |
| 706 |
{ \box_dp:N \l_@@_box_four - \box_dp:N \l_@@_box_three } |
| 707 |
} |
| 708 |
\box_set_ht:Nn \l_@@_box_two \c_zero_dim |
| 709 |
\box_set_dp:Nn \l_@@_box_four \c_zero_dim |
| 710 |
\vbox |
| 711 |
{ |
| 712 |
\skip_vertical:N \l_@@_top_dim |
| 713 |
\vtop |
| 714 |
{ |
| 715 |
\hbox |
| 716 |
{ |
| 717 |
\c_math_toggle_token |
| 718 |
\left \{ |
| 719 |
\vcenter |
| 720 |
{ |
| 721 |
\hbox |
| 722 |
{ |
| 723 |
\tl_if_empty:nF { #2 } |
| 724 |
{ |
| 725 |
\box_use_drop:N \l_@@_box_one |
| 726 |
\skip_horizontal:n \l_@@_space_between_dim |
| 727 |
} |
| 728 |
\box_use_drop:N \l_@@_box_two |
| 729 |
\strut |
| 730 |
} |
| 731 |
\skip_vertical:N \l_@@_interline_dim |
| 732 |
\hbox |
| 733 |
{ |
| 734 |
\tl_if_empty:nF { #4 } |
| 735 |
{ |
| 736 |
\box_use_drop:N \l_@@_box_three |
| 737 |
\skip_horizontal:n \l_@@_space_between_dim |
| 738 |
} |
| 739 |
\box_use_drop:N \l_@@_box_four |
| 740 |
\strut |
| 741 |
} |
| 742 |
} |
| 743 |
\right . |
| 744 |
\c_math_toggle_token |
| 745 |
} |
| 746 |
\skip_vertical:N \l_@@_bottom_dim |
| 747 |
} |
| 748 |
} |
| 749 |
\group_end: |
| 750 |
} |
| 751 |
% \end{macrocode} |
| 752 |
% |
| 753 |
% |
| 754 |
% \bigskip |
| 755 |
% \begin{macrocode} |
| 756 |
\msg_new:nnn |
| 757 |
{ cascade } |
| 758 |
{ math~mode } |
| 759 |
{ |
| 760 |
The~commands~of~the~extension~'cascade'~ |
| 761 |
should~be~used~in~text~mode~only.~However,~you~can~ |
| 762 |
go~on~for~this~time. |
| 763 |
} |
| 764 |
% \end{macrocode} |
| 765 |
% |
| 766 |
% \begin{macrocode} |
| 767 |
\msg_new:nnn |
| 768 |
{ cascade } |
| 769 |
{ t~option~already~set } |
| 770 |
{ |
| 771 |
You~can't~use~the~key~'t'~here~because~it~has~been~set~ |
| 772 |
in~an~encompassing~command.~If~you~go~on,~this~key~will~be~ |
| 773 |
ignored. |
| 774 |
} |
| 775 |
% \end{macrocode} |
| 776 |
% |
| 777 |
% \begin{macrocode} |
| 778 |
\msg_new:nnn { cascade } { angular~argument~without~t } |
| 779 |
{ |
| 780 |
You~can't~use~the~argument~between~angular~brackets~because~ |
| 781 |
you~have~not~used~the~key~'t'. The~argument~between~angular~brackets~ |
| 782 |
will~be~ignored. |
| 783 |
} |
| 784 |
% \end{macrocode} |
| 785 |
% |
| 786 |
% \bigskip |
| 787 |
% \DescribeMacro{\ShortCascade} |
| 788 |
% The command |\ShortCascade| is a simplified version of |\Cascade| with only |
| 789 |
% two arguments. |
| 790 |
% \begin{macrocode} |
| 791 |
\NewDocumentCommand \ShortCascade { O { } m m } |
| 792 |
{ \Cascade [ #1 ] { } { #2 } { } { #3 } } |
| 793 |
% \end{macrocode} |
| 794 |
% |
| 795 |
% \bigskip |
| 796 |
% \DescribeMacro{\ShortEdacsac} |
| 797 |
% Idem for |\ShortEdacsac| |
| 798 |
% \begin{macrocode} |
| 799 |
\NewDocumentCommand \ShortEdacsac { O { } m m } |
| 800 |
{ \Edacsac [ #1 ] { #2 } { } { #3 } { } } |
| 801 |
% \end{macrocode} |
| 802 |
% |
| 803 |
% |
| 804 |
% \vspace{1cm} |
| 805 |
% \section{History} |
| 806 |
% |
| 807 |
% \subsection*{Changes between versions 1.1 and 1.2} |
| 808 |
% |
| 809 |
% New commands |\Edacsac| and |\ShortEdacsac|. |
| 810 |
% |
| 811 |
% \subsection*{Changes between versions 1.0 and 1.1} |
| 812 |
% |
| 813 |
% New option |t|. |
| 814 |
% |
| 815 |
% \tableofcontents |
| 816 |
% |
| 817 |
% \end{document} |
| 818 |
% |
| 819 |
% Local Variables: |
| 820 |
% TeX-fold-mode: t |
| 821 |
% TeX-fold-preserve-comments: nil |
| 822 |
% flyspell-mode: nil |
| 823 |
% fill-column: 80 |
| 824 |
% End: |
| 825 |
|
| 826 |
|
| 827 |
|
| 828 |
|
| 829 |
|
| 830 |
|