| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% Copyright (C) 2004-2011 by Morten Hoegholm |
| 4 |
% Copyright (C) 2012-2019 by Lars Madsen |
| 5 |
% Copyright (C) 2020- by Lars Madsen, The LaTeX3 team |
| 6 |
% |
| 7 |
% This work may be distributed and/or modified under the |
| 8 |
% conditions of the LaTeX Project Public License, either |
| 9 |
% version 1.3c of this license or (at your option) any later |
| 10 |
% version. The latest version of this license is in |
| 11 |
% http://www.latex-project.org/lppl.txt |
| 12 |
% and version 1.3c or later is part of all distributions of |
| 13 |
% LaTeX version 2008/05/05 or later. |
| 14 |
% |
| 15 |
% This work has the LPPL maintenance status "maintained". |
| 16 |
% |
| 17 |
% This Current Maintainer of this work is |
| 18 |
% Lars Madsen |
| 19 |
% |
| 20 |
% This work consists of the main source file mathtools.dtx |
| 21 |
% and the derived files |
| 22 |
% mathtools.sty, mathtools.pdf, mathtools.ins, mathtools.drv. |
| 23 |
% |
| 24 |
% Distribution: |
| 25 |
% CTAN:macros/latex/contrib/mh/mathtools.dtx |
| 26 |
% CTAN:macros/latex/contrib/mh/mathtools.pdf |
| 27 |
% |
| 28 |
% Unpacking: |
| 29 |
% (a) If mathtools.ins is present: |
| 30 |
% tex mathtools.ins |
| 31 |
% (b) Without mathtools.ins: |
| 32 |
% tex mathtools.dtx |
| 33 |
% (c) If you insist on using LaTeX |
| 34 |
% latex \let\install=y\input{mathtools.dtx} |
| 35 |
% (quote the arguments according to the demands of your shell) |
| 36 |
% |
| 37 |
% Documentation: |
| 38 |
% (a) If mathtools.drv is present: |
| 39 |
% latex mathtools.drv |
| 40 |
% (b) Without mathtools.drv: |
| 41 |
% latex mathtools.dtx; ... |
| 42 |
% The class ltxdoc loads the configuration file ltxdoc.cfg |
| 43 |
% if available. Here you can specify further options, e.g. |
| 44 |
% use A4 as paper format: |
| 45 |
% \PassOptionsToClass{a4paper}{article} |
| 46 |
% |
| 47 |
% Programm calls to get the documentation (example): |
| 48 |
% pdflatex mathtools.dtx |
| 49 |
% makeindex -s gind.ist mathtools.idx |
| 50 |
% pdflatex mathtools.dtx |
| 51 |
% makeindex -s gind.ist mathtools.idx |
| 52 |
% pdflatex mathtools.dtx |
| 53 |
% |
| 54 |
% Installation: |
| 55 |
% TDS:tex/latex/mh/mathtools.sty |
| 56 |
% TDS:doc/latex/mh/mathtools.pdf |
| 57 |
% TDS:source/latex/mh/mathtools.dtx |
| 58 |
% |
| 59 |
%<*ignore> |
| 60 |
\begingroup |
| 61 |
\def\x{LaTeX2e} |
| 62 |
\expandafter\endgroup |
| 63 |
\ifcase 0\ifx\install y1\fi\expandafter |
| 64 |
\ifx\csname processbatchFile\endcsname\relax\else1\fi |
| 65 |
\ifx\fmtname\x\else 1\fi\relax |
| 66 |
\else\csname fi\endcsname |
| 67 |
%</ignore> |
| 68 |
%<*install> |
| 69 |
\input docstrip.tex |
| 70 |
\Msg{************************************************************************} |
| 71 |
\Msg{* Installation} |
| 72 |
\Msg{* Package: mathtools 2024/10/04 v1.31} |
| 73 |
\Msg{************************************************************************} |
| 74 |
|
| 75 |
\keepsilent |
| 76 |
\askforoverwritefalse |
| 77 |
|
| 78 |
\preamble |
| 79 |
|
| 80 |
This is a generated file. |
| 81 |
|
| 82 |
Copyright (C) 2002-2011 by Morten Hoegholm |
| 83 |
Copyright (C) 2012-2019 by Lars Madsen |
| 84 |
Copyright (C) 2020- by Lars Madsen, the LaTeX3 project |
| 85 |
|
| 86 |
|
| 87 |
This work may be distributed and/or modified under the |
| 88 |
conditions of the LaTeX Project Public License, either |
| 89 |
version 1.3c of this license or (at your option) any later |
| 90 |
version. The latest version of this license is in |
| 91 |
http://www.latex-project.org/lppl.txt |
| 92 |
and version 1.3c or later is part of all distributions of |
| 93 |
LaTeX version 2008/05/04 or later. |
| 94 |
|
| 95 |
This work has the LPPL maintenance status "maintained". |
| 96 |
|
| 97 |
This Current Maintainer of this work is |
| 98 |
Lars Madsen and the LaTeX3 project |
| 99 |
|
| 100 |
This work consists of the main source file mathtools.dtx |
| 101 |
and the derived files |
| 102 |
mathtools.sty, mathtools.pdf, mathtools.ins, mathtools.drv. |
| 103 |
|
| 104 |
\endpreamble |
| 105 |
|
| 106 |
\generate{% |
| 107 |
\file{mathtools.ins}{\from{mathtools.dtx}{install}}% |
| 108 |
\file{mathtools.drv}{\from{mathtools.dtx}{driver}}% |
| 109 |
\usedir{tex/latex/mh}% |
| 110 |
\file{mathtools.sty}{\from{mathtools.dtx}{package}}% |
| 111 |
} |
| 112 |
|
| 113 |
\obeyspaces |
| 114 |
\Msg{************************************************************************} |
| 115 |
\Msg{*} |
| 116 |
\Msg{* To finish the installation you have to move the following} |
| 117 |
\Msg{* file into a directory searched by TeX:} |
| 118 |
\Msg{*} |
| 119 |
\Msg{* mathtools.sty} |
| 120 |
\Msg{*} |
| 121 |
\Msg{* To produce the documentation run the file `mathtools.drv'} |
| 122 |
\Msg{* through LaTeX.} |
| 123 |
\Msg{*} |
| 124 |
\Msg{* Happy TeXing!} |
| 125 |
\Msg{*} |
| 126 |
\Msg{************************************************************************} |
| 127 |
|
| 128 |
\endbatchfile |
| 129 |
%</install> |
| 130 |
%<*ignore> |
| 131 |
\fi |
| 132 |
%</ignore> |
| 133 |
%<*driver> |
| 134 |
\NeedsTeXFormat{LaTeX2e} |
| 135 |
\ProvidesFile{mathtools.drv}% |
| 136 |
[2024/10/04 v1.31 mathematical typesetting tools] |
| 137 |
\documentclass{ltxdoc} |
| 138 |
|
| 139 |
\IfFileExists{fourier.sty}{\usepackage{fourier}}{} |
| 140 |
\addtolength\marginparwidth{-25pt} |
| 141 |
\usepackage{mathtools} |
| 142 |
|
| 143 |
\setcounter{IndexColumns}{2} |
| 144 |
|
| 145 |
\providecommand*\pkg[1]{\textsf{#1}} |
| 146 |
\providecommand*\env[1]{\texttt{#1}} |
| 147 |
\providecommand*\email[1]{\href{mailto:#1}{\texttt{#1}}} |
| 148 |
\providecommand*\mode[1]{\texttt{[#1]}} |
| 149 |
\providecommand*\file[1]{\texttt{#1}} |
| 150 |
\usepackage{xcolor,varioref,amssymb} |
| 151 |
\makeatletter |
| 152 |
\newcommand*\thinfbox[2][black]{\fboxsep0pt\textcolor{#1}{\rulebox{{\normalcolor#2}}}} |
| 153 |
\newcommand*\thinboxed[2][black]{\thinfbox[#1]{\ensuremath{\displaystyle#2}}} |
| 154 |
\newcommand*\rulebox[1]{% |
| 155 |
\sbox\z@{\ensuremath{\displaystyle#1}}% |
| 156 |
\@tempdima\dp\z@ |
| 157 |
\hbox{% |
| 158 |
\lower\@tempdima\hbox{% |
| 159 |
\vbox{\hrule height\fboxrule\box\z@\hrule height\fboxrule}% |
| 160 |
}% |
| 161 |
}% |
| 162 |
} |
| 163 |
|
| 164 |
\newenvironment{codesyntax} |
| 165 |
{\par\small\addvspace{4.5ex plus 1ex}% |
| 166 |
\vskip -\parskip |
| 167 |
\noindent |
| 168 |
\begin{tabular}{|l|}\hline\ignorespaces}% |
| 169 |
{\\\hline\end{tabular}\nobreak\par\nobreak |
| 170 |
\vspace{2.3ex}\vskip -\parskip\noindent\ignorespacesafterend} |
| 171 |
\makeatletter |
| 172 |
|
| 173 |
\newcommand*\FeatureRequest[2]{% |
| 174 |
\hskip1sp |
| 175 |
\marginpar{% |
| 176 |
\parbox[b]{\marginparwidth}{\small\sffamily\raggedright |
| 177 |
\strut Feature request by\\#1\\#2% |
| 178 |
} |
| 179 |
}% |
| 180 |
} |
| 181 |
|
| 182 |
|
| 183 |
\newcommand*\ProvidedBy[2]{% |
| 184 |
\hskip1sp |
| 185 |
\marginpar{% |
| 186 |
\parbox[b]{\marginparwidth}{\small\sffamily\raggedright |
| 187 |
\strut Feature provided by\\#1\\#2% |
| 188 |
} |
| 189 |
}% |
| 190 |
} |
| 191 |
|
| 192 |
\newcommand*\SuggestedBy[2]{% |
| 193 |
\hskip1sp |
| 194 |
\marginpar{% |
| 195 |
\parbox[b]{\marginparwidth}{\small\sffamily\raggedright |
| 196 |
\strut Suggested by\\#1\\#2% |
| 197 |
} |
| 198 |
}% |
| 199 |
} |
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
\newcommand*\cttPosting[2]{% |
| 204 |
\hskip1sp |
| 205 |
\marginpar{% |
| 206 |
\parbox[b]{\marginparwidth}{\small\sffamily\raggedright |
| 207 |
\strut Posted on \texttt{comp.text.tex} \\#1\\#2% |
| 208 |
}% |
| 209 |
}% |
| 210 |
} |
| 211 |
|
| 212 |
\newcommand*\tsxPosting[2]{% |
| 213 |
\hskip1sp |
| 214 |
\marginpar{% |
| 215 |
\parbox[b]{\marginparwidth}{\small\sffamily\raggedright |
| 216 |
\strut Posted on \texttt{\small tex.stackexchange.com} \\#1\\#2% |
| 217 |
}% |
| 218 |
}% |
| 219 |
} |
| 220 |
|
| 221 |
\newcommand*\tsxchatPosting[3][Requested on]{% |
| 222 |
\hskip1sp |
| 223 |
\marginpar{% |
| 224 |
\parbox[b]{\marginparwidth}{\small\sffamily\raggedright |
| 225 |
\strut #1 \texttt{\scriptsize tex.stackexchange.com chat} \\#2\\#3% |
| 226 |
}% |
| 227 |
}% |
| 228 |
} |
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
\newcommand*\CommentAdded[1]{% |
| 233 |
\hskip1sp |
| 234 |
\marginpar{% |
| 235 |
\parbox[b]{\marginparwidth}{\small\sffamily\raggedright |
| 236 |
\strut Comment added\\#1% |
| 237 |
}% |
| 238 |
}% |
| 239 |
} |
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
\expandafter\def\expandafter\MakePrivateLetters\expandafter{% |
| 244 |
\MakePrivateLetters \catcode`\_=11\relax |
| 245 |
} |
| 246 |
|
| 247 |
\providecommand*\SpecialOptIndex[1]{% |
| 248 |
\@bsphack |
| 249 |
\index{#1\actualchar{\protect\ttfamily #1} |
| 250 |
(option)\encapchar usage}% |
| 251 |
\index{options:\levelchar#1\actualchar{\protect\ttfamily #1}\encapchar |
| 252 |
usage}\@esphack} |
| 253 |
\providecommand*\opt[1]{\texttt{#1}} |
| 254 |
|
| 255 |
\providecommand*\SpecialKeyIndex[1]{% |
| 256 |
\@bsphack |
| 257 |
\index{#1\actualchar{\protect\ttfamily #1} |
| 258 |
(key)\encapchar usage}% |
| 259 |
\index{keys:\levelchar#1\actualchar{\protect\ttfamily #1}\encapchar |
| 260 |
usage}\@esphack} |
| 261 |
\providecommand*\key[1]{\textsf{#1}} |
| 262 |
|
| 263 |
\providecommand*\eTeX{$\m@th\varepsilon$-\TeX} |
| 264 |
|
| 265 |
\def\MTmeta#1{% |
| 266 |
\ensuremath\langle |
| 267 |
\ifmmode \expandafter \nfss@text \fi |
| 268 |
{% |
| 269 |
\meta@font@select |
| 270 |
\edef\meta@hyphen@restore |
| 271 |
{\hyphenchar\the\font\the\hyphenchar\font}% |
| 272 |
\hyphenchar\font\m@ne |
| 273 |
\language\l@nohyphenation |
| 274 |
#1\/% |
| 275 |
\meta@hyphen@restore |
| 276 |
}\ensuremath\rangle |
| 277 |
\endgroup |
| 278 |
} |
| 279 |
\makeatother |
| 280 |
\DeclareRobustCommand\meta{\begingroup\MakePrivateLetters\MTmeta}% |
| 281 |
\def\MToarg#1{{\ttfamily[}\meta{#1}{\ttfamily]}\endgroup} |
| 282 |
\DeclareRobustCommand\oarg{\begingroup\MakePrivateLetters\MToarg}% |
| 283 |
\def\MHmarg#1{{\ttfamily\char`\{}\meta{#1}{\ttfamily\char`\}}\endgroup} |
| 284 |
\DeclareRobustCommand\marg{\begingroup\MakePrivateLetters\MHmarg}% |
| 285 |
\def\MHarg#1{{\ttfamily\char`\{#1\ttfamily\char`\}}\endgroup} |
| 286 |
\DeclareRobustCommand\arg{\begingroup\MakePrivateLetters\MHarg}% |
| 287 |
\def\MHcs#1{\texttt{\char`\\#1}\endgroup} |
| 288 |
\DeclareRobustCommand\cs{\begingroup\MakePrivateLetters\MHcs} |
| 289 |
|
| 290 |
\def\endverbatim{\if@newlist |
| 291 |
\leavevmode\fi\endtrivlist\vspace{-\baselineskip}} |
| 292 |
\expandafter\let\csname endverbatim*\endcsname =\endverbatim |
| 293 |
|
| 294 |
\let\MTtheindex\theindex |
| 295 |
\def\theindex{\MTtheindex\MakePrivateLetters} |
| 296 |
|
| 297 |
|
| 298 |
\NewDocumentCommand\Framebox{ o O{c} m }{% |
| 299 |
\IfNoValueTF{#1}{% |
| 300 |
\framebox{\footnotesize\strut #3}% |
| 301 |
}{% |
| 302 |
\framebox[#1][#2]{\footnotesize\strut #3}% |
| 303 |
}% |
| 304 |
} |
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
%\usepackage[draft]{fixme} |
| 309 |
%\fxsetup{ |
| 310 |
% multiuser, |
| 311 |
%layout=marginnote, |
| 312 |
%} |
| 313 |
%\providecommand\fxnote[2][]{} |
| 314 |
|
| 315 |
\usepackage{xurl} |
| 316 |
|
| 317 |
\usepackage[final, |
| 318 |
hyperindex=false, |
| 319 |
colorlinks, |
| 320 |
]{hyperref} |
| 321 |
\renewcommand*\usage[1]{\textit{\hyperpage{#1}}} |
| 322 |
|
| 323 |
\OnlyDescription |
| 324 |
\begin{document} |
| 325 |
\DocInput{mathtools.dtx} |
| 326 |
\end{document} |
| 327 |
%</driver> |
| 328 |
% \fi |
| 329 |
% |
| 330 |
% \changes{v1.19}{2017/03/31}{Updated to match some macro renaming in |
| 331 |
% \pkg{mhsetup}} |
| 332 |
% \changes{v1.0}{2004/07/26}{Initial release} |
| 333 |
% |
| 334 |
% \GetFileInfo{mathtools.drv} |
| 335 |
% |
| 336 |
% \CheckSum{3775} |
| 337 |
% |
| 338 |
% \title{The \pkg{mathtools} package\thanks{This file has version number |
| 339 |
% \fileversion, last revised \filedate.}} |
| 340 |
% |
| 341 |
% \author{Morten Høgholm, Lars Madsen and the \LaTeX3 project} |
| 342 |
% \date{\filedate} |
| 343 |
% |
| 344 |
% \maketitle |
| 345 |
% |
| 346 |
% \begin{abstract} |
| 347 |
% \noindent The \pkg{mathtools} package is an extension package to |
| 348 |
% \pkg{amsmath}. There are two things on \pkg{mathtools}' agenda: |
| 349 |
% (1)~correct various bugs/deficiencies in \pkg{amsmath} until |
| 350 |
% these are fixed by the \AmS{} and (2)~provide useful tools |
| 351 |
% for mathematical typesetting, be it a small macro for |
| 352 |
% typesetting a prescript or an underbracket, or entirely new |
| 353 |
% display math constructs such as a \env{multlined} environment. |
| 354 |
% \end{abstract} |
| 355 |
% |
| 356 |
% \tableofcontents |
| 357 |
% |
| 358 |
% \section{Introduction} |
| 359 |
% |
| 360 |
% Although \pkg{amsmath} provides many handy tools for mathematical |
| 361 |
% typesetting, it is nonetheless a static package. This is not a bad |
| 362 |
% thing, because what it does, it mostly does quite well and having |
| 363 |
% a stable math typesetting package is ``a good thing.'' However, |
| 364 |
% \pkg{amsmath} does not fulfill all the needs of the mathematical |
| 365 |
% part of the \LaTeX{} community, resulting in many authors writing |
| 366 |
% small snippets of code for tweaking the mathematical layout. Some |
| 367 |
% of these snippets have also been posted to newsgroups and mailing |
| 368 |
% lists over the years, although more often than not without being |
| 369 |
% released as stand-alone packages. |
| 370 |
% |
| 371 |
% The \pkg{mathtools} package is exactly what its name implies: tools |
| 372 |
% for mathematical typesetting. It is a collection of many of these |
| 373 |
% often needed small tweaks---with some big tweaks added as well. It |
| 374 |
% can only do so by having harvesting newsgroups for code and/or you |
| 375 |
% writing the maintainers with wishes for code to be included, so if |
| 376 |
% you have any good macros or just macros that help you when writing |
| 377 |
% mathematics, then don't hesitate to report them. |
| 378 |
% |
| 379 |
% As of 2020, \pkg{mathtools} (and \pkg{empheq}) is now hosted at the |
| 380 |
% \LaTeX3 team GitHub at |
| 381 |
% \begin{center} |
| 382 |
% \url{https://github.com/latex3/mathtools} |
| 383 |
% \end{center} |
| 384 |
% So if you have any issue, feel free to register an issue there. |
| 385 |
% |
| 386 |
% \medskip\noindent |
| 387 |
% Update 2013: We now make \cs{(}\cs{)} and \cs[\cs] |
| 388 |
% robust (can be disabled via \texttt{nonrobust} package option). |
| 389 |
% |
| 390 |
% \section{Package loading} |
| 391 |
% |
| 392 |
% |
| 393 |
% The \pkg{mathtools} package requires \pkg{amsmath} but is able to |
| 394 |
% pass options to it as well. Thus a line like |
| 395 |
% \begin{verbatim} |
| 396 |
% \usepackage[fleqn,tbtags]{mathtools} |
| 397 |
% \end{verbatim} |
| 398 |
% is equivalent to |
| 399 |
% \begin{verbatim} |
| 400 |
% \usepackage[fleqn,tbtags]{amsmath} |
| 401 |
% \usepackage{mathtools} |
| 402 |
% \end{verbatim} |
| 403 |
% |
| 404 |
% |
| 405 |
% \subsection{Special \pkg{mathtools} options} |
| 406 |
% |
| 407 |
% \begin{codesyntax} |
| 408 |
% \SpecialOptIndex{fixamsmath}\opt{fixamsmath}\texttt{~~~~} |
| 409 |
% \SpecialOptIndex{donotfixamsmathbugs}\opt{donotfixamsmathbugs} |
| 410 |
% \end{codesyntax} |
| 411 |
% The option \opt{fixamsmath} (default) fixes two bugs in |
| 412 |
% \pkg{amsmath}.\footnote{See the online \LaTeX{} bugs database |
| 413 |
% \url{http://www.latex-project.org/cgi-bin/ltxbugs2html} under |
| 414 |
% \AmS-\LaTeX{} problem reports 3591 and 3614.} Should you for some |
| 415 |
% reason not want to fix these bugs then just add the option |
| 416 |
% \opt{donotfixamsmathbugs} (if you can do it without typos). The |
| 417 |
% reason for this extremely long name is that I really don't see why |
| 418 |
% you wouldn't want these bugs to be fixed, so I've made it slightly |
| 419 |
% difficult not to fix them. |
| 420 |
% |
| 421 |
% \begin{codesyntax} |
| 422 |
% \SpecialOptIndex{allowspaces}\opt{allowspaces}\texttt{~~~~} |
| 423 |
% \SpecialOptIndex{disallowspaces}\opt{disallowspaces} |
| 424 |
% \end{codesyntax} |
| 425 |
% Sometimes \pkg{amsmath} gives you nasty surprises, as here where |
| 426 |
% things look seemingly innocent: |
| 427 |
% \begin{verbatim} |
| 428 |
% \[ |
| 429 |
% \begin{gathered} |
| 430 |
% [t] = 100 \\ |
| 431 |
% [v] = 200 |
| 432 |
% \end{gathered} |
| 433 |
% \] |
| 434 |
% \end{verbatim} |
| 435 |
% Without \pkg{mathtools} this will result in this output: |
| 436 |
% \[ |
| 437 |
% \begin{gathered}[c] |
| 438 |
% = 100 \\ |
| 439 |
% [v] = 200 |
| 440 |
% \end{gathered} |
| 441 |
% \] |
| 442 |
% Yes, the \texttt{[t]} has been gobbled without warning! Note, with |
| 443 |
% modern \pkg{amsmath} \verb|\begin{gathered}[x]| will eat \verb|[x]| |
| 444 |
% and \emph{issue a warning unless} \texttt{x} is \texttt{t}, |
| 445 |
% \texttt{b} or \texttt{c}.\footnote{Older \pkg{amsmath} will |
| 446 |
% silently gobble the argument.} This is hardly what you'd expect |
| 447 |
% as an end user, as the desired output was probably something like |
| 448 |
% this instead: |
| 449 |
% \[ |
| 450 |
% \begin{gathered}[c] |
| 451 |
% [t] = 100 \\ |
| 452 |
% [v] = 200 |
| 453 |
% \end{gathered} |
| 454 |
% \] |
| 455 |
% With the option \opt{disallowspaces} (default) \pkg{mathtools} |
| 456 |
% disallows spaces in front of optional arguments where it could |
| 457 |
% possibly cause problems just as \pkg{amsmath} does with |\\| |
| 458 |
% inside the display environments. This includes the environments |
| 459 |
% \env{gathered} (and also those shown in \S |
| 460 |
% \vref{subsec:gathered}), \env{aligned}, \env{multlined}, and the |
| 461 |
% extended \env{matrix}-environments (\S \vref{subsubsec:matrices}). |
| 462 |
% If you however want to preserve the more dangerous standard |
| 463 |
% optional spaces, simply choose the option \opt{allowspaces}. |
| 464 |
% |
| 465 |
% \begin{codesyntax} |
| 466 |
% \SpecialOptIndex{legacycolonsymbols}\opt{legacycolonsymbols} |
| 467 |
% \end{codesyntax} |
| 468 |
% As of Summer 2022, we've had to rename several \cs{...colon...} |
| 469 |
% symbol macros in order to have a consistent naming scheme across |
| 470 |
% different packages.\footnote{For example with \pkg{unicode-math}.} |
| 471 |
% If needed, this package option brings back the original |
| 472 |
% \cs{...colon...} definitions. See page~\pageref{colonsymbols} for |
| 473 |
% more information. |
| 474 |
% |
| 475 |
% \section{Tools for mathematical typesetting} |
| 476 |
% |
| 477 |
% \begin{codesyntax} |
| 478 |
% \SpecialUsageIndex{\mathtoolsset}\cs{mathtoolsset}\marg{key val list} |
| 479 |
% \end{codesyntax} |
| 480 |
% Many of the tools shown in this manual can be turned on and off by |
| 481 |
% setting a switch to either true or false. In all cases it is done |
| 482 |
% with the command \cs{mathtoolsset}. A typical use could be something like |
| 483 |
% \begin{verbatim} |
| 484 |
% \mathtoolsset{ |
| 485 |
% showonlyrefs, |
| 486 |
% mathic % or mathic = true |
| 487 |
% } |
| 488 |
% \end{verbatim} |
| 489 |
% More information on the keys later on. |
| 490 |
% |
| 491 |
% |
| 492 |
% \subsection{Fine-tuning mathematical layout} |
| 493 |
% |
| 494 |
% Sometimes you need to tweak the layout of formulas a little to get |
| 495 |
% the best result and this part of the manual describes the various |
| 496 |
% macros \pkg{mathtools} provides for this. |
| 497 |
% |
| 498 |
% \subsubsection{A complement to \texttt{\textbackslash smash}, |
| 499 |
% \texttt{\textbackslash llap}, and \texttt{\textbackslash rlap}} |
| 500 |
% |
| 501 |
% \begin{codesyntax} |
| 502 |
% \SpecialUsageIndex{\mathllap} |
| 503 |
% \cs{mathllap}\oarg{mathstyle}\marg{math}\texttt{~~} |
| 504 |
% \SpecialUsageIndex{\mathclap} |
| 505 |
% \cs{mathclap}\oarg{mathstyle}\marg{math}\\ |
| 506 |
% \SpecialUsageIndex{\mathrlap} |
| 507 |
% \cs{mathrlap}\oarg{mathstyle}\marg{math}\texttt{~~} |
| 508 |
% \SpecialUsageIndex{\clap} |
| 509 |
% \cs{clap}\marg{text}\\ |
| 510 |
% \SpecialUsageIndex{\mathmbox} |
| 511 |
% \cs{mathmbox}\marg{math}\phantom{\meta{mathstyle}}\texttt{~~~~} |
| 512 |
% \SpecialUsageIndex{\mathmakebox} |
| 513 |
% \cs{mathmakebox}\oarg{width}\oarg{pos}\marg{math} |
| 514 |
% \end{codesyntax} |
| 515 |
% In \cite{Perlis01}, Alexander R.~Perlis describes some simple yet |
| 516 |
% useful macros for use in math displays. For example the display |
| 517 |
% \begin{verbatim} |
| 518 |
% \[ |
| 519 |
% X = \sum_{1\le i\le j\le n} X_{ij} |
| 520 |
% \] |
| 521 |
% \end{verbatim} |
| 522 |
% \[ |
| 523 |
% X = \sum_{1\le i\le j\le n} X_{ij} |
| 524 |
% \] |
| 525 |
% contains a lot of excessive white space. The idea that comes to |
| 526 |
% mind is to fake the width of the subscript. The command |
| 527 |
% \cs{mathclap} puts its argument in a zero width box and centers |
| 528 |
% it, so it could possibly be of use here. |
| 529 |
% \begin{verbatim} |
| 530 |
% \[ |
| 531 |
% X = \sum_{\mathclap{1\le i\le j\le n}} X_{ij} |
| 532 |
% \] |
| 533 |
% \end{verbatim} |
| 534 |
% \[ |
| 535 |
% X = \sum_{\mathclap{1\le i\le j\le n}} X_{ij} |
| 536 |
% \] |
| 537 |
% For an in-depth discussion of |
| 538 |
% these macros I find it better to read the article; an online |
| 539 |
% version can be found at |
| 540 |
% \begin{quote} |
| 541 |
% \url{http://www.tug.org/TUGboat/Articles/tb22-4/tb72perlS.pdf} |
| 542 |
% \end{quote} |
| 543 |
% Note that the definitions shown in the article do not exactly |
| 544 |
% match the definitions in \pkg{mathtools}. Besides providing an |
| 545 |
% optional argument for specifying the desired math style, these |
| 546 |
% versions also work around a most unfortunate \TeX{} |
| 547 |
% ``feature.''\footnote{The faulty reboxing procedure.} The |
| 548 |
% \cs{smash} macro is fixed too. |
| 549 |
% |
| 550 |
% |
| 551 |
% \subsubsection{Forcing a cramped style} |
| 552 |
% |
| 553 |
% \begin{codesyntax} |
| 554 |
% \SpecialUsageIndex{\cramped} |
| 555 |
% \cs{cramped}\oarg{mathstyle}\marg{math} |
| 556 |
% \end{codesyntax} |
| 557 |
% \cttPosting{Michael Herschorn}{1992/07/21} |
| 558 |
% Let's look at another example where we have used \cs{mathclap}: |
| 559 |
% \begin{verbatim} |
| 560 |
% \begin{equation}\label{eq:mathclap} |
| 561 |
% \sum_{\mathclap{a^2<b^2<c}}\qquad |
| 562 |
% \sum_{a^2<b^2<c} |
| 563 |
% \end{equation} |
| 564 |
% \end{verbatim} |
| 565 |
% \begin{equation}\label{eq:mathclap} |
| 566 |
% \sum_{\mathclap{a^2<b^2<c}}\qquad |
| 567 |
% \sum_{a^2<b^2<c} |
| 568 |
% \end{equation} |
| 569 |
% Do you see the difference? Maybe if I zoomed in a bit: |
| 570 |
% \begingroup \fontsize{24}{\baselineskip}\selectfont |
| 571 |
% \[ |
| 572 |
% \sum_{\mathclap{a^2<b^2<c}}\qquad |
| 573 |
% \sum_{a^2<b^2<c} |
| 574 |
% \] |
| 575 |
% \endgroup |
| 576 |
% Notice how the limit of the right summation sign is typeset in a |
| 577 |
% more compact style than the left. It is because \TeX{} sets the |
| 578 |
% limits of operators in a \emph{cramped} style. For each of \TeX's |
| 579 |
% four math styles (\cs{displaystyle}, \cs{textstyle}, |
| 580 |
% \cs{scriptstyle}, and \cs{scriptscriptstyle}), there also exists a |
| 581 |
% cramped style that doesn't raise exponents as much. Besides in the |
| 582 |
% limits of operators, \TeX{} also automatically uses these cramped |
| 583 |
% styles in radicals such as \cs{sqrt} and in the denominators of |
| 584 |
% fractions, but unfortunately there are no primitive commands that |
| 585 |
% allow you to detect crampedness or switch to it. |
| 586 |
% |
| 587 |
% \pkg{mathtools} offers the command \cs{cramped} which forces a |
| 588 |
% cramped style in normal un-cramped math. Additionally you can |
| 589 |
% choose which of the four styles you want it in as well by |
| 590 |
% specifying it as the optional argument: |
| 591 |
% \begin{verbatim} |
| 592 |
% \[ |
| 593 |
% \cramped{x^2} \leftrightarrow x^2 \quad |
| 594 |
% \cramped[\scriptstyle]{x^2} \leftrightarrow {\scriptstyle x^2} |
| 595 |
% \] |
| 596 |
% \end{verbatim} |
| 597 |
% \[ |
| 598 |
% \cramped{x^2} \leftrightarrow x^2 \quad |
| 599 |
% \cramped[\scriptstyle]{x^2} \leftrightarrow {\scriptstyle x^2} |
| 600 |
% \] |
| 601 |
% You may be surprised how often the cramped style can be |
| 602 |
% beneficial to your output. Take a look at this example: |
| 603 |
% \begin{verbatim} |
| 604 |
% \begin{quote} |
| 605 |
% The 2005 Euro\TeX{} conference is held in Abbaye des |
| 606 |
% Pr\'emontr\'es, France, marking the 16th ($2^{2^2}$) anniversary |
| 607 |
% of both Dante and GUTenberg (the German and French \TeX{} users |
| 608 |
% group resp.). |
| 609 |
% \end{quote} |
| 610 |
% \end{verbatim} |
| 611 |
% \begin{quote} |
| 612 |
% The 2005 Euro\TeX{} conference is held in Abbaye des |
| 613 |
% Pr\'emontr\'es, France, marking the 16th ($2^{2^2}$) anniversary |
| 614 |
% of both Dante and GUTenberg (the German and French \TeX{} users |
| 615 |
% group resp.). |
| 616 |
% \end{quote} |
| 617 |
% Typesetting on a grid is generally considered quite desirable, but |
| 618 |
% as the second line of the example shows, the exponents of $2$ |
| 619 |
% cause the line to be too tall for the normal value of |
| 620 |
% \cs{baselineskip}, so \TeX{} inserts a \cs{lineskip} (normal value |
| 621 |
% is \the\lineskip). In order to circumvent the problem, we can |
| 622 |
% force a cramped style so that the exponents aren't raised as much: |
| 623 |
% \begin{verbatim} |
| 624 |
% \begin{quote} |
| 625 |
% The 2005 Euro\TeX{} ... 16th ($\cramped{2^{2^2}}$) ... |
| 626 |
% \end{quote} |
| 627 |
% \end{verbatim} |
| 628 |
% \begin{quote} |
| 629 |
% The 2005 Euro\TeX{} conference is held in Abbaye des |
| 630 |
% Pr\'emontr\'es, France, marking the 16th ($\cramped{2^{2^2}}$) |
| 631 |
% anniversary of both Dante and GUTenberg (the German and French |
| 632 |
% \TeX{} users group resp.). |
| 633 |
% \end{quote} |
| 634 |
% |
| 635 |
% \begin{codesyntax} |
| 636 |
% \SpecialUsageIndex{\crampedllap} |
| 637 |
% \cs{crampedllap}\oarg{mathstyle}\marg{math}\texttt{~~} |
| 638 |
% \SpecialUsageIndex{\crampedclap} |
| 639 |
% \cs{crampedclap}\oarg{mathstyle}\marg{math}\\ |
| 640 |
% \SpecialUsageIndex{\crampedrlap} |
| 641 |
% \cs{crampedrlap}\oarg{mathstyle}\marg{math} |
| 642 |
% \end{codesyntax} |
| 643 |
% The commands \cs{crampedllap}, \cs{crampedclap}, and |
| 644 |
% \cs{crampedrlap} are identical to the three \cs{mathXlap} commands |
| 645 |
% described earlier except the argument is typeset in cramped style. |
| 646 |
% You need this in order to typeset \eqref{eq:mathclap} correctly |
| 647 |
% while still faking the width of the limit. |
| 648 |
% \begin{verbatim} |
| 649 |
% \begin{equation*}\label{eq:mathclap-b} |
| 650 |
% \sum_{\crampedclap{a^2<b^2<c}} |
| 651 |
% \tag{\ref{eq:mathclap}*} |
| 652 |
% \end{equation*} |
| 653 |
% \end{verbatim} |
| 654 |
% \begin{equation*}\label{eq:mathclap-b} |
| 655 |
% \sum_{\crampedclap{a^2<b^2<c}} |
| 656 |
% \tag{\ref{eq:mathclap}*} |
| 657 |
% \end{equation*} |
| 658 |
% Of course you could just type |
| 659 |
% \begin{verbatim} |
| 660 |
% \sum_{\mathclap{\cramped{a^2<b^2<c}}} |
| 661 |
% \end{verbatim} |
| 662 |
% but it has one major disadvantage: In order for \cs{mathXlap} and |
| 663 |
% \cs{cramped} to get the right size, \TeX{} has to process them |
| 664 |
% four times, meaning that nesting them as shown above will cause |
| 665 |
% \TeX{} to typeset $4^2$ instances before choosing the right one. |
| 666 |
% In this situation however, we will of course need the same style |
| 667 |
% for both commands so it makes sense to combine the commands in |
| 668 |
% one, thus letting \TeX{} make the choice only once rather than |
| 669 |
% twice. |
| 670 |
% |
| 671 |
% \begin{codesyntax} |
| 672 |
% \SpecialEnvIndex{crampedsubarray}\cs{begin}\arg{crampedsubarray}\marg{col} |
| 673 |
% \meta{contents} \cs{end}\arg{crampedsubarray}\\ |
| 674 |
% \SpecialUsageIndex{\crampedsubstack} |
| 675 |
% \cs{crampedsubstack}\marg{lines separated by \cs{}\cs{}} |
| 676 |
% \end{codesyntax} |
| 677 |
% \SuggestedBy{Henri Menke}{2019/07/08} If we go back to |
| 678 |
% \eqref{eq:mathclap} and apply \cs{substack}, you'll notice that the |
| 679 |
% cramped style, the sum would normally apply, is now gone: |
| 680 |
% \begin{verbatim} |
| 681 |
% \[ |
| 682 |
% \sum_{\substack{a^2<b^2<c}}\qquad |
| 683 |
% \sum_{a^2<b^2<c} |
| 684 |
% \] |
| 685 |
% \end{verbatim} |
| 686 |
% \begingroup \fontsize{24}{\baselineskip}\selectfont |
| 687 |
% \[ |
| 688 |
% \sum_{\substack{a^2<b^2<c}}\qquad |
| 689 |
% \sum_{a^2<b^2<c} |
| 690 |
% \] |
| 691 |
% \endgroup |
| 692 |
% We therefore provide a cramped version of |
| 693 |
% \cs{substack}.\footnote{\cs{substack} is internally implemented via |
| 694 |
% the \env{subarray}-env, so our cramped version of \cs{substack} is implemented via a |
| 695 |
% cramped version of this env.} |
| 696 |
% \begin{verbatim} |
| 697 |
% \[ |
| 698 |
% \sum_{\crampedsubstack{a^2<b^2<c}}\qquad |
| 699 |
% \sum_{a^2<b^2<c} |
| 700 |
% \] |
| 701 |
% \end{verbatim} |
| 702 |
% \begingroup \fontsize{24}{\baselineskip}\selectfont |
| 703 |
% \[ |
| 704 |
% \sum_{\crampedsubstack{a^2<b^2<c}}\qquad |
| 705 |
% \sum_{a^2<b^2<c} |
| 706 |
% \] |
| 707 |
% \endgroup |
| 708 |
% Note: We may need to add a similar hook into multlined. |
| 709 |
% |
| 710 |
% |
| 711 |
% |
| 712 |
% |
| 713 |
% |
| 714 |
% \subsubsection{Smashing an operator} |
| 715 |
% |
| 716 |
% |
| 717 |
% |
| 718 |
% \begin{codesyntax} |
| 719 |
% \SpecialUsageIndex{\smashoperator} |
| 720 |
% \cs{smashoperator}\oarg{pos}\marg{operator with limits} |
| 721 |
% \end{codesyntax} |
| 722 |
% \FeatureRequest{Lars Madsen}{2004/05/04} Above we showed how to get |
| 723 |
% \LaTeX{} to ignore the width of the subscript of an |
| 724 |
% operator. However this approach takes a lot of extra typing, |
| 725 |
% especially if you have a wide superscript, meaning you have to put |
| 726 |
% in \cs{crampedclap} in both sub- and superscript. To make things |
| 727 |
% easier, \pkg{mathtools} provides a \cs{smashoperator} command, |
| 728 |
% which simply ignores the width of the sub- and superscript. It also |
| 729 |
% takes an optional argument, \texttt{l}, \texttt{r}, or \texttt{lr} |
| 730 |
% (default, \texttt{rl} is an alias for \texttt{lr}), denoting which |
| 731 |
% side of the operator should be ignored (smashed). |
| 732 |
% \begin{verbatim} |
| 733 |
% \[ |
| 734 |
% V = \sum_{1\le i\le j\le n}^{\infty} V_{ij} \quad |
| 735 |
% X = \smashoperator{\sum_{1\le i\le j\le n}^{3456}} X_{ij} \quad |
| 736 |
% Y = \smashoperator[r]{\sum\limits_{1\le i\le j\le n}} Y_{ij} \quad |
| 737 |
% Z = \smashoperator[l]{\mathop{T}_{1\le i\le j\le n}} Z_{ij} |
| 738 |
% \] |
| 739 |
% \end{verbatim} |
| 740 |
% \[ |
| 741 |
% V = \sum_{1\le i\le j\le n}^{\infty} V_{ij} \quad |
| 742 |
% X = \smashoperator{\sum_{1\le i\le j\le n}^{3456}} X_{ij} \quad |
| 743 |
% Y = \smashoperator[r]{\sum\limits_{1\le i\le j\le n}} Y_{ij} \quad |
| 744 |
% Z = \smashoperator[l]{\mathop{T}_{1\le i\le j\le n}} Z_{ij} |
| 745 |
% \] |
| 746 |
% Note that \cs{smashoperator} always sets its argument in display |
| 747 |
% style and with limits even if you have used the \opt{nosumlimits} |
| 748 |
% option of \pkg{amsmath}. If you wish, you can use shorthands for |
| 749 |
% \texttt{\_} and \texttt{\textasciicircum} such as \cs{sb} and |
| 750 |
% \cs{sp}. |
| 751 |
% |
| 752 |
% |
| 753 |
% \subsubsection{Adjusting limits of operators} |
| 754 |
% |
| 755 |
% \begin{codesyntax} |
| 756 |
% \SpecialUsageIndex{\adjustlimits} |
| 757 |
% \cs{adjustlimits}\marg{operator$\sb1$}\texttt{\_}\marg{limit$\sb1$} |
| 758 |
% \marg{operator$\sb2$}\texttt{\_}\marg{limit$\sb2$} |
| 759 |
% \end{codesyntax} |
| 760 |
% \FeatureRequest{Lars Madsen}{2004/07/09} |
| 761 |
% When typesetting two consecutive operators with limits one often |
| 762 |
% wishes the limits of the operators were better aligned. Look |
| 763 |
% closely at these examples: |
| 764 |
% \begin{verbatim} |
| 765 |
% \[ |
| 766 |
% \text{a)} \lim_{n\to\infty} \max_{p\ge n} \quad |
| 767 |
% \text{b)} \lim_{n\to\infty} \max_{p^2\ge n} \quad |
| 768 |
% \text{c)} \lim_{n\to\infty} \sup_{p^2\ge nK} \quad |
| 769 |
% \text{d)} \limsup_{n\to\infty} \max_{p\ge n} |
| 770 |
% \] |
| 771 |
% \end{verbatim} |
| 772 |
% \[ |
| 773 |
% \text{a)} \lim_{n\to\infty} \max_{p\ge n} \quad |
| 774 |
% \text{b)} \lim_{n\to\infty} \max_{p^2\ge n} \quad |
| 775 |
% \text{c)} \lim_{n\to\infty} \sup_{p^2\ge nK} \quad |
| 776 |
% \text{d)} \limsup_{n\to\infty} \max_{p\ge n} |
| 777 |
% \] |
| 778 |
% a) looks okay, but b) is not quite as good because the second |
| 779 |
% limit ($\cramped{p^2\ge n}$) is significantly taller than the |
| 780 |
% first ($n\to\infty$). With c)~things begin to look really bad, |
| 781 |
% because the second operator has a descender while the first |
| 782 |
% doesn't, and finally we have d)~which looks just as bad as~c). The |
| 783 |
% command \cs{adjustlimits} is useful in these cases, as you can |
| 784 |
% just put it in front of these consecutive operators and it'll make |
| 785 |
% the limits line up. |
| 786 |
% \medskip\par\noindent |
| 787 |
% \begin{minipage}{\textwidth} |
| 788 |
% \begin{verbatim} |
| 789 |
% \[ |
| 790 |
% \text{a)} \adjustlimits\lim_{n\to\infty} \max_{p\ge n} \quad |
| 791 |
% \text{b)} \adjustlimits\lim_{n\to\infty} \max_{p^2\ge n} \quad |
| 792 |
% \text{c)} \adjustlimits\lim_{n\to\infty} \sup_{p^2\ge nK} \quad |
| 793 |
% \text{d)} \adjustlimits\limsup_{n\to\infty} \max_{p\ge n} |
| 794 |
% \] |
| 795 |
% \end{verbatim} |
| 796 |
% \end{minipage} |
| 797 |
% \[ |
| 798 |
% \text{a)} \adjustlimits\lim_{n\to\infty} \max_{p\ge n} \quad |
| 799 |
% \text{b)} \adjustlimits\lim_{n\to\infty} \max_{p^2\ge n} \quad |
| 800 |
% \text{c)} \adjustlimits\lim_{n\to\infty} \sup_{p^2\ge nK} \quad |
| 801 |
% \text{d)} \adjustlimits\limsup_{n\to\infty} \max_{p\ge n} |
| 802 |
% \] |
| 803 |
% The use of \cs{sb} instead of \texttt{\_} is allowed. |
| 804 |
% |
| 805 |
% |
| 806 |
% \subsubsection{Swapping space above \texorpdfstring{\AmS}{AMS} display math environments } |
| 807 |
% \label{sec:swapping} |
| 808 |
% |
| 809 |
% One feature that the plain old \env{equation} environment has that |
| 810 |
% the \AmS\ environments do not (because of technical reasons) is |
| 811 |
% the feature of using less space above the equation if the situation |
| 812 |
% presents itself. The \AmS\ environments cannot do this, but one can |
| 813 |
% manually, using |
| 814 |
% \begin{codesyntax} |
| 815 |
% \SpecialUsageIndex{\SwapAboveDisplaySkip} |
| 816 |
% \cs{SwapAboveDisplaySkip} |
| 817 |
% \end{codesyntax} |
| 818 |
% as the very first content within an \AmS\ display math |
| 819 |
% environment. It will then issue an \cs{abovedisplayshortskip} |
| 820 |
% instead of the normal \cs{abovedisplayskip}. |
| 821 |
% |
| 822 |
% Note it will not work with the \env{equation} or \env{multline} environments. |
| 823 |
% |
| 824 |
% Here is an example of the effect |
| 825 |
% \begin{verbatim} |
| 826 |
% \noindent\rule\textwidth{1pt} |
| 827 |
% \begin{align*} A &= B \end{align*} |
| 828 |
% \noindent\rule\textwidth{1pt} |
| 829 |
% \begin{align*} |
| 830 |
% \SwapAboveDisplaySkip |
| 831 |
% A &= B |
| 832 |
% \end{align*} |
| 833 |
% \end{verbatim} |
| 834 |
% \noindent\rule\textwidth{1pt} |
| 835 |
% \begin{align*} A &= B \end{align*} |
| 836 |
% \noindent\rule\textwidth{1pt} |
| 837 |
% \begin{align*} |
| 838 |
% \SwapAboveDisplaySkip |
| 839 |
% A &= B |
| 840 |
% \end{align*} |
| 841 |
% |
| 842 |
% |
| 843 |
% \subsection{Controlling tags} |
| 844 |
% |
| 845 |
% In this section various tools for altering the appearance of tags |
| 846 |
% are shown. All of the tools here can be used at any point in the |
| 847 |
% document but they should probably affect the whole document, so |
| 848 |
% the preamble is the best place to issue them. |
| 849 |
% |
| 850 |
% \subsubsection{The appearance of tags} |
| 851 |
% \begin{codesyntax} |
| 852 |
% \SpecialUsageIndex{\newtagform} |
| 853 |
% \cs{newtagform}\marg{name}\oarg{inner_format}\marg{left}\marg{right}\\ |
| 854 |
% \SpecialUsageIndex{\renewtagform} |
| 855 |
% \cs{renewtagform}\marg{name}\oarg{inner_format}\marg{left}\marg{right}\\ |
| 856 |
% \SpecialUsageIndex{\usetagform} |
| 857 |
% \cs{usetagform}\marg{name} |
| 858 |
% \end{codesyntax} |
| 859 |
% Altering the layout of equation numbers in \pkg{amsmath} is not |
| 860 |
% very user friendly (it involves a macro with three \texttt{@}'s in |
| 861 |
% its name), so \pkg{mathtools} provides an interface somewhat |
| 862 |
% reminiscent of the page style concept. This way you can define |
| 863 |
% several different tag forms and then choose the one you prefer. |
| 864 |
% |
| 865 |
% As an example let's try to define a tag form which puts the |
| 866 |
% equation number in square brackets. First we define a brand new tag |
| 867 |
% form: |
| 868 |
% \begin{verbatim} |
| 869 |
% \newtagform{brackets}{[}{]} |
| 870 |
% \end{verbatim} |
| 871 |
% Then we activate it: |
| 872 |
% \begin{verbatim} |
| 873 |
% \usetagform{brackets} |
| 874 |
% \end{verbatim} |
| 875 |
% The result is then |
| 876 |
% \newtagform{brackets}{[}{]} |
| 877 |
% \usetagform{brackets} |
| 878 |
% \begin{equation} |
| 879 |
% E \neq m c^3 |
| 880 |
% \end{equation} |
| 881 |
% |
| 882 |
% Similarly you could define a second version of the brackets that |
| 883 |
% prints the equation number in bold face instead |
| 884 |
% \begin{verbatim} |
| 885 |
% \newtagform{brackets2}[\textbf]{[}{]} |
| 886 |
% \usetagform{brackets2} |
| 887 |
% \begin{equation} |
| 888 |
% E \neq m c^3 |
| 889 |
% \end{equation} |
| 890 |
% \end{verbatim} |
| 891 |
% \newtagform{brackets2}[\textbf]{[}{]} |
| 892 |
% \usetagform{brackets2} |
| 893 |
% \begin{equation} |
| 894 |
% E \neq m c^3 |
| 895 |
% \end{equation} |
| 896 |
% When you reference an equation with \cs{eqref}, the tag form in |
| 897 |
% effect at the time of referencing controls the formatting, so be |
| 898 |
% careful if you use different tag forms throughout your document. |
| 899 |
% |
| 900 |
% If you want to renew a tag form, then use the command |
| 901 |
% \cs{renewtagform}. Should you want to |
| 902 |
% return to the standard setting then choose\usetagform{default} |
| 903 |
% \begin{verbatim} |
| 904 |
% \usetagform{default} |
| 905 |
% \end{verbatim} |
| 906 |
% |
| 907 |
% \changes{v1.12}{2012/05/09}{Added caveat} |
| 908 |
% \noindent\textbf{Caveat regarding \pkg{ntheorem}}: If you like to |
| 909 |
% change the appearence of the tags \emph{and} you are also using the |
| 910 |
% \pkg{ntheorem} package, then please postpone the change of |
| 911 |
% appearance until \emph{after} loading \pkg{ntheorem}. (In order to |
| 912 |
% do its thing, \pkg{ntheorem} has to mess with the tags\dots) |
| 913 |
% |
| 914 |
% \subsubsection{Showing only referenced tags} |
| 915 |
% |
| 916 |
% \begin{codesyntax} |
| 917 |
% \SpecialKeyIndex{showonlyrefs}$\key{showonlyrefs}=\texttt{true}\vert\texttt{false}$\\ |
| 918 |
% \SpecialKeyIndex{showmanualtags}$\key{showmanualtags}=\texttt{true}\vert\texttt{false}$\\ |
| 919 |
% \SpecialUsageIndex{\refeq}\cs{refeq}\marg{label} |
| 920 |
% \end{codesyntax} |
| 921 |
% First of, one should always use \cs{eqref} when referring to |
| 922 |
% equation numbers. When \opt{showonlyrefs} is true, we monitor |
| 923 |
% \cs{eqref}\marg{label}, and those used will get an equation number, |
| 924 |
% whereas those not used will not. Note: We do \emph{not} monitor the |
| 925 |
% normal \cs{ref} command! See the follow paragraph for situations |
| 926 |
% for what to do when \cs{eqref} cannot be used to refer to the equation. |
| 927 |
% |
| 928 |
% An equation where the tag is produced with a manual \cs{tag*} |
| 929 |
% shouldn't be referenced with the normal \cs{eqref} because that |
| 930 |
% would format it according to the current tag format. Using just |
| 931 |
% \cs{ref} on the other hand may not be a good solution either as |
| 932 |
% the argument of \cs{tag*} is always set in upright shape in the |
| 933 |
% equation and you may be referencing it in italic text. In the |
| 934 |
% example below, the command \cs{refeq} is used to avoid what could |
| 935 |
% possibly lead to confusion in cases where the tag font has very |
| 936 |
% different form in upright and italic shape (here we switch to |
| 937 |
% Palatino in the example): |
| 938 |
% \begin{verbatim} |
| 939 |
% \begin{quote}\renewcommand*\rmdefault{ppl}\normalfont\itshape |
| 940 |
% \begin{equation*} |
| 941 |
% a=b \label{eq:example}\tag*{Q\&A} |
| 942 |
% \end{equation*} |
| 943 |
% See \ref{eq:example} or is it better with \refeq{eq:example}? |
| 944 |
% \end{quote} |
| 945 |
% \end{verbatim} |
| 946 |
% \begin{quote}\renewcommand*\rmdefault{ppl}\normalfont\itshape |
| 947 |
% \begin{equation*} |
| 948 |
% a=b \label{eq:example}\tag*{Q\&A} |
| 949 |
% \end{equation*} |
| 950 |
% See \ref{eq:example} or is it better with \refeq{eq:example}? |
| 951 |
% \end{quote} |
| 952 |
% |
| 953 |
% |
| 954 |
% Another problem sometimes faced is the need for showing the |
| 955 |
% equation numbers for only those equations actually referenced. In |
| 956 |
% \pkg{mathtools} this can be done by setting the key |
| 957 |
% \key{showonlyrefs} to either true or false by using |
| 958 |
% \cs{mathtoolsset}. You can also choose whether or not to show the |
| 959 |
% manual tags specified with \cs{tag} or \cs{tag*} by setting the |
| 960 |
% option \key{showmanualtags} to true or false.\footnote{I recommend |
| 961 |
% setting \key{showmanualtags} to true, else the whole idea of using |
| 962 |
% \cs{tag} doesn't really make sense, does it?} For both keys just |
| 963 |
% typing the name of it chooses true as shown in the following |
| 964 |
% example. |
| 965 |
% |
| 966 |
% \begin{verbatim} |
| 967 |
% \mathtoolsset{showonlyrefs,showmanualtags} |
| 968 |
% \usetagform{brackets} |
| 969 |
% \begin{gather} |
| 970 |
% a=a \label{eq:a} \\ |
| 971 |
% b=b \label{eq:b} \tag{**} |
| 972 |
% \end{gather} |
| 973 |
% This should refer to the equation containing $a=a$: \eqref{eq:a}. |
| 974 |
% Then a switch of tag forms. |
| 975 |
% \usetagform{default} |
| 976 |
% \begin{align} |
| 977 |
% c&=c \label{eq:c} \\ |
| 978 |
% d&=d \label{eq:d} |
| 979 |
% \end{align} |
| 980 |
% This should refer to the equation containing $d=d$: \eqref{eq:d}. |
| 981 |
% \begin{equation} |
| 982 |
% e=e |
| 983 |
% \end{equation} |
| 984 |
% Back to normal.\mathtoolsset{showonlyrefs=false} |
| 985 |
% \begin{equation} |
| 986 |
% f=f |
| 987 |
% \end{equation} |
| 988 |
% \end{verbatim} |
| 989 |
% \mathtoolsset{showonlyrefs,showmanualtags} |
| 990 |
% \usetagform{brackets} |
| 991 |
% \begin{gather} |
| 992 |
% a=a \label{eq:a} \\ |
| 993 |
% b=b \label{eq:b} \tag{**} |
| 994 |
% \end{gather} |
| 995 |
% This should refer to the equation containing $a=a$: \eqref{eq:a}. |
| 996 |
% Then a switch of tag forms. |
| 997 |
% \usetagform{default} |
| 998 |
% \begin{align} |
| 999 |
% c&=c \label{eq:c} \\ |
| 1000 |
% d&=d \label{eq:d} |
| 1001 |
% \end{align} |
| 1002 |
% This should refer to the equation containing $d=d$: \eqref{eq:d}. |
| 1003 |
% \begin{equation} |
| 1004 |
% e=e |
| 1005 |
% \end{equation} |
| 1006 |
% Back to normal.\mathtoolsset{showonlyrefs=false} |
| 1007 |
% \begin{equation} |
| 1008 |
% f=f |
| 1009 |
% \end{equation} |
| 1010 |
% |
| 1011 |
% Note that this feature only works if you use \cs{eqref} or |
| 1012 |
% \cs{refeq} to reference your equations. |
| 1013 |
% |
| 1014 |
% When using \key{showonlyrefs} it might be useful to be able to |
| 1015 |
% actually add a few equation numbers without directly referring to |
| 1016 |
% them. |
| 1017 |
% \begin{codesyntax} |
| 1018 |
% \SpecialUsageIndex{\noeqref}\cs{noeqref}\marg{label,label,\dots} |
| 1019 |
% \end{codesyntax} |
| 1020 |
% \FeatureRequest{Rasmus Villemoes}{2008/03/26} |
| 1021 |
% The syntax is somewhat similar to \cs{nocite}. If a label in the |
| 1022 |
% list is undefined we will throw a warning in the same manner as |
| 1023 |
% \cs{ref}. |
| 1024 |
% |
| 1025 |
% \medskip\noindent\textbf{BUG 1:} Unfortunately the use of the |
| 1026 |
% \key{showonlyref} introduces a bug within amsmath's typesetting |
| 1027 |
% of formula versus equation number. This bug manifests itself by |
| 1028 |
% allowing formulas to be typeset close to or over the equation |
| 1029 |
% number. Currently no general fix is known, other than making sure |
| 1030 |
% that one's formulas are not long enough to touch the equation |
| 1031 |
% number. |
| 1032 |
% |
| 1033 |
% To make a long story short, amsmath typesets its math environments |
| 1034 |
% twice, one time for measuring and one time for the actual |
| 1035 |
% typesetting. In the measuring part, the width of the equation |
| 1036 |
% number is recorded such that the formula or the equation number can |
| 1037 |
% be moved (if necessary) in the typesetting part. When |
| 1038 |
% \key{showonlyref} is enabled, the width of the equation number |
| 1039 |
% depends on whether or not this number is referred~to. To determine |
| 1040 |
% this, we need to know the current label. But the current label is |
| 1041 |
% \emph{not} known in the measuring phase. Thus the measured width is |
| 1042 |
% always zero (because no label equals not referred to) and therefore |
| 1043 |
% the typesetting phase does not take the equation number into |
| 1044 |
% account. |
| 1045 |
% |
| 1046 |
% \medskip\noindent\textbf{BUG 2:} There is a bug between |
| 1047 |
% \key{showonlyrefs} and the \pkg{ntheorem} package, when the |
| 1048 |
% \pkg{ntheorem} option \key{thmmarks} is active. The shown equation |
| 1049 |
% numbers may come out wrong (seems to be multiplied by 2). Or the end |
| 1050 |
% marker may be placed in the wrong place if a proof ends with a |
| 1051 |
% displayed formula, and that formula is not referred to. |
| 1052 |
% |
| 1053 |
% There are two possible solutions to this both involving \pkg{empheq}. |
| 1054 |
% The easiest fix is to add the following line |
| 1055 |
% \begin{verbatim} |
| 1056 |
% \usepackage[overload,ntheorem]{empheq} |
| 1057 |
% \end{verbatim} |
| 1058 |
% before loading \pkg{ntheorem}. But the \texttt{overload} option of |
| 1059 |
% course disables things like \cs{intertext} and \cs{shortintertext}. |
| 1060 |
% |
| 1061 |
% The other thing to try is to drop the \texttt{overload} option |
| 1062 |
% and use \env{empheq} on the very last expression, as in |
| 1063 |
% \begin{verbatim} |
| 1064 |
% \begin{empheq}{align} |
| 1065 |
% A &= B \label {eq:32}\\ |
| 1066 |
% & = 1. \label{eq:31} |
| 1067 |
% \end{empheq} |
| 1068 |
% \end{proof} |
| 1069 |
% \end{verbatim} |
| 1070 |
% |
| 1071 |
% The \pkg{empheq} package fixes some |
| 1072 |
% problems with \pkg{ntheorem} and lets \pkg{mathtools} get correct |
| 1073 |
% access to the equation numbers again. |
| 1074 |
% |
| 1075 |
% \subsection{Extensible symbols} |
| 1076 |
% |
| 1077 |
% The number of horizontally extensible symbols in standard \LaTeX{} |
| 1078 |
% and \pkg{amsmath} is somewhat low. This part of the manual |
| 1079 |
% describes what \pkg{mathtools} does to help this situation. |
| 1080 |
% |
| 1081 |
% \subsubsection{Arrow-like symbols} |
| 1082 |
% |
| 1083 |
% |
| 1084 |
% \begin{codesyntax} |
| 1085 |
% \SpecialUsageIndex{\xleftrightarrow} |
| 1086 |
% \cs{xleftrightarrow}\oarg{sub}\marg{sup}\texttt{~~~~~~~~~} |
| 1087 |
% \SpecialUsageIndex{\xRightarrow} |
| 1088 |
% \cs{xRightarrow}\oarg{sub}\marg{sup}\\ |
| 1089 |
% \SpecialUsageIndex{\xLeftarrow} |
| 1090 |
% \cs{xLeftarrow}\oarg{sub}\marg{sup}\texttt{~~~~~~~~~~~~~~} |
| 1091 |
% \SpecialUsageIndex{\xLeftrightarrow} |
| 1092 |
% \cs{xLeftrightarrow}\oarg{sub}\marg{sup}\\ |
| 1093 |
% \SpecialUsageIndex{\xhookleftarrow} |
| 1094 |
% \cs{xhookleftarrow}\oarg{sub}\marg{sup}\texttt{~~~~~~~~~~} |
| 1095 |
% \SpecialUsageIndex{\xhookrightarrow} |
| 1096 |
% \cs{xhookrightarrow}\oarg{sub}\marg{sup}\\ |
| 1097 |
% \SpecialUsageIndex{\xmapsto} |
| 1098 |
% \cs{xmapsto}\oarg{sub}\marg{sup} |
| 1099 |
% \end{codesyntax} |
| 1100 |
% Extensible arrows are part of \pkg{amsmath} in the form of the |
| 1101 |
% commands |
| 1102 |
% \begin{quote} |
| 1103 |
% \cs{xrightarrow}\oarg{subscript}\marg{superscript}\quad and\\ |
| 1104 |
% \cs{xleftarrow}\oarg{subscript}\marg{superscript} |
| 1105 |
% \end{quote} |
| 1106 |
% But what about extensible versions of say, \cs{leftrightarrow} or |
| 1107 |
% \cs{Longleftarrow}? It turns out that the above mentioned |
| 1108 |
% extensible arrows are the only two of their kind defined by |
| 1109 |
% \pkg{amsmath}, but luckily \pkg{mathtools} helps with that. The |
| 1110 |
% extensible arrow-like symbols in \pkg{mathtools} follow the same |
| 1111 |
% naming scheme as the one's in \pkg{amsmath} so to get an extensible |
| 1112 |
% \cs{Leftarrow} you simply do a |
| 1113 |
% \begin{verbatim} |
| 1114 |
% \[ |
| 1115 |
% A \xLeftarrow[under]{over} B |
| 1116 |
% \] |
| 1117 |
% \end{verbatim} |
| 1118 |
% \[ |
| 1119 |
% A \xLeftarrow[under]{over} B |
| 1120 |
% \] |
| 1121 |
% \textbf{Caveat for \cs{xmapsto}:} Whenever \pkg{unicode-math} is |
| 1122 |
% used, the macro \cs{xmapsto} will not work correctly (a random 7 |
| 1123 |
% appears). This is due to how we define \cs{xmapsto}: the symbol |
| 1124 |
% »\,$\mapstochar{}$\,« (via \cs{mapstochar}, setup in the \LaTeX{} |
| 1125 |
% kernel) and extensible \cs{rightarrow}. The symbol behind |
| 1126 |
% \cs{mapstochar} is not defined in unicode, and thus is not |
| 1127 |
% available in the unicode math fonts.\footnote{The symbol |
| 1128 |
% $\mapsto$ \emph{is} in unicode and \pkg{unicode-math} maps |
| 1129 |
% \cs{mapsto} onto this symbol in the unicode math font. Whereas |
| 1130 |
% without \pkg{unicode-math}, \cs{mapsto} is a symbol constructed |
| 1131 |
% by combining \cs{mapstochar} and \cs{rightarrow}. On the other |
| 1132 |
% hand \textsf{lualatex} \emph{does} have some special macros to |
| 1133 |
% create extensible arrows, but \emph{none} of these can write above |
| 1134 |
% \emph{and} below at the same time. So for now we leave this |
| 1135 |
% unresolved.} |
| 1136 |
% \begin{codesyntax} |
| 1137 |
% \SpecialUsageIndex{\xrightharpoondown} |
| 1138 |
% \cs{xrightharpoondown}\oarg{sub}\marg{sup}\texttt{~~~~} |
| 1139 |
% \SpecialUsageIndex{\xrightharpoonup} |
| 1140 |
% \cs{xrightharpoonup}\oarg{sub}\marg{sup}\\ |
| 1141 |
% \SpecialUsageIndex{\xleftharpoondown} |
| 1142 |
% \cs{xleftharpoondown}\oarg{sub}\marg{sup}\texttt{~~~~~} |
| 1143 |
% \SpecialUsageIndex{\xleftharpoonup} |
| 1144 |
% \cs{xleftharpoonup}\oarg{sub}\marg{sup}\\ |
| 1145 |
% \SpecialUsageIndex{\xrightleftharpoons} |
| 1146 |
% \cs{xrightleftharpoons}\oarg{sub}\marg{sup}\texttt{~~~} |
| 1147 |
% \SpecialUsageIndex{\xleftrightharpoons} |
| 1148 |
% \cs{xleftrightharpoons}\oarg{sub}\marg{sup} |
| 1149 |
% \end{codesyntax} |
| 1150 |
% \pkg{mathtools} also provides the extensible harpoons shown above. |
| 1151 |
% They're taken from~\cite{Voss:2004}. For those liking visuals, here |
| 1152 |
% are the macros in use in the order listed in the two boxes above. |
| 1153 |
% \begin{align*} |
| 1154 |
% A &\xleftrightarrow[below]{above} B & |
| 1155 |
% A &\xRightarrow[below]{above} B \\ |
| 1156 |
% A &\xLeftarrow[below]{above} B & |
| 1157 |
% A &\xLeftrightarrow[below]{above} B \\ |
| 1158 |
% A &\xhookleftarrow[below]{above} B & |
| 1159 |
% A &\xhookrightarrow[below]{above} B \\ |
| 1160 |
% A &\xmapsto[below]{above} B \\ |
| 1161 |
% A &\xrightharpoondown[below]{above} B & |
| 1162 |
% A &\xrightharpoonup[below]{above} B \\ |
| 1163 |
% A &\xleftharpoondown[below]{above} B & |
| 1164 |
% A &\xleftharpoonup[below]{above} B \\ |
| 1165 |
% A &\xrightleftharpoons[below]{above} B & |
| 1166 |
% A &\xleftrightharpoons[below]{above} B \\ |
| 1167 |
% \end{align*} |
| 1168 |
% Change in 2020: In \cs{xLeftarrow}, \cs{xRightarrow} and |
| 1169 |
% \cs{xLeftrightarrow} we added a space to the argument(s), making |
| 1170 |
% the arrow slightly longer and moving the argument away from the |
| 1171 |
% large arrow head. |
| 1172 |
% |
| 1173 |
% \begin{codesyntax} |
| 1174 |
% \SpecialUsageIndex{\xlongrightarrow} |
| 1175 |
% \cs{xlongrightarrow}\oarg{sub}\marg{sup}\texttt{~~~~} |
| 1176 |
% \SpecialUsageIndex{\xlongleftarrow} |
| 1177 |
% \cs{xlongleftarrow}\oarg{sub}\marg{sup}\texttt{~~~~} |
| 1178 |
% \end{codesyntax} |
| 1179 |
% \FeatureRequest{rbrito {\footnotesize (issue \#12)}}{added 2022}% |
| 1180 |
% Similar to \cs{xright/leftarrow} but based on the \emph{long} |
| 1181 |
% versions. For short arguments it stays the same length as the |
| 1182 |
% \cs{long...} base arrow. |
| 1183 |
% \begin{align*} |
| 1184 |
% A & \longrightarrow B & A & \longleftarrow B \\ |
| 1185 |
% A & \xlongrightarrow[b]{a} B & A & \xlongleftarrow[b]{a} B \\ |
| 1186 |
% A & \xlongrightarrow[below]{above} B & A & \xlongleftarrow[below]{above} B \\ |
| 1187 |
% \end{align*} |
| 1188 |
% \begin{codesyntax} |
| 1189 |
% \SpecialUsageIndex{\xLongrightarrow} |
| 1190 |
% \cs{xLongrightarrow}\oarg{sub}\marg{sup}\texttt{~~~~} |
| 1191 |
% \SpecialUsageIndex{\xLongleftarrow} |
| 1192 |
% \cs{xLongleftarrow}\oarg{sub}\marg{sup}\texttt{~~~~} |
| 1193 |
% \end{codesyntax} |
| 1194 |
% \FeatureRequest{quarkQuark {\footnotesize (issue \#51)}}{added 2024}% |
| 1195 |
% Similar to \cs{xRight/Leftarrow} but based on the \emph{long} |
| 1196 |
% versions. For short arguments it stays the same length as the |
| 1197 |
% \cs{long...} base arrow. |
| 1198 |
% \begin{align*} |
| 1199 |
% A & \xLongrightarrow B & A & \Longleftarrow B \\ |
| 1200 |
% A & \xLongrightarrow[b]{a} B & A & \xLongleftarrow[b]{a} B \\ |
| 1201 |
% A & \xLongrightarrow[below]{above} B & A & \xLongleftarrow[below]{above} B \\ |
| 1202 |
% \end{align*} |
| 1203 |
|
| 1204 |
% |
| 1205 |
% |
| 1206 |
% |
| 1207 |
% \subsubsection{Braces and brackets} |
| 1208 |
% |
| 1209 |
% \LaTeX{} defines other kinds of extensible symbols like |
| 1210 |
% \cs{overbrace} and \cs{underbrace}, but sometimes you may want |
| 1211 |
% another symbol, say, a bracket. |
| 1212 |
% \begin{codesyntax} |
| 1213 |
% \SpecialUsageIndex{\underbracket}\cs{underbracket}\oarg{rule thickness} |
| 1214 |
% \oarg{bracket height}\marg{arg}\\ |
| 1215 |
% \SpecialUsageIndex{\overbracket}\cs{overbracket}\oarg{rule thickness} |
| 1216 |
% \oarg{bracket height}\marg{arg} |
| 1217 |
% \end{codesyntax} |
| 1218 |
% The commands \cs{underbracket} and \cs{overbracket} are inspired |
| 1219 |
% by \cite{Voss:2004}, although the implementation here is slightly |
| 1220 |
% different. |
| 1221 |
% Used without the optional arguments the bracket commands produce this: |
| 1222 |
% \begin{quote} |
| 1223 |
% |$\underbracket {foo\ bar}_{baz}$|\quad $\underbracket {foo\ bar}_{baz}$ \\ |
| 1224 |
% |$\overbracket {foo\ bar}^{baz}$ |\quad $\overbracket {foo\ bar}^{baz}$ |
| 1225 |
% \end{quote} |
| 1226 |
% The default rule thickness is equal to that of \cs{underbrace} |
| 1227 |
% (app.~$5/18$\,ex) while the default bracket height is equal to |
| 1228 |
% app.~$0.7$\,ex. These values give really pleasing results in all |
| 1229 |
% font sizes, but feel free to use the optional arguments. That way |
| 1230 |
% you may get ``beauties'' like |
| 1231 |
% \begin{verbatim} |
| 1232 |
% \[ |
| 1233 |
% \underbracket[3pt]{xxx\ yyy}_{zzz} \quad \text{and} \quad |
| 1234 |
% \underbracket[1pt][7pt]{xxx\ yyy}_{zzz} |
| 1235 |
% \] |
| 1236 |
% \end{verbatim} |
| 1237 |
% \[ |
| 1238 |
% \underbracket[3pt]{xxx\ yyy}_{zzz} \quad \text{and} \quad |
| 1239 |
% \underbracket[1pt][7pt]{xxx\ yyy}_{zzz} |
| 1240 |
% \] |
| 1241 |
% \begin{codesyntax} |
| 1242 |
% \SpecialUsageIndex{\underbrace}\cs{underbrace}\marg{arg}\texttt{~~} |
| 1243 |
% \SpecialUsageIndex{\LaTeXunderbrace}\cs{LaTeXunderbrace}\marg{arg}\\ |
| 1244 |
% \SpecialUsageIndex{\overbrace}\cs{overbrace}\marg{arg}\texttt{~~~} |
| 1245 |
% \SpecialUsageIndex{\LaTeXoverbrace}\cs{LaTeXoverbrace}\marg{arg} |
| 1246 |
% \end{codesyntax} |
| 1247 |
% The standard implementation of the math operators \cs{underbrace} |
| 1248 |
% and \cs{overbrace} in \LaTeX{} has some deficiencies. For example, |
| 1249 |
% all lengths used internally are \emph{fixed} and optimized for |
| 1250 |
% 10\,pt typesetting. As a direct consequence thereof, using font |
| 1251 |
% sizes other than 10 will produce less than optimal results. |
| 1252 |
% Another unfortunate feature is the size of the braces. In the |
| 1253 |
% example below, notice how the math operator \cs{sum} places its |
| 1254 |
% limit compared to \cs{underbrace}. |
| 1255 |
% \[ |
| 1256 |
% \mathop{\thinboxed[blue]{\sum}}_{n} |
| 1257 |
% \mathop{\thinboxed[blue]{\LaTeXunderbrace{\thinboxed[green]{foof}}}}_{zzz} |
| 1258 |
% \] |
| 1259 |
% The blue lines indicate the dimensions of the math operator and |
| 1260 |
% the green lines the dimensions of $foof$. As you can see, there |
| 1261 |
% seems to be too much space between the brace and the $zzz$ whereas |
| 1262 |
% the space between brace and $foof$ is okay. Let's see what happens |
| 1263 |
% when we use a bigger font size:\par\Huge\vskip-\baselineskip |
| 1264 |
% \[ |
| 1265 |
% \mathop{\thinboxed[blue]{\sum}}_{n} |
| 1266 |
% \mathop{\thinboxed[blue]{\LaTeXunderbrace{\thinboxed[green]{foof}}}}_{zzz} |
| 1267 |
% \] |
| 1268 |
% \normalsize Now there's too little space between the brace and the |
| 1269 |
% $zzz$ and also too little space between the brace and the $foof$. |
| 1270 |
% If you use Computer Modern you'll actually see that the $f$ |
| 1271 |
% overlaps with the brace! Let's try in \cs{footnotesize}: |
| 1272 |
% \par\footnotesize |
| 1273 |
% \[ |
| 1274 |
% \mathop{\thinboxed[blue]{\sum}}_{n} |
| 1275 |
% \mathop{\thinboxed[blue]{\LaTeXunderbrace{\thinboxed[green]{foof}}}}_{zzz} |
| 1276 |
% \]\normalsize |
| 1277 |
% Here the spacing above and below the brace is quite excessive. |
| 1278 |
% |
| 1279 |
% As \cs{overbrace} has the exact same problems, there are good |
| 1280 |
% reasons for \pkg{mathtools} to make redefinitions of |
| 1281 |
% \cs{underbrace} and \cs{overbrace}. These new versions work |
| 1282 |
% equally well in all font sizes and fix the spacing issues and |
| 1283 |
% apart from working with the default Computer Modern fonts, they |
| 1284 |
% also work with the packages \pkg{mathpazo}, \pkg{pamath}, |
| 1285 |
% \pkg{fourier}, \pkg{eulervm}, \pkg{cmbright}, and \pkg{mathptmx}. |
| 1286 |
% If you use the \pkg{ccfonts} to get the full Concrete fonts, the |
| 1287 |
% original version saved under the names \cs{LaTeXunderbrace} and |
| 1288 |
% \cs{LaTeXoverbrace} is better, due to the special design of |
| 1289 |
% the Concrete extensible braces. In that case you should probably |
| 1290 |
% just add the lines |
| 1291 |
% \begin{verbatim} |
| 1292 |
% \let\underbrace\LaTeXunderbrace |
| 1293 |
% \let\overbrace\LaTeXoverbrace |
| 1294 |
% \end{verbatim} |
| 1295 |
% to your preamble after loading \pkg{mathtools} which will restore |
| 1296 |
% the original definitions of \cs{overbrace} and \cs{underbrace}. |
| 1297 |
% |
| 1298 |
% |
| 1299 |
% |
| 1300 |
% |
| 1301 |
% \subsection{New mathematical building blocks} |
| 1302 |
% |
| 1303 |
% In this part of the manual, various mathematical environments are |
| 1304 |
% described. |
| 1305 |
% |
| 1306 |
% \subsubsection{Matrices}\label{subsubsec:matrices} |
| 1307 |
% |
| 1308 |
% \begin{codesyntax} |
| 1309 |
% \SpecialEnvIndex{matrix*}\cs{begin}\arg{matrix*}\texttt{ }\oarg{col} |
| 1310 |
% \meta{contents} \cs{end}\arg{matrix*}\\ |
| 1311 |
% \SpecialEnvIndex{pmatrix*}\cs{begin}\arg{pmatrix*}\oarg{col} |
| 1312 |
% \meta{contents} \cs{end}\arg{pmatrix*}\\ |
| 1313 |
% \SpecialEnvIndex{bmatrix*}\cs{begin}\arg{bmatrix*}\oarg{col} |
| 1314 |
% \meta{contents} \cs{end}\arg{bmatrix*}\\ |
| 1315 |
% \SpecialEnvIndex{Bmatrix*}\cs{begin}\arg{Bmatrix*}\oarg{col} |
| 1316 |
% \meta{contents} \cs{end}\arg{Bmatrix*}\\ |
| 1317 |
% \SpecialEnvIndex{vmatrix*}\cs{begin}\arg{vmatrix*}\oarg{col} |
| 1318 |
% \meta{contents} \cs{end}\arg{vmatrix*}\\ |
| 1319 |
% \SpecialEnvIndex{Vmatrix*}\cs{begin}\arg{Vmatrix*}\oarg{col} |
| 1320 |
% \meta{contents} \cs{end}\arg{Vmatrix*} |
| 1321 |
% \end{codesyntax} |
| 1322 |
% \FeatureRequest{Lars Madsen}{2004/04/05} |
| 1323 |
% All of the \pkg{amsmath} \env{matrix} environments center the |
| 1324 |
% columns by default, which is not always what you want. Thus |
| 1325 |
% \pkg{mathtools} provides a starred version for each of the original |
| 1326 |
% environments. These starred environments take an optional argument |
| 1327 |
% specifying the alignment of the columns, so that |
| 1328 |
% \begin{verbatim} |
| 1329 |
% \[ |
| 1330 |
% \begin{pmatrix*}[r] |
| 1331 |
% -1 & 3 \\ |
| 1332 |
% 2 & -4 |
| 1333 |
% \end{pmatrix*} |
| 1334 |
% \] |
| 1335 |
% \end{verbatim} |
| 1336 |
% yields |
| 1337 |
% \[ |
| 1338 |
% \begin{pmatrix*}[r] |
| 1339 |
% -1 & 3 \\ |
| 1340 |
% 2 & -4 |
| 1341 |
% \end{pmatrix*} |
| 1342 |
% \] |
| 1343 |
% The optional argument (default is \texttt{[c]}) can be any column |
| 1344 |
% type valid in the usual \env{array} environment. |
| 1345 |
% |
| 1346 |
% While we are at it, we also provide fenced versions of the |
| 1347 |
% \env{smallmatrix} environment. To keep up with the naming of the |
| 1348 |
% large matrix environments, we provide both a starred and a |
| 1349 |
% non-starred version. Since \env{smallmatrix} is defined in a |
| 1350 |
% different manner than the \env{matrix} environment, the option to |
| 1351 |
% say \env{smallmatrix*} \emph{has} to be either \texttt{c}, |
| 1352 |
% \texttt{l} \emph{or}~\texttt{r}. The default is \texttt{c}, which |
| 1353 |
% can be changed globally using the \key{smallmatrix-align}=\meta{c,l |
| 1354 |
% or r}. |
| 1355 |
% \begin{codesyntax} |
| 1356 |
% \SpecialEnvIndex{smallmatrix*}\cs{begin}\arg{smallmatrix*}\texttt{ }\oarg{col} |
| 1357 |
% \meta{contents} \cs{end}\arg{smallmatrix*}\\ |
| 1358 |
% \SpecialEnvIndex{psmallmatrix}\cs{begin}\arg{psmallmatrix} |
| 1359 |
% \meta{contents} \cs{end}\arg{psmallmatrix}\\ |
| 1360 |
% \SpecialEnvIndex{psmallmatrix*}\cs{begin}\arg{psmallmatrix*}\oarg{col} |
| 1361 |
% \meta{contents} \cs{end}\arg{psmallmatrix*}\\ |
| 1362 |
% \SpecialEnvIndex{bsmallmatrix}\cs{begin}\arg{bsmallmatrix} |
| 1363 |
% \meta{contents} \cs{end}\arg{bsmallmatrix}\\ |
| 1364 |
% \SpecialEnvIndex{bsmallmatrix*}\cs{begin}\arg{bsmallmatrix*}\oarg{col} |
| 1365 |
% \meta{contents} \cs{end}\arg{bsmallmatrix*}\\ |
| 1366 |
% \SpecialEnvIndex{Bsmallmatrix}\cs{begin}\arg{Bsmallmatrix} |
| 1367 |
% \meta{contents} \cs{end}\arg{Bsmallmatrix}\\ |
| 1368 |
% \SpecialEnvIndex{Bsmallmatrix*}\cs{begin}\arg{Bsmallmatrix*}\oarg{col} |
| 1369 |
% \meta{contents} \cs{end}\arg{Bsmallmatrix*}\\ |
| 1370 |
% \SpecialEnvIndex{vsmallmatrix}\cs{begin}\arg{vsmallmatrix} |
| 1371 |
% \meta{contents} \cs{end}\arg{vsmallmatrix}\\ |
| 1372 |
% \SpecialEnvIndex{vsmallmatrix*}\cs{begin}\arg{vsmallmatrix*}\oarg{col} |
| 1373 |
% \meta{contents} \cs{end}\arg{vsmallmatrix*}\\ |
| 1374 |
% \SpecialEnvIndex{Vsmallmatrix}\cs{begin}\arg{Vsmallmatrix} |
| 1375 |
% \meta{contents} \cs{end}\arg{Vsmallmatrix}\\ |
| 1376 |
% \SpecialEnvIndex{Vsmallmatrix*}\cs{begin}\arg{Vsmallmatrix*}\oarg{col} |
| 1377 |
% \meta{contents} \cs{end}\arg{Vsmallmatrix*}\\ |
| 1378 |
% \SpecialKeyIndex{smallmatrix-align}\makebox{$\key{smallmatrix-align}=\meta{c,l or r}$}\\ |
| 1379 |
% \SpecialKeyIndex{smallmatrix-inner-space}\makebox{$\key{smallmatrix-inner-space}=\cs{,}$} |
| 1380 |
% \end{codesyntax} |
| 1381 |
% \ProvidedBy{Rasmus Villemoes}{2011/01/17} |
| 1382 |
% \begin{verbatim} |
| 1383 |
% \[ |
| 1384 |
% \begin{bsmallmatrix} a & -b \\ -c & d \end{bsmallmatrix} |
| 1385 |
% \begin{bsmallmatrix*}[r] a & -b \\ -c & d \end{bsmallmatrix*} |
| 1386 |
% \] |
| 1387 |
% \end{verbatim} |
| 1388 |
% yields |
| 1389 |
% \[ |
| 1390 |
% \begin{bsmallmatrix} a & -b \\ -c & d \end{bsmallmatrix} |
| 1391 |
% \begin{bsmallmatrix*}[r] a & -b \\ -c & d \end{bsmallmatrix*} |
| 1392 |
% \] |
| 1393 |
% Inside the \verb?Xsmallmatrix? construction a small space is |
| 1394 |
% inserted between the fences and the contents, the size of it can be |
| 1395 |
% changed using \key{smallmatrix-inner-space}=\meta{some spacing command}, |
| 1396 |
% the default is \cs{,}. |
| 1397 |
% |
| 1398 |
% As an extra trick the fences will behave as open and closing fences |
| 1399 |
% despite their auto-scaling nature.\footnote{\cs{left} and |
| 1400 |
% \cs{right} creates an \emph{inner} construction, and not as one |
| 1401 |
% might expect something where a preceding \cs{sin} sees an opening |
| 1402 |
% fence, thus the space before or after may be too large. Inside this |
| 1403 |
% construction they behave.} |
| 1404 |
% |
| 1405 |
% |
| 1406 |
% \subsubsection{The \env{multlined} environment} |
| 1407 |
% |
| 1408 |
% \begin{codesyntax} |
| 1409 |
% \SpecialEnvIndex{multlined}\cs{begin}\arg{multlined}\oarg{pos}\oarg{width} |
| 1410 |
% \meta{contents} \cs{end}\arg{multlined}\\ |
| 1411 |
% \SpecialUsageIndex{\shoveleft}\cs{shoveleft}\oarg{dimen}\marg{arg}\texttt{~~} |
| 1412 |
% \SpecialUsageIndex{\shoveright}\cs{shoveright}\oarg{dimen}\marg{arg}\\ |
| 1413 |
% \makeatletter\settowidth\@tempdimc{\cs{shoveleft}\oarg{dimen}\marg{arg}}\global\@tempdimc\@tempdimc |
| 1414 |
% \SpecialKeyIndex{firstline-afterskip}\makebox[\@tempdimc][l]{$\key{firstline-afterskip}=\meta{dimen}$}\texttt{~~} |
| 1415 |
% \SpecialKeyIndex{lastline-preskip}$\key{lastline-preskip}=\meta{dimen}$\\ |
| 1416 |
% \makeatletter\SpecialKeyIndex{multlined-width}\makebox[\@tempdimc][l]{$\key{multlined-width}=\meta{dimen}$}\texttt{~~} |
| 1417 |
% \SpecialKeyIndex{multlined-pos}$\key{multlined-pos}=\texttt{c}\vert\texttt{b}\vert\texttt{t}$ |
| 1418 |
% \end{codesyntax} |
| 1419 |
% Some of the \pkg{amsmath} environments exist in two forms: an |
| 1420 |
% outer and an inner environment. One example is the pair |
| 1421 |
% \env{gather} \& \env{gathered}. There is one important omission on |
| 1422 |
% this list however, as there is no inner \env{multlined} |
| 1423 |
% environment, so this is where \pkg{mathtools} steps in. |
| 1424 |
% |
| 1425 |
% One might wonder what the sensible behavior should be. We want it |
| 1426 |
% to be an inner environment so that it is not wider than necessary, |
| 1427 |
% but on the other hand we would like to be able to control the |
| 1428 |
% width. The current implementation of \env{multlined} handles both |
| 1429 |
% cases. The idea is this: Set the first line flush left and add a |
| 1430 |
% hard space after it; this space is governed by the |
| 1431 |
% \key{firstline-afterskip} key. The last line should be set flush |
| 1432 |
% right and preceded by a hard space of size \key{lastline-preskip}. |
| 1433 |
% Both these hard spaces have a default value of \cs{multlinegap}. |
| 1434 |
% Here we use a `t' in the first optional argument denoting a |
| 1435 |
% top-aligned building block (the default is `c').\footnote{The helper macro |
| 1436 |
% \cs{Framebox}\marg{...} is equivalent to |
| 1437 |
% \cs{framebox}\marg{\cs{footnotesize}\cs{strut} ...}} |
| 1438 |
% \begin{verbatim} |
| 1439 |
% \[ |
| 1440 |
% A = \begin{multlined}[t] |
| 1441 |
% \Framebox[4cm]{first} \\ |
| 1442 |
% \Framebox[4cm]{last} |
| 1443 |
% \end{multlined} B |
| 1444 |
% \] |
| 1445 |
% \end{verbatim} |
| 1446 |
% \[ |
| 1447 |
% A = \begin{multlined}[t] |
| 1448 |
% \Framebox[4cm]{first} \\ |
| 1449 |
% \Framebox[4cm]{last} |
| 1450 |
% \end{multlined} B |
| 1451 |
% \] |
| 1452 |
% Note also that \env{multlined} gives you access to an extended |
| 1453 |
% syntax for \cs{shoveleft} and \cs{shoveright} as shown in the |
| 1454 |
% example below. |
| 1455 |
% \begin{verbatim} |
| 1456 |
% \[ |
| 1457 |
% \begin{multlined} |
| 1458 |
% \Framebox[.65\columnwidth]{First line} \\ |
| 1459 |
% \Framebox[.5\columnwidth]{Second line} \\ |
| 1460 |
% \shoveleft{L+E+F+T} \\ |
| 1461 |
% \shoveright{R+I+G+H+T} \\ |
| 1462 |
% \shoveleft[1cm]{L+E+F+T} \\ |
| 1463 |
% \shoveright[\widthof{$R+I+G+H+T$}]{R+I+G+H+T} \\ |
| 1464 |
% \Framebox[.65\columnwidth]{Last line} |
| 1465 |
% \end{multlined} |
| 1466 |
% \] |
| 1467 |
% \end{verbatim} |
| 1468 |
% \[ |
| 1469 |
% \begin{multlined} |
| 1470 |
% \Framebox[.65\columnwidth]{First line} \\ |
| 1471 |
% \Framebox[.5\columnwidth]{Second line} \\ |
| 1472 |
% \shoveleft{L+E+F+T} \\ |
| 1473 |
% \shoveright{R+I+G+H+T} \\ |
| 1474 |
% \shoveleft[1cm]{L+E+F+T} \\ |
| 1475 |
% \shoveright[\widthof{$R+I+G+H+T$}]{R+I+G+H+T} \\ |
| 1476 |
% \Framebox[.65\columnwidth]{Last line} |
| 1477 |
% \end{multlined} |
| 1478 |
% \] |
| 1479 |
% |
| 1480 |
% You can also choose the width yourself by specifying it as an |
| 1481 |
% optional argument: |
| 1482 |
% \begin{verbatim} |
| 1483 |
% \[ |
| 1484 |
% \begin{multlined}[b][7cm] |
| 1485 |
% \Framebox[4cm]{first} \\ |
| 1486 |
% \Framebox[4cm]{last} |
| 1487 |
% \end{multlined} = B |
| 1488 |
% \] |
| 1489 |
% \end{verbatim} |
| 1490 |
% \[ |
| 1491 |
% \begin{multlined}[b][7cm] |
| 1492 |
% \Framebox[4cm]{first} \\ |
| 1493 |
% \Framebox[4cm]{last} |
| 1494 |
% \end{multlined} = B |
| 1495 |
% \] |
| 1496 |
% There can be two optional arguments (position and width) and |
| 1497 |
% they're interchangeable. |
| 1498 |
% |
| 1499 |
% \medskip\noindent |
| 1500 |
% \textbf{Bug 1:} |
| 1501 |
% \CommentAdded{2014/05/11} |
| 1502 |
% If used inside an \env{array} or |
| 1503 |
% a derivative (say, a \env{matrix} variant), \env{multlined} does |
| 1504 |
% not work as expected. The implementation contains an `invisible' |
| 1505 |
% line after the first \env{multline} row, inside an \env{array} this |
| 1506 |
% line is no longer `invisible' because \env{array} sets |
| 1507 |
% \cs{baselineskip} to zero. We have no general workaround |
| 1508 |
% for this. |
| 1509 |
% |
| 1510 |
% \medskip\noindent |
| 1511 |
% \textbf{Bug 2:} |
| 1512 |
% \CommentAdded{2015/11/12} |
| 1513 |
% Due to the way \env{multlined} is implemented, certain |
| 1514 |
% constructions do not work inside \env{multlined}. We have added a |
| 1515 |
% hook (\cs{MultlinedHook}) that can be added to. The default value |
| 1516 |
% is a fix for \env{subarray} and \env{crampedsubarray} and thus for |
| 1517 |
% \cs{substack} and \cs{crampedsubstack} (and a few others, thus add |
| 1518 |
% to the hook, don't replace it). |
| 1519 |
% |
| 1520 |
% This can actually be used to fix Bug~1: |
| 1521 |
% \begin{verbatim} |
| 1522 |
% \usepackage{mathtools,etoolbox} |
| 1523 |
% \newlength\Normalbaselineskip |
| 1524 |
% \setlength\Normalbaselineskip{\baselineskip} |
| 1525 |
% \appto\MultlinedHook{ |
| 1526 |
% \setlength\baselineskip{\Normalbaselineskip} |
| 1527 |
% } |
| 1528 |
% \end{verbatim} |
| 1529 |
% |
| 1530 |
% \medskip\noindent |
| 1531 |
% \textbf{Caveat:} |
| 1532 |
% \CommentAdded{2017/05/22} |
| 1533 |
% \cs{shoveleft} and \cs{shoveright} does not work as expected if |
| 1534 |
% used as the last line in \env{multlined}. |
| 1535 |
% |
| 1536 |
% |
| 1537 |
% \subsubsection{More \env{cases}-like environments} |
| 1538 |
% |
| 1539 |
% \begin{codesyntax} |
| 1540 |
% \SpecialEnvIndex{dcases} |
| 1541 |
% \cs{begin}\arg{dcases}\texttt{~} \meta{math_column} |&| \meta{math_column} |
| 1542 |
% \cs{end}\arg{dcases}\\ |
| 1543 |
% \SpecialEnvIndex{dcases*} |
| 1544 |
% \cs{begin}\arg{dcases*} \meta{math_column} |&| \makebox[\widthof{\meta{math\_column}}][l]{\meta{text\_column}} |
| 1545 |
% \cs{end}\arg{dcases*}\\ |
| 1546 |
% \SpecialEnvIndex{rcases} |
| 1547 |
% \cs{begin}\arg{rcases}\texttt{~~} \meta{math_column} |&| \makebox[\widthof{\meta{math\_column}}][l]{\meta{math\_column}} |
| 1548 |
% \cs{end}\arg{rcases}\\ |
| 1549 |
% \SpecialEnvIndex{rcases*} |
| 1550 |
% \cs{begin}\arg{rcases*}\texttt{~} \meta{math_column} |&| \makebox[\widthof{\meta{math\_column}}][l]{\meta{text\_column}} |
| 1551 |
% \cs{end}\arg{rcases*}\\ |
| 1552 |
% \SpecialEnvIndex{drcases} |
| 1553 |
% \cs{begin}\arg{drcases}\texttt{~} \meta{math_column} |&| \makebox[\widthof{\meta{math\_column}}][l]{\meta{math\_column}} |
| 1554 |
% \cs{end}\arg{drcases}\\ |
| 1555 |
% \SpecialEnvIndex{drcases*} |
| 1556 |
% \cs{begin}\arg{drcases*} \meta{math_column} |&| \makebox[\widthof{\meta{math\_column}}][l]{\meta{text\_column}} |
| 1557 |
% \cs{end}\arg{drcases*}\\ |
| 1558 |
% \SpecialEnvIndex{cases*} |
| 1559 |
% \cs{begin}\arg{cases*}\texttt{~} \meta{math_column} |&| \makebox[\widthof{\meta{math\_column}}][l]{\meta{text\_column}} |
| 1560 |
% \cs{end}\arg{cases*} |
| 1561 |
% \end{codesyntax} |
| 1562 |
% \FeatureRequest{Lars Madsen}{2004/07/01} |
| 1563 |
% Anyone who has tried to use an integral in the regular |
| 1564 |
% \env{cases} environment from \pkg{amsmath} will have noticed that |
| 1565 |
% it is set as |
| 1566 |
% \[ |
| 1567 |
% a=\begin{cases} |
| 1568 |
% E = m c^2 & \text{Nothing to see here} \\ |
| 1569 |
% \int x-3\, dx & \text{Integral is text style} |
| 1570 |
% \end{cases} |
| 1571 |
% \] |
| 1572 |
% \pkg{mathtools} provides two environments similar to \env{cases}. |
| 1573 |
% Using the \env{dcases} environment you get the same output as with |
| 1574 |
% \env{cases} except that the rows are set in display style. |
| 1575 |
% \begin{verbatim} |
| 1576 |
% \[ |
| 1577 |
% \begin{dcases} |
| 1578 |
% E = m c^2 & c \approx 3.00\times 10^{8}\,\mathrm{m}/\mathrm{s} \\ |
| 1579 |
% \int x-3\, dx & \text{Integral is display style} |
| 1580 |
% \end{dcases} |
| 1581 |
% \] |
| 1582 |
% \end{verbatim} |
| 1583 |
% \[ |
| 1584 |
% \begin{dcases} |
| 1585 |
% E = m c^2 & c \approx 3.00\times 10^{8}\,\mathrm{m}/\mathrm{s} \\ |
| 1586 |
% \int x-3\, dx & \text{Integral is display style} |
| 1587 |
% \end{dcases} |
| 1588 |
% \] |
| 1589 |
% Additionally the environment \env{dcases*} acts just the same, but |
| 1590 |
% the second column is set in the normal roman font of the |
| 1591 |
% document.\footnote{Or rather: it inherits the font characteristics |
| 1592 |
% active just before the \env{dcases*} environment.} |
| 1593 |
% \begin{verbatim} |
| 1594 |
% \[ |
| 1595 |
% a= \begin{dcases*} |
| 1596 |
% E = m c^2 & Nothing to see here \\ |
| 1597 |
% \int x-3\, dx & Integral is display style |
| 1598 |
% \end{dcases*} |
| 1599 |
% \] |
| 1600 |
% \end{verbatim} |
| 1601 |
% \[ |
| 1602 |
% a= \begin{dcases*} |
| 1603 |
% E = m c^2 & Nothing to see here \\ |
| 1604 |
% \int x-3\, dx & Integral is display style |
| 1605 |
% \end{dcases*} |
| 1606 |
% \] |
| 1607 |
% The environments \env{rcases}, \env{rcases*}, \env{drcases} and |
| 1608 |
% \env{drcases*} are equivalent to \env{cases} and \env{dcases}, but |
| 1609 |
% here the brace is placed on the right instead of on the left. |
| 1610 |
% \begin{verbatim} |
| 1611 |
% \[ |
| 1612 |
% \begin{rcases*} |
| 1613 |
% x^2 & for $x>0$\\ |
| 1614 |
% x^3 & else |
| 1615 |
% \end{rcases*} \quad \Rightarrow \cdots |
| 1616 |
% \] |
| 1617 |
% \end{verbatim} |
| 1618 |
% \[ |
| 1619 |
% \begin{rcases*} |
| 1620 |
% x^2 & for $x>0$\\ |
| 1621 |
% x^3 & else |
| 1622 |
% \end{rcases*} \quad \Rightarrow\cdots |
| 1623 |
% \] |
| 1624 |
% |
| 1625 |
% |
| 1626 |
% \subsubsection{Emulating indented lines in alignments} |
| 1627 |
% \begin{codesyntax} |
| 1628 |
% \SpecialEnvIndex{\MoveEqLeft}\cs{MoveEqLeft}\oarg{number} |
| 1629 |
% \end{codesyntax} |
| 1630 |
% \ProvidedBy{Lars Madsen}{2008/06/05} In \cite{Swanson}, Ellen |
| 1631 |
% Swanson recommends that whenever one has a long displayed formula, |
| 1632 |
% spanning several lines, and it is unfeasible to align against a |
| 1633 |
% relation within the first line, then all lines in the display |
| 1634 |
% should be aligned at the left most edge of the first line, and all |
| 1635 |
% subsequent lines should be indented by 2\,em (or if needed by a |
| 1636 |
% smaller amount). That is we are talking about displays that end up |
| 1637 |
% looking like this\footnote{Maintainer (daleif)'s note: This is one |
| 1638 |
% of my most used constructions whenever I edit manuscripts. I'd |
| 1639 |
% rather use this than for example \env{multline} as I find it gives |
| 1640 |
% the text a more consistent look.} |
| 1641 |
% \begin{align*} |
| 1642 |
% \MoveEqLeft \Framebox[10cm][c]{Long first line}\\ |
| 1643 |
% & = \Framebox[6cm][c]{2nd line}\\ |
| 1644 |
% & \leq \dots |
| 1645 |
% \end{align*} |
| 1646 |
% Traditionally one could do this by starting subsequent lines by |
| 1647 |
% \verb+&\qquad ...+, but that is tedious. Instead the example above |
| 1648 |
% was made using \cs{MoveEqLeft}: |
| 1649 |
% \begin{verbatim} |
| 1650 |
% \begin{align*} |
| 1651 |
% \MoveEqLeft \Framebox[10cm][c]{Long first line}\\ |
| 1652 |
% & = \Framebox[6cm][c]{2nd line}\\ |
| 1653 |
% & \leq \dots |
| 1654 |
% \end{align*} |
| 1655 |
% \end{verbatim} |
| 1656 |
% \cs{MoveEqLeft} is placed instead of the \verb+&+ on the first |
| 1657 |
% line, and will effectively \emph{move} the entire first line |
| 1658 |
% \oarg{number} of ems to the left (default is 2). If you choose to |
| 1659 |
% align to the right of the relation, use \cs{MoveEqLeft}\verb+[3]+ |
| 1660 |
% to accommodate the extra distance to the alignment point: |
| 1661 |
% \begin{verbatim} |
| 1662 |
% \begin{align*} |
| 1663 |
% \MoveEqLeft[3] \Framebox[10cm][c]{Part 1}\\ |
| 1664 |
% = {} & \Framebox[8cm][c]{2nd line}\\ |
| 1665 |
% & + \Framebox[4cm][c]{last part} |
| 1666 |
% \end{align*} |
| 1667 |
% \end{verbatim} |
| 1668 |
% \begin{align*} |
| 1669 |
% \MoveEqLeft[3] \Framebox[10cm][c]{Long first line}\\ |
| 1670 |
% = {} & \Framebox[6cm][c]{2nd line}\\ |
| 1671 |
% & + \Framebox[4cm][c]{last part} |
| 1672 |
% \end{align*} |
| 1673 |
% |
| 1674 |
% |
| 1675 |
% \noindent\textbf{Caveat regarding \cs{MoveEqLeft}}: If the first |
| 1676 |
% part of the equation starts with say \verb|[a]|, \cs{MoveEqLeft} may |
| 1677 |
% attempt to eat it! You can prevent this by specifying the optional |
| 1678 |
% argument (remember the default is the same as \cs{MoveEqLeft[2]}) or |
| 1679 |
% by using \cs{MoveEqLeft\{\}}. |
| 1680 |
% |
| 1681 |
% \subsubsection{Boxing a single line in an alignment} |
| 1682 |
% |
| 1683 |
% The \texttt{amsmath} package provides the \cs{boxed} macro to box |
| 1684 |
% material in math mode. But this of course will not work if the box |
| 1685 |
% should cross an alignment point. We provide a macro that |
| 1686 |
% can.\footnote{Note that internally \cs{Aboxed} does use |
| 1687 |
% \cs{boxed}.} \hskip1sp \marginpar{% |
| 1688 |
% \parbox[b]{\marginparwidth}{\small\sffamily\raggedright |
| 1689 |
% \strut Evolved from a request by\\Merciadri Luca\\ |
| 1690 |
% 2010/06/28\\on comp.text.tex% |
| 1691 |
% }\strut |
| 1692 |
% }% |
| 1693 |
% \marginpar{\strut\\% |
| 1694 |
% \parbox[b]{\marginparwidth}{\small\sffamily\raggedright |
| 1695 |
% \strut Reimplemented by\\Florent Chervet (GL) \\ |
| 1696 |
% 2011/06/11\\on comp.text.tex% |
| 1697 |
% }\strut |
| 1698 |
% }% |
| 1699 |
% \begin{codesyntax} |
| 1700 |
% \SpecialEnvIndex{\Aboxed}\cs{Aboxed}\marg{left hand side |
| 1701 |
% \quad\texttt{\textnormal{\&}}\quad right hand side} |
| 1702 |
% \end{codesyntax} |
| 1703 |
% Example |
| 1704 |
% \begin{verbatim} |
| 1705 |
% \begin{align*} |
| 1706 |
% \Aboxed{ f(x) & = \int h(x)\, dx} \\ |
| 1707 |
% & = g(x) |
| 1708 |
% \end{align*} |
| 1709 |
% \end{verbatim} |
| 1710 |
% Resulting in: |
| 1711 |
% \begin{align*} |
| 1712 |
% \Aboxed{ f(x) & = \int h(x)\, dx} \\ |
| 1713 |
% & = g(x) |
| 1714 |
% \end{align*} |
| 1715 |
% One can have multiple boxes on each line, and the |
| 1716 |
% ``\texttt{\textnormal{\&}}\quad right hand side'' can even be |
| 1717 |
% missing. Here is an example of how the padding in the box can be changed. |
| 1718 |
% \begin{verbatim} |
| 1719 |
% \begin{align*} |
| 1720 |
% \setlength\fboxsep{1em} |
| 1721 |
% \Aboxed{ f(x) &= 0 } & \Aboxed{ g(x) &= b} \\ |
| 1722 |
% \Aboxed{ h(x) } & \Aboxed{ i(x) } |
| 1723 |
% \end{align*} |
| 1724 |
% \end{verbatim} |
| 1725 |
% \begin{align*} |
| 1726 |
% \setlength\fboxsep{1em} |
| 1727 |
% \Aboxed{ f(x) &= 0 } & \Aboxed{ g(x) &= b} \\ |
| 1728 |
% \Aboxed{ h(x) } & \Aboxed{ i(x) } |
| 1729 |
% \end{align*} |
| 1730 |
% Note how the \cs{fboxsep} change only affects the box coming |
| 1731 |
% immediately after it. |
| 1732 |
% |
| 1733 |
% \marginpar{\strut\\% |
| 1734 |
% \parbox[b]{\marginparwidth}{\small\sffamily\raggedright |
| 1735 |
% \strut Comment by Qrrbrbirlbel on \url{tex.stackexchange.com}, 2013/05/20. |
| 1736 |
% }\strut |
| 1737 |
% }% |
| 1738 |
% As \cs{Aboxed} looks for the alignment \texttt{\&} it may be |
| 1739 |
% necessary to \emph{hide} constructions like matrices that also make |
| 1740 |
% use of \texttt{\&}. Just add a set of braces around the construction |
| 1741 |
% you want to hide. |
| 1742 |
% |
| 1743 |
% \medskip\noindent\textbf{Tip:} At times users want a \cs{Aboxed} |
| 1744 |
% with a different type of box. To help we provide a \cs{Aboxed} builder: |
| 1745 |
% \begin{codesyntax} |
| 1746 |
% \SpecialUsageIndex{\MakeAboxedCommand}\cs{MakeAboxedCommand}\cs{Aboxedname}\cs{boxmacro} |
| 1747 |
% \end{codesyntax} |
| 1748 |
% where \cs{boxname} should be a macro taking a single argument. The |
| 1749 |
% normal \cs{Aboxed} is the same as |
| 1750 |
% \verb|\MakeAboxedCommand\Aboxed\fbox|. Thus you can do |
| 1751 |
% \newcommand\myboxA[1]{\fcolorbox{gray}{yellow}{#1}} |
| 1752 |
% \newcommand\myboxB[1]{{\fboxsep=5pt\fboxrule=2pt\fbox{#1}}} |
| 1753 |
% \MakeAboxedCommand\AboxedA\myboxA |
| 1754 |
% \MakeAboxedCommand\AboxedB\myboxB |
| 1755 |
% \begin{align*} |
| 1756 |
% \AboxedA{ f(x) &= x^2 } & \AboxedB{ f(x) &= x^2 } |
| 1757 |
% \end{align*} |
| 1758 |
% via |
| 1759 |
% \begin{verbatim} |
| 1760 |
% \newcommand\myboxA[1]{\fcolorbox{gray}{yellow}{#1}} |
| 1761 |
% \newcommand\myboxB[1]{{\fboxsep=5pt\fboxrule=2pt\fbox{#1}}} |
| 1762 |
% \MakeAboxedCommand\AboxedA\myboxA |
| 1763 |
% \MakeAboxedCommand\AboxedB\myboxB |
| 1764 |
% \begin{align*} |
| 1765 |
% \AboxedA{ f(x) &= x^2 } & \AboxedB{ f(x) &= x^2 } |
| 1766 |
% \end{align*} |
| 1767 |
% \end{verbatim} |
| 1768 |
% |
| 1769 |
% |
| 1770 |
% \subsubsection{Adding arrows between lines in an alignment} |
| 1771 |
% |
| 1772 |
% This first macro is a bit misleading, it is only intended to be |
| 1773 |
% used in combination with the \env{alignat(*)} environment. |
| 1774 |
% \begin{codesyntax} |
| 1775 |
% \SpecialEnvIndex{\ArrowBetweenLines}\cs{ArrowBetweenLines}\oarg{symbol}\\ |
| 1776 |
% \SpecialEnvIndex{\ArrowBetweenLines*}\cs{ArrowBetweenLines*}\oarg{symbol} |
| 1777 |
% \end{codesyntax} |
| 1778 |
% \hskip1sp |
| 1779 |
% \marginpar{% |
| 1780 |
% \parbox[b]{\marginparwidth}{\small\sffamily\raggedright |
| 1781 |
% \strut Evolved from a request by\\Christian |
| 1782 |
% Bohr-Halling\\2004/03/31\\on dk.edb.tekst% |
| 1783 |
% } |
| 1784 |
% }% |
| 1785 |
% To add, say $\Updownarrow$ between two lines in an alignment use |
| 1786 |
% \cs{ArrowBetweenLines} and the \env{alignat} environment (note the |
| 1787 |
% extra pair of \texttt{\&}'s in front): |
| 1788 |
% \begin{verbatim} |
| 1789 |
% \begin{alignat}{2} |
| 1790 |
% && \framebox[1.5cm]{} &= \framebox[3cm]{}\\ |
| 1791 |
% \ArrowBetweenLines % \Updownarrow is the default |
| 1792 |
% && \framebox[1.5cm]{} &= \framebox[2cm]{} |
| 1793 |
% \end{alignat} |
| 1794 |
% \end{verbatim} |
| 1795 |
% resulting in |
| 1796 |
% \begin{alignat}{2} |
| 1797 |
% && \framebox[1.5cm]{} &= \framebox[3cm]{}\\ |
| 1798 |
% \ArrowBetweenLines |
| 1799 |
% && \framebox[1.5cm]{} &= \framebox[2cm]{} |
| 1800 |
% \end{alignat} |
| 1801 |
% Note the use of \verb+&&+ starting each \emph{regular} line of |
| 1802 |
% math. For adding the arrow on the right, use |
| 1803 |
% \cs{ArrowBetweenLines*}\oarg{symbol}, and end each line of math |
| 1804 |
% with \verb+&&+. |
| 1805 |
% \begin{verbatim} |
| 1806 |
% \begin{alignat*}{2} |
| 1807 |
% \framebox[1.5cm]{} &= \framebox[3cm]{} &&\\ |
| 1808 |
% \ArrowBetweenLines*[\Downarrow] |
| 1809 |
% \framebox[1.5cm]{} &= \framebox[2cm]{} && |
| 1810 |
% \end{alignat*} |
| 1811 |
% \end{verbatim} |
| 1812 |
% resulting in |
| 1813 |
% \begin{alignat*}{2} |
| 1814 |
% \framebox[1.5cm]{} &= \framebox[3cm]{} &&\\ |
| 1815 |
% \ArrowBetweenLines*[\Downarrow] |
| 1816 |
% \framebox[1.5cm]{} &= \framebox[2cm]{} && |
| 1817 |
% \end{alignat*} |
| 1818 |
% |
| 1819 |
% |
| 1820 |
% \subsubsection{Centered \texorpdfstring{\cs{vdots}}{\textbackslash vdots}} |
| 1821 |
% |
| 1822 |
% If one wants to mark a vertical continuation, there is |
| 1823 |
% the \verb?\vdots? command, but combine this with an alignment and |
| 1824 |
% we get something rather suboptimal |
| 1825 |
% \FeatureRequest{Bruno Le Floch \\(and many others)}{2011/01/25} |
| 1826 |
% \begin{align*} |
| 1827 |
% \framebox[1.5cm]{} &= \framebox[3cm]{}\\ |
| 1828 |
% & \vdots\\ |
| 1829 |
% &= \framebox[3cm]{} |
| 1830 |
% \end{align*} |
| 1831 |
% It would be nice to have (1) a \verb?\vdots? centered within the |
| 1832 |
% width of another symbol, and (2) a construction similar to |
| 1833 |
% \verb?\ArrowBetweenLines? that does not take up so much space. |
| 1834 |
% We provide both. |
| 1835 |
% \begin{codesyntax} |
| 1836 |
% \SpecialUsageIndex{\vdotswithin}\cs{vdotswithin}\marg{symbol}\\ |
| 1837 |
% \SpecialUsageIndex{\shortvdotswithin}\cs{shortvdotswithin}\marg{symbol}\\ |
| 1838 |
% \SpecialUsageIndex{\shortvdotswithin*}\cs{shortvdotswithin*}\marg{symbol}\\ |
| 1839 |
% \SpecialUsageIndex{\MTFlushSpaceAbove}\cs{MTFlushSpaceAbove}\\ |
| 1840 |
% \SpecialUsageIndex{\MTFlushSpaceBelow}\cs{MTFlushSpaceBelow}\\ |
| 1841 |
% \SpecialKeyIndex{shortvdotsadjustabove}\makebox{$\key{shortvdotsadjustabove}=\meta{length}$}\\ |
| 1842 |
% \SpecialKeyIndex{shortvdotsadjustbelow}\makebox{$\key{shortvdotsadjustbelow}=\meta{length}$} |
| 1843 |
% \end{codesyntax} |
| 1844 |
% Two examples in one |
| 1845 |
% \begin{verbatim} |
| 1846 |
% \begin{align*} |
| 1847 |
% a &= b \\ |
| 1848 |
% & \vdotswithin{=} \\ |
| 1849 |
% & = c \\ |
| 1850 |
% \shortvdotswithin{=} |
| 1851 |
% & = d |
| 1852 |
% \end{align*} |
| 1853 |
% \end{verbatim} |
| 1854 |
% yielding |
| 1855 |
% \begin{align*} |
| 1856 |
% a &= b \\ |
| 1857 |
% & \vdotswithin{=} \\ |
| 1858 |
% & = c \\ |
| 1859 |
% \shortvdotswithin{=} |
| 1860 |
% & = d |
| 1861 |
% \end{align*} |
| 1862 |
% Thus \verb?\vdotswithin{=}? creates a box corresponding to |
| 1863 |
% \verb?{}={}? and typesets a ``$\vdots$'' centered inside it. When |
| 1864 |
% doing this as a normal line in an alignment leaves us with excessive |
| 1865 |
% space which \verb?\shortvdotswithin{=}? takes care with for us. |
| 1866 |
% |
| 1867 |
% The macro call \verb?\shortvdotswithin{=}? corresponds to |
| 1868 |
% \begin{verbatim} |
| 1869 |
% \MTFlushSpaceAbove |
| 1870 |
% & \vdotswithin{=} |
| 1871 |
% \MTFlushSpaceBelow |
| 1872 |
% \end{verbatim} |
| 1873 |
% whereas \verb?\shortvdotswithin*{=}? is the case with |
| 1874 |
% \begin{verbatim} |
| 1875 |
% \MTFlushSpaceAbove |
| 1876 |
% \vdotswithin{=} & |
| 1877 |
% \MTFlushSpaceBelow |
| 1878 |
% \end{verbatim} |
| 1879 |
% Note how \verb?\MTFlushSpaceBelow? implicitly adds a \verb?\\? at |
| 1880 |
% the end of the line. Thus one cannot have more on the line when |
| 1881 |
% using \verb?\shortvdotswithin? or the starred version. But, if |
| 1882 |
% needed, one can de-construct the macro and arrive at |
| 1883 |
% \begin{verbatim} |
| 1884 |
% \begin{alignat*}{3} |
| 1885 |
% A&+ B &&= C &&+ D \\ |
| 1886 |
% \MTFlushSpaceAbove |
| 1887 |
% &\vdotswithin{+} &&&& \vdotswithin{+} |
| 1888 |
% \MTFlushSpaceBelow |
| 1889 |
% C &+ D &&= Y &&+K |
| 1890 |
% \end{alignat*} |
| 1891 |
% \end{verbatim} |
| 1892 |
% yielding |
| 1893 |
% \begin{alignat*}{3} |
| 1894 |
% A&+ B &&= C &&+ D \\ |
| 1895 |
% \MTFlushSpaceAbove |
| 1896 |
% &\vdotswithin{+} &&&& \vdotswithin{+} |
| 1897 |
% \MTFlushSpaceBelow |
| 1898 |
% C &+ D &&= Y &&+K |
| 1899 |
% \end{alignat*} |
| 1900 |
% If one has the need for such a construction. |
| 1901 |
% |
| 1902 |
% The de-spaced version does support the \env{spreadlines} |
| 1903 |
% environment. The actual amount of space being \emph{flushed} above |
| 1904 |
% and below can be controlled by the user using the two options |
| 1905 |
% indicated. Their original values are \verb?2.15\origjot? and |
| 1906 |
% \verb?\origjot? respectively (\verb?\origjot? is usually 3pt). |
| 1907 |
% |
| 1908 |
% \subsection{Intertext and short intertext} |
| 1909 |
% |
| 1910 |
% |
| 1911 |
% \begin{codesyntax} |
| 1912 |
% \SpecialUsageIndex{\shortintertext}\cs{shortintertext}\marg{text} |
| 1913 |
% \end{codesyntax} |
| 1914 |
% \cttPosting{Gabriel Zachmann and Donald Arseneau}{2000/05/12--13} |
| 1915 |
% \pkg{amsmath} provides the command \cs{intertext} for interrupting |
| 1916 |
% a multiline display while still maintaining the alignment points. |
| 1917 |
% However the spacing often seems quite excessive as seen below. |
| 1918 |
% \begin{verbatim} |
| 1919 |
% \begin{align} |
| 1920 |
% a&=b \intertext{Some text} |
| 1921 |
% c&=d |
| 1922 |
% \end{align} |
| 1923 |
% \end{verbatim} |
| 1924 |
% \begin{align} |
| 1925 |
% a&=b \intertext{Some text} |
| 1926 |
% c&=d |
| 1927 |
% \end{align} |
| 1928 |
% |
| 1929 |
% Using the command \cs{shortintertext} alleviates this situation |
| 1930 |
% somewhat: |
| 1931 |
% \begin{verbatim} |
| 1932 |
% \begin{align} |
| 1933 |
% a&=b \shortintertext{Some text} |
| 1934 |
% c&=d |
| 1935 |
% \end{align} |
| 1936 |
% \end{verbatim} |
| 1937 |
% \begin{align} |
| 1938 |
% a&=b \shortintertext{Some text} |
| 1939 |
% c&=d |
| 1940 |
% \end{align} |
| 1941 |
% |
| 1942 |
% \noindent |
| 1943 |
% It turns out that both \cs{shortintertext} and the original |
| 1944 |
% \cs{intertext} from \pkg{amsmath} has a slight problem. If we use |
| 1945 |
% the \env{spreadlines} (see section~\ref{sec:spread}) to open up |
| 1946 |
% the equations in a multiline calculation, then this opening up |
| 1947 |
% value also applies to the spacing above and below the original |
| 1948 |
% \cs{shortintertext} and \cs{intertext}. \tsxPosting{Tobias Weh |
| 1949 |
% \\(referring to a suggestion by Chung-chieh Shan)}{2011/05/29} |
| 1950 |
% It can be illustrated using the following example, an interested |
| 1951 |
% reader can apply it with and without the original \cs{intertext} |
| 1952 |
% and \cs{shortintertext}. |
| 1953 |
% \begin{verbatim} |
| 1954 |
% % the original \intertext and \shortintertext |
| 1955 |
% \mathtoolsset{original-intertext,original-shortintertext} |
| 1956 |
% \newcommand\myline{\par\noindent\rule{\textwidth}{1mm}} |
| 1957 |
% \myline |
| 1958 |
% \begin{spreadlines}{1em} |
| 1959 |
% \begin{align*} |
| 1960 |
% AA\\ BB\\ \intertext{\myline} |
| 1961 |
% AA\\ BB\\ \shortintertext{\myline} |
| 1962 |
% AA\\ BB |
| 1963 |
% \end{align*} |
| 1964 |
% \end{spreadlines} |
| 1965 |
% \myline |
| 1966 |
% \end{verbatim} |
| 1967 |
% |
| 1968 |
% We now fix this internally for both \cs{intertext} and |
| 1969 |
% \cs{shortintertext}, plus we add the possibility to fine-tune |
| 1970 |
% spacing around these constructions. The original versions can be |
| 1971 |
% brought back using the \texttt{original-x} keys below. |
| 1972 |
% \begin{codesyntax} |
| 1973 |
% \SpecialUsageIndex{\intertext}\cs{intertext}\marg{text}\\ |
| 1974 |
% \SpecialUsageIndex{\shortintertext}\cs{shortintertext}\marg{text}\\ |
| 1975 |
% \SpecialKeyIndex{original-intertext}$\key{original-intertext}=\texttt{true}\vert\texttt{false}$ \quad(default: \texttt{false})\\ |
| 1976 |
% \SpecialKeyIndex{original-shortintertext}$\key{original-shortintertext}=\texttt{true}\vert\texttt{false}$ |
| 1977 |
% \quad(default: \texttt{false})\\ |
| 1978 |
% \SpecialKeyIndex{above-intertext-sep}$\key{above-intertext-sep}=\meta{dimen}$ \quad(default: 0pt)\\ |
| 1979 |
% \SpecialKeyIndex{below-intertext-sep}$\key{below-intertext-sep}=\meta{dimen}$ \quad(default: 0pt)\\ |
| 1980 |
% \SpecialKeyIndex{above-shortintertext-sep}$\key{above-shortintertext-sep}=\meta{dimen}$ \quad(default: 3pt)\\ |
| 1981 |
% \SpecialKeyIndex{below-shortintertext-sep}$\key{below-shortintertext-sep}=\meta{dimen}$ \quad(default: 3pt) |
| 1982 |
% \end{codesyntax} |
| 1983 |
% The updated \cs{shortintertext} will look like the original version |
| 1984 |
% unless for areas with an enlarged \cs{jot} value (see for example |
| 1985 |
% the \env{spreadlines}, section~\ref{sec:spread}). Whereas \cs{intertext} |
| 1986 |
% will have a slightly smaller value above and below (corresponding |
| 1987 |
% to about 3pt less space above and below), the spacing around |
| 1988 |
% \cs{intertext} should now match the normal spacing going into and |
| 1989 |
% out of an \env{align}. |
| 1990 |
% |
| 1991 |
% \textbf{Tip:} \cs{intertext} and \cs{shortintertext} also works |
| 1992 |
% within \env{gather}. |
| 1993 |
% |
| 1994 |
% |
| 1995 |
% \subsection{Paired delimiters} |
| 1996 |
% |
| 1997 |
% |
| 1998 |
% \begin{codesyntax} |
| 1999 |
% \SpecialUsageIndex{\DeclarePairedDelimiter} |
| 2000 |
% \cs{DeclarePairedDelimiter}\marg{cmd}\marg{left_delim}\marg{right_delim} |
| 2001 |
% \end{codesyntax} |
| 2002 |
% \FeatureRequest{Lars Madsen}{2004/06/25} |
| 2003 |
% In the \pkg{amsmath} documentation it is shown how to define a few |
| 2004 |
% commands for typesetting the absolute value and norm. These |
| 2005 |
% definitions are: |
| 2006 |
% \begin{verbatim} |
| 2007 |
% \newcommand*\abs[1]{\lvert#1\rvert} |
| 2008 |
% \newcommand*\norm[1]{\lVert#1\rVert} |
| 2009 |
% \end{verbatim} |
| 2010 |
% \DeclarePairedDelimiter\abs\lvert\rvert |
| 2011 |
% While they produce correct horizontal spacing you have to be |
| 2012 |
% careful about the vertical spacing if the argument is just a |
| 2013 |
% little taller than usual as in |
| 2014 |
% \[ |
| 2015 |
% \abs{\frac{a}{b}} |
| 2016 |
% \] |
| 2017 |
% Here it won't give a nice result, so you have to manually put in |
| 2018 |
% either a \cs{left}--\cs{right} pair or a \cs{bigl}--\cs{bigr} pair. |
| 2019 |
% Both methods mean that you have to delete your \cs{abs} command, |
| 2020 |
% which may not sound like an ideal solution. |
| 2021 |
% |
| 2022 |
% With the command \cs{DeclarePairedDelimiter} you can combine all |
| 2023 |
% these features in one easy to use command. Let's show an example: |
| 2024 |
% \begin{verbatim} |
| 2025 |
% \DeclarePairedDelimiter\abs{\lvert}{\rvert} |
| 2026 |
% \end{verbatim} |
| 2027 |
% This defines the command \cs{abs} just like in the |
| 2028 |
% \pkg{amsmath} documentation but with a few additions: |
| 2029 |
% \begin{itemize} |
| 2030 |
% \item A starred variant: \cs{abs*} produces delimiters that are preceded |
| 2031 |
% by \cs{left} and \cs{right} resp.: |
| 2032 |
% \begin{verbatim} |
| 2033 |
% \[ |
| 2034 |
% \abs*{\frac{a}{b}} |
| 2035 |
% \] |
| 2036 |
% \end{verbatim} |
| 2037 |
% \[ |
| 2038 |
% \abs*{\frac{a}{b}} |
| 2039 |
% \] |
| 2040 |
% \item A variant with an optional argument: |
| 2041 |
% \cs{abs}\oarg{size_cmd}, where |
| 2042 |
% \meta{size_cmd} is either \cs{big}, \cs{Big}, \cs{bigg}, or |
| 2043 |
% \cs{Bigg} (if you have any bigggger versions you can use them |
| 2044 |
% too). |
| 2045 |
% \begin{verbatim} |
| 2046 |
% \[ |
| 2047 |
% \abs[\Bigg]{\frac{a}{b}} |
| 2048 |
% \] |
| 2049 |
% \end{verbatim} |
| 2050 |
% \[ |
| 2051 |
% \abs[\Bigg]{\frac{a}{b}} |
| 2052 |
% \] |
| 2053 |
% \end{itemize} |
| 2054 |
% |
| 2055 |
% \paragraph{A note on the delimiters.} Whenever the manual scalings |
| 2056 |
% are used we internally convert them into their \cs{...l} and |
| 2057 |
% \cs{...r} variants. Therefore if you define your own manual |
| 2058 |
% scalers, remember to also have -l and -r variants. |
| 2059 |
% \\ |
| 2060 |
% \emph{New from version 1.30.} You can now use »\verb|.|« (dot) |
| 2061 |
% as an empty delimiter, for macros what only have a delimiter on one |
| 2062 |
% side.\footnote{The syntax is borrowed from |
| 2063 |
% \cs{left.}\cs{frac\{1\}\{2\}}\cs{right}\cs{rvert} where the dot marks an empty |
| 2064 |
% delimiter. } |
| 2065 |
% |
| 2066 |
% \begin{codesyntax} |
| 2067 |
% \SpecialUsageIndex{\DeclarePairedDelimiterX} |
| 2068 |
% \cs{DeclarePairedDelimiterX}\marg{cmd}\oarg{num args}\marg{left_delim}\marg{right_delim}\marg{body}\\ |
| 2069 |
% \cs{delimsize} |
| 2070 |
% \end{codesyntax} |
| 2071 |
% Sometimes one might want to have the capabilities of |
| 2072 |
% \cs{DeclarePairedDelimiter}, but also want a macro which takes more |
| 2073 |
% than one argument plus being able to specify the body of the |
| 2074 |
% generated macro. |
| 2075 |
% |
| 2076 |
% \cs{DeclarePairedDelimiterX} extends the features of |
| 2077 |
% \cs{DeclarePairedDelimiter} such that the user will get a macro |
| 2078 |
% which is fenced off at either end, plus the capability to provide |
| 2079 |
% the \meta{body} for whatever the macro should do within these |
| 2080 |
% fences. |
| 2081 |
% |
| 2082 |
% Inside the \meta{body} part, the macro \cs{delimsize} refers to the |
| 2083 |
% size of the outer fences. It can then be used inside \meta{body} to |
| 2084 |
% scale any inner fences. |
| 2085 |
% |
| 2086 |
% Thus |
| 2087 |
% \begin{quote} |
| 2088 |
% \cs{DeclarePairedDelimiter}\marg{cmd}\marg{left_delim}\marg{right_delim} |
| 2089 |
% \end{quote} |
| 2090 |
% is the same thing as |
| 2091 |
% \begin{quote} |
| 2092 |
% \cs{DeclarePairedDelimiterX}\marg{cmd}\texttt{[1]}\marg{left_delim}\marg{right_delim}\rlap{\texttt{\{\#1\}}} |
| 2093 |
% \end{quote} |
| 2094 |
% % |
| 2095 |
% Let us do some examples. First we want to prepare a macro for inner |
| 2096 |
% products, with two arguments such that we can hide the character |
| 2097 |
% separating the arguments (a~journal style might require a |
| 2098 |
% semi-colon, so we will save a lot of hand editing). This can be |
| 2099 |
% done via |
| 2100 |
% \begin{verbatim} |
| 2101 |
% \DeclarePairedDelimiterX\innerp[2]{\langle}{\rangle}{#1,#2} |
| 2102 |
% \end{verbatim} |
| 2103 |
% More interestingly we can refer to the size inside the |
| 2104 |
% \meta{code}. Here we do a weird three argument `braket' |
| 2105 |
% \begin{verbatim} |
| 2106 |
% \DeclarePairedDelimiterX\braket[3]{\langle}{\rangle}% |
| 2107 |
% {#1\,\delimsize\vert\,\mathopen{}#2\,\delimsize\vert\,\mathopen{}#3} |
| 2108 |
% \end{verbatim} |
| 2109 |
% \begin{itshape} |
| 2110 |
% Note the use of `\verb|\mathopen{}|' in the \meta{body} of |
| 2111 |
% \cs{braket}, this is very important when a scalable delimiter is |
| 2112 |
% being used and it does not present itself as a left or right |
| 2113 |
% delimiter. You will see why it is needed if you use |
| 2114 |
% \verb|\braket{A}{-B}{C}| in a version without |
| 2115 |
% \verb|\mathopen{}|.\footnote{Basically, the problem is that |
| 2116 |
% \cs{vert} is a `symbol', thus $\vert-B$ is interpreted |
| 2117 |
% \emph{subtraction}, not a symbol followed by negative $B$ (aka a |
| 2118 |
% sign). When \cs{mathopen\{\}} is added, \TeX\ is told that an |
| 2119 |
% opening delimiter just occurred, and it will adjust the minus |
| 2120 |
% accordingly.} |
| 2121 |
% \end{itshape} |
| 2122 |
% |
| 2123 |
% Then we get |
| 2124 |
% \DeclarePairedDelimiterX\innerp[2]{\langle}{\rangle}{#1,#2} |
| 2125 |
% \DeclarePairedDelimiterX\braket[3]{\langle}{\rangle}% |
| 2126 |
% {#1\,\delimsize\vert\,\mathopen{}#2\,\delimsize\vert\,\mathopen{}#3} |
| 2127 |
% \begin{verbatim} |
| 2128 |
% \[ |
| 2129 |
% \innerp*{A}{ \frac{1}{2} } \quad |
| 2130 |
% \braket[\Big]{B}{\sum_{k} f_k}{C} |
| 2131 |
% \] |
| 2132 |
% \end{verbatim} |
| 2133 |
% \[ |
| 2134 |
% \innerp*{A}{ \frac{1}{2} } \quad |
| 2135 |
% \braket[\Big]{B}{\sum_{k}}{C} |
| 2136 |
% \] |
| 2137 |
% |
| 2138 |
% |
| 2139 |
% \iffalse |
| 2140 |
% \bigskip |
| 2141 |
% |
| 2142 |
% \noindent |
| 2143 |
% \textbf{\textit{Side note:}} We have changed the internal code of |
| 2144 |
% \cs{DeclarePairedDelimiter} and \cs{DeclarePairedDelimiterX} such |
| 2145 |
% that the starred version does no longer give the odd spacings that |
| 2146 |
% \cs{left}\dots\cs{right} sometimes give. Compare this |
| 2147 |
% \begin{verbatim} |
| 2148 |
% \[ |
| 2149 |
% 2\innerp{A}{B} \quad 2\innerp*{A}{B} \quad 2\left\langle A,B \right\rangle |
| 2150 |
% \] |
| 2151 |
% \end{verbatim} |
| 2152 |
% \[ |
| 2153 |
% \sin\innerp{A}{B} \quad |
| 2154 |
% \sin\innerp*{A}{B} \quad |
| 2155 |
% \sin\left\langle A,B \right\rangle |
| 2156 |
% \] |
| 2157 |
% The spacing in the last one does not behave like other fences (this |
| 2158 |
% is a feature of the \cs{left}\dots\cs{right} construction). |
| 2159 |
% \fi |
| 2160 |
% |
| 2161 |
% With the inner scaling, we can provide macros whose syntax closely |
| 2162 |
% follows the mathematical meaning. Fx for building sets, try |
| 2163 |
% this\footnote{The reason for using a separate \cs{SetSymbol} macro |
| 2164 |
% has to do with complicated set definitions, where the condition |
| 2165 |
% spans several lines. In this case \cs{Set} cannot be used. Thus it |
| 2166 |
% is nice to be able to refer to the specific set building symbol we |
| 2167 |
% have decided to use in this document. Also remember to add |
| 2168 |
% \cs{allowbreak} \emph{before} the proceeding inserted space. Then |
| 2169 |
% that space will disappear when a line break occurs.} |
| 2170 |
% \begin{verbatim} |
| 2171 |
% % just to make sure it exists |
| 2172 |
% \providecommand\given{} |
| 2173 |
% % can be useful to refer to this outside \Set |
| 2174 |
% \newcommand\SetSymbol[1][]{% |
| 2175 |
% \nonscript\:#1\vert |
| 2176 |
% \allowbreak |
| 2177 |
% \nonscript\: |
| 2178 |
% \mathopen{}} |
| 2179 |
% \DeclarePairedDelimiterX\Set[1]\{\}{% |
| 2180 |
% \renewcommand\given{\SetSymbol[\delimsize]} |
| 2181 |
% #1 |
| 2182 |
% } |
| 2183 |
% \end{verbatim} |
| 2184 |
% \providecommand\given{} |
| 2185 |
% \newcommand\SetSymbol[1][]{\nonscript\:#1\vert\allowbreak\nonscript\:\mathopen{}} |
| 2186 |
% \DeclarePairedDelimiterX\Set[1]\{\}{% |
| 2187 |
% \renewcommand\given{\SetSymbol[\delimsize]} |
| 2188 |
% #1 |
| 2189 |
% } |
| 2190 |
% \begin{verbatim} |
| 2191 |
% \[ \Set*{ x \in X \given \frac{\sqrt{x}}{x^2+1} > 1 } \] |
| 2192 |
% \end{verbatim} |
| 2193 |
% \[ \Set*{ x \in X \given \frac{\sqrt{x}}{x^2+1} > 1 } \] |
| 2194 |
% Thus we end up with a syntax much closer to how we read this |
| 2195 |
% aloud. Also we hide the `given' symbol for easy |
| 2196 |
% replacement.\footnote{The \cs{nonscript} construction removes the |
| 2197 |
% \cs{:} in sub- and superscript, this might not always be |
| 2198 |
% preferable. You can use |
| 2199 |
% \cs{mathchoice\{}\cs{:\}\{}\cs{:\}\{}\cs{,\}\{}\cs{,\}} instead of \cs{nonscript}\cs{:}.} |
| 2200 |
% |
| 2201 |
% Combining with \pkg{etoolbox} it becomes easy to make a function |
| 2202 |
% that automatically provides a marker for a blank argument: |
| 2203 |
% \begin{verbatim} |
| 2204 |
% \usepackage{etoolbox} |
| 2205 |
% \DeclarePairedDelimiterX\norm[1]\lVert\rVert{ |
| 2206 |
% \ifblank{#1}{\:\cdot\:}{#1} |
| 2207 |
% } |
| 2208 |
% \end{verbatim} |
| 2209 |
% Then \verb|\norm{}| will give you $\lVert\:\cdot\:\rVert$ while |
| 2210 |
% \verb|\norm{a}| gives the expected $\lVert a \rVert$. |
| 2211 |
% |
| 2212 |
% \begin{codesyntax} |
| 2213 |
% \SpecialUsageIndex{\DeclarePairedDelimiterXPP} |
| 2214 |
% \cs{DeclarePairedDelimiterXPP}\marg{cmd}\oarg{num args}\marg{pre |
| 2215 |
% code}\marg{left_delim}\\% |
| 2216 |
% \marg{right_delim}\marg{post code}\marg{body} |
| 2217 |
% \end{codesyntax} |
| 2218 |
% \FeatureRequest{Barbara Beeton (on TSE)}{2013/10/07} |
| 2219 |
% \cs{DeclarePairedDelimiterX} has an annoying caveat: it is very hard |
| 2220 |
% to make a macro \verb|\lnorm{a}| that should result in $\lVert |
| 2221 |
% a\rVert_2$.\footnote{The added `\texttt{\_2}' is hard to get around |
| 2222 |
% the argument parsing.} |
| 2223 |
% |
| 2224 |
% As a consequence we provide |
| 2225 |
% \cs{DeclarePairedDelimiterXPP}.\footnote{Extended |
| 2226 |
% DeclarePairedDelimiter with Pre and Post code.} With the addition of |
| 2227 |
% the \marg{pre code} and \marg{post code} it is identical to |
| 2228 |
% \cs{DeclarePairedDelimiterX}. It should be interpreted as |
| 2229 |
% \begin{center} |
| 2230 |
% \marg{pre code} \marg{left_delim} \marg{right_delim} |
| 2231 |
% \marg{post code} \marg{body} |
| 2232 |
% \end{center} |
| 2233 |
% |
| 2234 |
% |
| 2235 |
% An $\mathcal{L}^2$ norm can now be defined as |
| 2236 |
% \begin{verbatim} |
| 2237 |
% \DeclarePairedDelimiterXPP\lnorm[1]{}\lVert\rVert{_2}{#1} |
| 2238 |
% \end{verbatim} |
| 2239 |
% A probability macro with build in support for conditionals |
| 2240 |
% (\cs{given} initialized as above) |
| 2241 |
% \begin{verbatim} |
| 2242 |
% \DeclarePairedDelimiterXPP\Prob[1]{\mathbb{P}}(){}{ |
| 2243 |
% \renewcommand\given{\nonscript\:\delimsize\vert\nonscript\:\mathopen{}} |
| 2244 |
% #1} |
| 2245 |
% \end{verbatim} |
| 2246 |
% Thus giving support for \verb|\Prob{A \given B}|. |
| 2247 |
% |
| 2248 |
% \medskip\noindent\textbf{Note 1:} As the number of arguments increases |
| 2249 |
% the \cs{DeclarePairedDelimiter...} macros become hard for users to |
| 2250 |
% understand. A key-value interface would be better. This is planed |
| 2251 |
% for a future release. In |
| 2252 |
% \url{http://tex.stackexchange.com/a/136767/3929} there is a |
| 2253 |
% suggested replacement for \cs{DeclarePairedDelimiter}, that greatly |
| 2254 |
% reduces the number of macros and provides a key-val |
| 2255 |
% interface. However, the code uses \pkg{xparse}, and if we want to use |
| 2256 |
% \pkg{xparse} for some of our macros, we might just as well rewrite |
| 2257 |
% the entire \pkg{mathtools} package in \pkg{expl3}. Also it is not |
| 2258 |
% obvious how to get \pkg{xparse} to support \verb|[3]| for the number |
| 2259 |
% of arguments. We will consider this for a future release. |
| 2260 |
% |
| 2261 |
% \medskip\noindent\textbf{Note 2:} If you want to define your own |
| 2262 |
% manual scaler macros, it is important that you besides \cs{foo} also |
| 2263 |
% define \cs{fool} and \cs{foor}. When a scaler is specified, in say |
| 2264 |
% \cs{abs[\cs{big}]}\marg{arg}, we actually use \cs{bigl} and |
| 2265 |
% \cs{bigr}. |
| 2266 |
% |
| 2267 |
% \medskip\noindent\textbf{Note 3:} In the unlikely event that you |
| 2268 |
% choose to use, say, \verb+\section{Foo $\norm[\big]{bar}$}+ you will |
| 2269 |
% get an error because \cs{big} is getting expanded too early. Sadly, |
| 2270 |
% due to how \cs{DeclarePairedDelimiter} is implemented one cannot use |
| 2271 |
% \verb|[\protect\big]|. At present (until \pkg{amsmath} makes |
| 2272 |
% \cs{big} and friends robust), the best |
| 2273 |
% solution\footnote{\protect\url{https://tex.stackexchange.com/a/639238/3929}} |
| 2274 |
% is to load the \pkg{etoolbox} package and add \verb|\robustify\big| |
| 2275 |
% and similar to your preamble. |
| 2276 |
% |
| 2277 |
% \subsubsection{Expert use} |
| 2278 |
% |
| 2279 |
% Within the starred version of \cs{DeclarePairedDelimiter} and |
| 2280 |
% \cs{DeclarePairedDelimiterX} we make a few changes such that the |
| 2281 |
% auto scaled \cs{left} and \cs{right} fences behave as opening and |
| 2282 |
% closing fences, i.e.\ $\sin(x)$ vs. $\sin\left(x\right)$ (the later |
| 2283 |
% made via \verb|$\sin\left(x\right)$|), notice the gap between |
| 2284 |
% `$\sin$' and `('. In some special cases it may be useful to be |
| 2285 |
% able to tinker with the behavior. |
| 2286 |
% \begin{codesyntax} |
| 2287 |
% \SpecialUsageIndex{\reDeclarePairedDelimiterInnerWrapper} |
| 2288 |
% \cs{reDeclarePairedDelimiterInnerWrapper}\marg{macro name}\%\\ |
| 2289 |
% \qquad \marg{\textnormal{\texttt{star}} or \textnormal{\texttt{nostarnonscaled}} or \textnormal{\texttt{nostarscaled}}}\marg{code} |
| 2290 |
% \end{codesyntax} |
| 2291 |
% Internally several macros are created, including three call backs |
| 2292 |
% that take care of the formatting. There is one internal macro for |
| 2293 |
% the starred version, labeled \texttt{star}, the other two are |
| 2294 |
% labeled \texttt{nostarnonscaled} and \texttt{nostarscaled}. Within |
| 2295 |
% \meta{code}, \texttt{\#1} will be replaced by the (scaled) left |
| 2296 |
% fence, \texttt{\#3} the corresponding (scaled) right fence, and |
| 2297 |
% \texttt{\#2} the stuff in between. For example, here is how one |
| 2298 |
% might turn the content into \cs{mathinner}: |
| 2299 |
% \begin{verbatim} |
| 2300 |
% \DeclarePairedDelimiter\abs\lvert\rvert |
| 2301 |
% \reDeclarePairedDelimiterInnerWrapper\abs{star}{#1#2#3} |
| 2302 |
% \reDeclarePairedDelimiterInnerWrapper\abs{nostarnonscaled}{\mathinner{#1#2#3}} |
| 2303 |
% \reDeclarePairedDelimiterInnerWrapper\abs{nostarscaled}{\mathinner{#1#2#3}} |
| 2304 |
% \end{verbatim} |
| 2305 |
% The default values for the call backs correspond to |
| 2306 |
% \begin{verbatim} |
| 2307 |
% star: \mathopen{}\mathclose\bgroup #1#2\aftergroup\egroup #3 |
| 2308 |
% nostarnonscaled: \ifx.#1\else\mathopen#1\fi#2\ifx.#3\else\mathclose#3\fi |
| 2309 |
% nostarscaled: \mathopen{#1}#2\mathclose{#3} |
| 2310 |
% \end{verbatim} |
| 2311 |
% The two \texttt{nostar...} versions look the same, but they are |
| 2312 |
% not. In most (math) fonts, the first item in this list will be |
| 2313 |
% different from the rest (the superscript sits |
| 2314 |
% higher).\footnote{Interestingly it did not show up in the font of |
| 2315 |
% this manual, which uses the \pkg{fourier} font set.} |
| 2316 |
% \begin{verbatim} |
| 2317 |
% \mathclose{\rvert}^2\mathclose\rvert^2\rvert^2 |
| 2318 |
% \end{verbatim} |
| 2319 |
% |
| 2320 |
% |
| 2321 |
% \bigskip\noindent \textbf{Breaking change:} Prior to May 2017, we |
| 2322 |
% used two wrappers, the other named \texttt{nostar}. As of May 2017 |
| 2323 |
% \texttt{nostar} has been split into \texttt{nostarnonscaled} and |
| 2324 |
% \texttt{nostarscaled} and \texttt{nostar} alone is no longer |
| 2325 |
% supported (will give an error). |
| 2326 |
% |
| 2327 |
% \bigskip\noindent \textbf{Note:} Since we are using macros to add |
| 2328 |
% the \verb|\left...\right| constructions around some body, it |
| 2329 |
% \emph{is} (in principle) possible to make such a construction |
| 2330 |
% breakable across lines, even breakable within an \env{align} |
| 2331 |
% construction. Currently, this can only be applied to macros made |
| 2332 |
% using \cs{DeclarePairedDelimiter} and \emph{not} macros made using |
| 2333 |
% \cs{DeclarePairedDelimiterX} or \cs{DeclarePairedDelimiterXPP} as |
| 2334 |
% the contents are typeset inside a group (to limit \cs{delimsize}) |
| 2335 |
% and thus hide any \verb|&| or \verb|\\| from \env{align} and |
| 2336 |
% \env{align} breaks down. |
| 2337 |
% |
| 2338 |
% When \cs{DeclarePairedDelimiter} is used, Sebastien Gouezel has |
| 2339 |
% provided the following example \ProvidedBy{Sebastien |
| 2340 |
% Gouezel}{2014/05/14} |
| 2341 |
% \begin{verbatim} |
| 2342 |
% \newcommand\MTkillspecial[1]{% helper macro |
| 2343 |
% \bgroup |
| 2344 |
% \catcode`\&=9 |
| 2345 |
% \let\\\relax% |
| 2346 |
% \scantokens{#1}% |
| 2347 |
% \egroup |
| 2348 |
% } |
| 2349 |
% \DeclarePairedDelimiter\abs\lvert\rvert |
| 2350 |
% \reDeclarePairedDelimiterInnerWrapper\abs{star}{ |
| 2351 |
% \mathopen{#1\vphantom{\MTkillspecial{#2}}\kern-\nulldelimiterspace\right.} |
| 2352 |
% #2 |
| 2353 |
% \mathclose{\left.\kern-\nulldelimiterspace\vphantom{\MTkillspecial{#2}}#3}} |
| 2354 |
% \end{verbatim} |
| 2355 |
% Then this example works just fine: |
| 2356 |
% \begin{verbatim} |
| 2357 |
% \begin{align*} |
| 2358 |
% f(a) &= |
| 2359 |
% \!\begin{aligned}[t] |
| 2360 |
% \abs*{ & \frac{1}{2}+\cdots \\ |
| 2361 |
% & \dots+\frac{1}{2} } |
| 2362 |
% \end{aligned} |
| 2363 |
% \end{align*} |
| 2364 |
% \end{verbatim} |
| 2365 |
% \newcommand\MTkillspecial[1]{% helper macro |
| 2366 |
% \bgroup |
| 2367 |
% \catcode`\&=9 |
| 2368 |
% \let\\\relax% |
| 2369 |
% \scantokens{#1}% |
| 2370 |
% \egroup |
| 2371 |
% } |
| 2372 |
% \let\abs\relax |
| 2373 |
% \MHInternalSyntaxOn |
| 2374 |
% \MH_let:NwN\MT_delim_abs_nostar:\relax |
| 2375 |
% \MHInternalSyntaxOff |
| 2376 |
% \DeclarePairedDelimiter\abs\lvert\rvert |
| 2377 |
% \reDeclarePairedDelimiterInnerWrapper\abs{star}{ |
| 2378 |
% \mathopen{#1\vphantom{\MTkillspecial{#2}}\kern-\nulldelimiterspace\right.} |
| 2379 |
% #2 |
| 2380 |
% \mathclose{\left.\kern-\nulldelimiterspace\vphantom{\MTkillspecial{#2}}#3}} |
| 2381 |
% \begin{align*} |
| 2382 |
% f(a) &= |
| 2383 |
% \!\begin{aligned}[t] |
| 2384 |
% \abs*{&\frac{1}{2}+\cdots \\ |
| 2385 |
% &\dots+\frac{1}{2}} |
| 2386 |
% \end{aligned} |
| 2387 |
% \end{align*} |
| 2388 |
% |
| 2389 |
% |
| 2390 |
% \subsection{Special symbols} |
| 2391 |
% |
| 2392 |
% This part of the manual is about special symbols. So far only one |
| 2393 |
% technique is covered, but more will come. |
| 2394 |
% |
| 2395 |
% \subsubsection{Left and right parentheses} |
| 2396 |
% |
| 2397 |
% \begin{codesyntax} |
| 2398 |
% \SpecialUsageIndex{\lparen}\cs{lparen}\texttt{~~} |
| 2399 |
% \SpecialUsageIndex{\rparen}\cs{rparen} |
| 2400 |
% \end{codesyntax} |
| 2401 |
% When you want a big parenthesis or bracket in a math display you |
| 2402 |
% usually just type |
| 2403 |
% \begin{quote} |
| 2404 |
% |\left( ... \right)|\quad or\quad |\left[ ... \right]| |
| 2405 |
% \end{quote} |
| 2406 |
% \LaTeX{} also defines the macro names \cs{lbrack} and \cs{rbrack} |
| 2407 |
% to be shorthands for the left and right square bracket resp., but |
| 2408 |
% doesn't provide similar definitions for the parentheses. Some |
| 2409 |
% packages need command names to work with\footnote{The \pkg{empheq} |
| 2410 |
% package needs command names for delimiters in order to make |
| 2411 |
% auto-scaling versions.} so \pkg{mathtools} defines the commands |
| 2412 |
% \cs{lparen} and \cs{rparen} to represent the left and right |
| 2413 |
% parenthesis resp. |
| 2414 |
% |
| 2415 |
% |
| 2416 |
% \subsubsection{Vertically centered colon} |
| 2417 |
% |
| 2418 |
% \begin{codesyntax} |
| 2419 |
% \SpecialKeyIndex{centercolon}$\key{centercolon}=\texttt{true}\vert\texttt{false}$\\ |
| 2420 |
% \SpecialUsageIndex{\vcentcolon}\cs{vcentcolon}\texttt{~~} |
| 2421 |
% \SpecialUsageIndex{\ordinarycolon}\cs{ordinarycolon} |
| 2422 |
% \end{codesyntax} |
| 2423 |
% \cttPosting{Donald Arseneau}{2000/12/07} |
| 2424 |
% When trying to show assignment operations as in $ a := b $, one |
| 2425 |
% quickly notices that the colon is not centered on the math axis as |
| 2426 |
% the equal sign, leading to an odd-looking output. The command |
| 2427 |
% \cs{vcentcolon} is a shorthand for such a vertically centered |
| 2428 |
% colon, and can be used as in |$a \vcentcolon= b$| and results in |
| 2429 |
% the desired output: $a \vcentcolon= b$. |
| 2430 |
% See also the \pkg{colonequals} package. |
| 2431 |
% |
| 2432 |
% Typing \cs{vcentcolon} every time is quite tedious, so one can use |
| 2433 |
% the key \key{centercolon} to make the colon active instead. |
| 2434 |
% \begin{verbatim} |
| 2435 |
% \mathtoolsset{centercolon} |
| 2436 |
% \[ |
| 2437 |
% a := b |
| 2438 |
% \] |
| 2439 |
% \mathtoolsset{centercolon=false} |
| 2440 |
% \end{verbatim} |
| 2441 |
% \[\mathtoolsset{centercolon} |
| 2442 |
% a := b |
| 2443 |
% \] |
| 2444 |
% In this case the command \cs{ordinarycolon} typesets an~\ldots\ |
| 2445 |
% ordinary colon (what a surprise). |
| 2446 |
% |
| 2447 |
% \medskip |
| 2448 |
% \noindent\textbf{Warning:} \texttt{centercolon} \emph{does not} |
| 2449 |
% work with languages that make use of an active colon, most notably |
| 2450 |
% \emph{French}. Sadly the \texttt{babel} package does not distinguish |
| 2451 |
% between text and math when it comes to active characters. Nor does |
| 2452 |
% it provide any hooks to deal with math. So currently no general |
| 2453 |
% solution exists for this problem. |
| 2454 |
% |
| 2455 |
% \subsubsection{Some extra symbols involving vertically centered colon} |
| 2456 |
% |
| 2457 |
% Inspired by the \pkg{txfonts} and \pkg{pxfonts} we provide some colon+symbol combinations such that they will be |
| 2458 |
% available even when current font does not provide the combined symbol. |
| 2459 |
% |
| 2460 |
% \medskip\noindent \textbf{Breaking change Summer 2022:} As is listed in the manual for |
| 2461 |
% \pkg{newtxmath}/\pkg{newpxmath}\footnote{These superceeds \pkg{txfonts} and \pkg{pxfonts}.}, the symbols |
| 2462 |
% \cmd{\coloneq}/\cmd{\Coloneq} and \cmd{\eqcolon}/\cmd{\Eqcolon} in \pkg{txfonts}/\pkg{pxfonts} generated the wrong |
| 2463 |
% symbols, or at least was not consistent with the naming converntion by other packages. This has now also been |
| 2464 |
% fixed in \pkg{mathtools}, giving us the following colon symbol list: |
| 2465 |
% |
| 2466 |
% \begin{center} |
| 2467 |
% \small\label{colonsymbols} |
| 2468 |
% \newcommand\SSS[1]{\SpecialUsageIndex{#1}\texttt{\detokenize{#1}}&$#1$} |
| 2469 |
% \fbox{\begin{tabular}{*{8}{l} } |
| 2470 |
% \SSS{\dblcolon} \\ |
| 2471 |
% \SSS{\coloneq} & \SSS{\Coloneq} & \SSS{\eqcolon} & \SSS{\Eqcolon} |
| 2472 |
% \\ |
| 2473 |
% \SSS{\colonapprox} & \SSS{\Colonapprox} & \SSS{\colonsim} & \SSS{\Colonsim} |
| 2474 |
% \\ |
| 2475 |
% \noalign{\smallskip} |
| 2476 |
% \multicolumn{8}{l}{\itshape Legacy duplicate names:} \\ |
| 2477 |
% \noalign{\smallskip} |
| 2478 |
% \SSS{\coloneqq} & \SSS{\eqqcolon} & \SSS{\Coloneqq} & \SSS{\Eqqcolon} \\ |
| 2479 |
% \noalign{\smallskip} |
| 2480 |
% \multicolumn{8}{l}{\itshape Extra symbols added Summer 2022:} \\ |
| 2481 |
% \noalign{\smallskip} |
| 2482 |
% \SSS{\approxcolon} & \SSS{\Approxcolon} & \SSS{\simcolon} & \SSS{\Simcolon} \\ |
| 2483 |
% \SSS{\colondash} & \SSS{\Colondash} & \SSS{\dashcolon} & \SSS{\Dashcolon} \\ |
| 2484 |
% \end{tabular}} |
| 2485 |
% \end{center} |
| 2486 |
% |
| 2487 |
% \medskip\noindent If for some reason you need to revert to original (pre summer 2022) colon symbol names, use the |
| 2488 |
% \opt{legacycolonsymbols} package option. In which case the macro names maps to: |
| 2489 |
% |
| 2490 |
% \begin{center} |
| 2491 |
% \small\label{colonsymbols-legacy} |
| 2492 |
% \makeatletter |
| 2493 |
% \newcommand\SSS[2]{\SpecialUsageIndex{#1}\texttt{\detokenize{#1}}&$\@nameuse{#2}$} |
| 2494 |
% \makeatother |
| 2495 |
% \fbox{\begin{tabular}{*{8}{l}} |
| 2496 |
% \SSS{\coloneqq}{MATHT@coloneq} & \SSS{\Coloneqq}{MATHT@dblcoloneq} |
| 2497 |
% & \SSS{\coloneq}{MATHT@colondash} & \SSS{Coloneq}{MATHT@dblcolondash} \\ |
| 2498 |
% \SSS{\eqqcolon}{MATHT@eqcolon} & \SSS{\Eqqcolon}{MATHT@eqdblcolon} |
| 2499 |
% & \SSS{\eqcolon}{MATHT@dashcolon} & \SSS{\Eqcolon}{MATHT@dashdblcolon} \\ |
| 2500 |
% \SSS{\colonapprox}{MATHT@colonapprox} & \SSS{\Colonapprox}{MATHT@dblcolonapprox} |
| 2501 |
% & \SSS{\colonsim}{MATHT@colonsim} & \SSS{\Colonsim}{MATHT@dblcolonsim} \\ |
| 2502 |
% \SSS{\dblcolon}{MATHT@dblcolon}\\ |
| 2503 |
% \noalign{\smallskip} |
| 2504 |
% \multicolumn{8}{l}{\itshape Extra symbols added Summer 2022:} \\ |
| 2505 |
% \noalign{\smallskip} |
| 2506 |
% \SSS{\approxcolon}{MATHT@approxcolon} & \SSS{\Approxcolon}{MATHT@approxdblcolon} |
| 2507 |
% & \SSS{\simcolon}{MATHT@simcolon} & \SSS{\Simcolon}{MATHT@simdblcolon} \\ |
| 2508 |
% \SSS{\colondash}{MATHT@colondash} & \SSS{\Colondash}{MATHT@dblcolondash} |
| 2509 |
% & \SSS{\dashcolon}{MATHT@dashcolon} & \SSS{\Dashcolon}{MATHT@dashdblcolon} |
| 2510 |
% \end{tabular}}\par\smallskip |
| 2511 |
% Colon symbol names with \opt{legacycolonsymbols} package option. |
| 2512 |
% \end{center} |
| 2513 |
% |
| 2514 |
% \medskip\noindent Note that the symbol names are added at the start of the document via the \cs{provide...} mechanism, |
| 2515 |
% thus if some font package provide a symbol of the same macro name, we do nothing. |
| 2516 |
% |
| 2517 |
% |
| 2518 |
% |
| 2519 |
% \subsubsection{A few additional symbols} |
| 2520 |
% |
| 2521 |
% Most provided math font sets are missing the symbols \cs{nuparrow} |
| 2522 |
% and \cs{ndownarrow} (i.e.\ negated up- and downarrow) plus a `big' |
| 2523 |
% version of \cs{times}. Therefore we will provide constructed |
| 2524 |
% versions of these whenever they are not already available. |
| 2525 |
% \begin{codesyntax} |
| 2526 |
% \SpecialUsageIndex{\nuparrow}\cs{nuparrow}\\ |
| 2527 |
% \SpecialUsageIndex{\ndownarrow}\cs{ndownarrow}\\ |
| 2528 |
% \SpecialUsageIndex{\bigtimes}\cs{bigtimes} |
| 2529 |
% \end{codesyntax} |
| 2530 |
% |
| 2531 |
% \noindent |
| 2532 |
% \textbf{Note:} These symbols are constructed via |
| 2533 |
% features from the \pkg{graphicx} package, and thus may not display |
| 2534 |
% correctly in most DVI previewers. Also note that \cs{nuparrow} and |
| 2535 |
% \cs{ndownarrow} are constructed via \cs{nrightarrow} and |
| 2536 |
% \cs{nleftarrrow} respectively, so these need to be |
| 2537 |
% present. Usually this is done via \pkg{amssymb}, but some packages |
| 2538 |
% may be incompatible with \pkg{amssymb} so the user will have to |
| 2539 |
% load \pkg{amssymb} or a similar package, that provides |
| 2540 |
% \cs{nrightarrow} and \cs{nleftarrow}, themselves. |
| 2541 |
% |
| 2542 |
% With those requirements in place, we have |
| 2543 |
% \begin{verbatim} |
| 2544 |
% \[ |
| 2545 |
% \lim_{a\ndownarrow 0} f(a) \neq \bigtimes_n X_n \qquad |
| 2546 |
% \frac{ \bigtimes_{k=1}^7 B_k \nuparrow \Omega }{2} |
| 2547 |
% \] |
| 2548 |
% \end{verbatim} |
| 2549 |
% \[ |
| 2550 |
% \lim_{a\ndownarrow 0} f(a) \neq \bigtimes_n X_n \qquad |
| 2551 |
% \frac{ \bigtimes_{k=1}^7 B_k \nuparrow \Omega }{2} |
| 2552 |
% \] |
| 2553 |
% |
| 2554 |
% |
| 2555 |
% |
| 2556 |
% |
| 2557 |
% \section{A tribute to Michael J.~Downes} |
| 2558 |
% |
| 2559 |
% Michael J.~Downes (1958--2003) was one of the major architects |
| 2560 |
% behind \pkg{amsmath} and member of the \LaTeX{} Team. He made many |
| 2561 |
% great contributions to the \TeX{} community; not only by the means |
| 2562 |
% of widely spread macro packages such as \pkg{amsmath} but also in |
| 2563 |
% the form of actively giving advice on newsgroups. Some of |
| 2564 |
% Michael's macro solutions on the newsgroups never made it into |
| 2565 |
% publicly available macro packages although they certainly deserved |
| 2566 |
% it, so \pkg{mathtools} tries to rectify this matter. The macros |
| 2567 |
% described in this section are either straight copies or heavily |
| 2568 |
% inspired by his original postings. |
| 2569 |
% |
| 2570 |
% \subsection{Mathematics within italic text} |
| 2571 |
% |
| 2572 |
% \begin{codesyntax} |
| 2573 |
% \SpecialKeyIndex{mathic}$\key{mathic}=\texttt{true}\vert\texttt{false}$ |
| 2574 |
% \end{codesyntax} |
| 2575 |
% \cttPosting{Michael J.~Downes}{1998/05/14} |
| 2576 |
% \TeX{} usually takes care of italic corrections in text, but fails |
| 2577 |
% when it comes to math. If you use the \LaTeX{} inline math |
| 2578 |
% commands \cs{(} and \cs{)} you can however work around it by |
| 2579 |
% setting the key \key{mathic} to true as shown below. |
| 2580 |
% \begin{verbatim} |
| 2581 |
% \begin{quote}\itshape |
| 2582 |
% Compare these lines: \par |
| 2583 |
% \mathtoolsset{mathic} % or \mathtoolsset{mathic=true} |
| 2584 |
% Subset of \(V\) and subset of \(A\). \par |
| 2585 |
% \mathtoolsset{mathic=false} |
| 2586 |
% Subset of \(V\) and subset of \(A\). |
| 2587 |
% \par |
| 2588 |
% \end{quote} |
| 2589 |
% \end{verbatim} |
| 2590 |
% \begin{quote}\itshape |
| 2591 |
% Compare these lines: \par |
| 2592 |
% \mathtoolsset{mathic} |
| 2593 |
% Subset of \(V\) and subset of \(A\). \par |
| 2594 |
% \mathtoolsset{mathic=false} |
| 2595 |
% Subset of \(V\) and subset of \(A\). |
| 2596 |
% \par |
| 2597 |
% \end{quote} |
| 2598 |
% \noindent |
| 2599 |
% As of 2013, \cs(\cs) are robust, as are the italic corrected versions. |
| 2600 |
% |
| 2601 |
% \medskip\noindent \textbf{Caveat:} Italic correction is a |
| 2602 |
% treacherous area. For example any penalties will cancel the italic |
| 2603 |
% correction inserted by |
| 2604 |
% \verb|\(| (for an explanation see \cite{TBT}, section 4.3.3). We |
| 2605 |
% have changed Michael's original to accommodate one specific penalty |
| 2606 |
% construction: the \emph{tie}, i.e., |
| 2607 |
% `\verb|text~\(|' will work as expected (as~of July, 2014). |
| 2608 |
% |
| 2609 |
% \subsection{Left sub/superscripts} |
| 2610 |
% |
| 2611 |
% \begin{codesyntax} |
| 2612 |
% \SpecialUsageIndex{\prescript} |
| 2613 |
% \cs{prescript}\marg{sup}\marg{sub}\marg{arg}\texttt{~~} |
| 2614 |
% \SpecialKeyIndex{prescript-sup-format} |
| 2615 |
% $\key{prescript-sup-format}=\meta{cmd}$\\ |
| 2616 |
% \SpecialKeyIndex{prescript-sub-format} |
| 2617 |
% $\key{prescript-sub-format}=\meta{cmd}$\hfill |
| 2618 |
% \SpecialKeyIndex{prescript-arg-format} |
| 2619 |
% \rlap{$\key{prescript-arg-format}=\meta{cmd}$}^^A |
| 2620 |
% \phantom{$\key{prescript-sup-format}=\meta{cmd}$} |
| 2621 |
% \end{codesyntax} |
| 2622 |
% \cttPosting{Michael J.~Downes}{2000/12/20} |
| 2623 |
% Sometimes one wants to put a sub- or superscript on the left of |
| 2624 |
% the argument. The \cs{prescript} command does just that: |
| 2625 |
% \begin{verbatim} |
| 2626 |
% \[ |
| 2627 |
% {}^{4}_{12}\mathbf{C}^{5+}_{2} \quad |
| 2628 |
% \prescript{14}{2}{\mathbf{C}}^{5+}_{2} \quad |
| 2629 |
% \prescript{4}{12}{\mathbf{C}}^{5+}_{2} \quad |
| 2630 |
% \prescript{14}{}{\mathbf{C}}^{5+}_{2} \quad |
| 2631 |
% \prescript{}{2}{\mathbf{C}}^{5+}_{2} |
| 2632 |
% \] |
| 2633 |
% \end{verbatim} |
| 2634 |
% \[ |
| 2635 |
% {}^{4}_{12}\mathbf{C}^{5+}_{2} \quad |
| 2636 |
% \prescript{14}{2}{\mathbf{C}}^{5+}_{2} \quad |
| 2637 |
% \prescript{4}{12}{\mathbf{C}}^{5+}_{2} \quad |
| 2638 |
% \prescript{14}{}{\mathbf{C}}^{5+}_{2} \quad |
| 2639 |
% \prescript{}{2}{\mathbf{C}}^{5+}_{2} |
| 2640 |
% \] |
| 2641 |
% |
| 2642 |
% The formatting of the arguments is controlled by three keys. This |
| 2643 |
% silly example shows you how to use them: |
| 2644 |
% \begin{verbatim} |
| 2645 |
% \newcommand*\myisotope[3]{% |
| 2646 |
% \begingroup % to keep changes local. We cannot use a brace group |
| 2647 |
% % as it affects spacing! |
| 2648 |
% \mathtoolsset{ |
| 2649 |
% prescript-sup-format=\mathit, |
| 2650 |
% prescript-sub-format=\mathbf, |
| 2651 |
% prescript-arg-format=\mathrm, |
| 2652 |
% }% |
| 2653 |
% \prescript{#1}{#2}{#3}% |
| 2654 |
% \endgroup |
| 2655 |
% } |
| 2656 |
% \[ |
| 2657 |
% \myisotope{A}{Z}{X}\to \myisotope{A-4}{Z-2}{Y}+ |
| 2658 |
% \myisotope{4}{2}{\alpha} |
| 2659 |
% \] |
| 2660 |
% \end{verbatim} |
| 2661 |
% \newcommand*\myisotope[3]{% |
| 2662 |
% \begingroup |
| 2663 |
% \mathtoolsset{ |
| 2664 |
% prescript-sup-format=\mathit, |
| 2665 |
% prescript-sub-format=\mathbf, |
| 2666 |
% prescript-arg-format=\mathrm, |
| 2667 |
% }% |
| 2668 |
% \prescript{#1}{#2}{#3}% |
| 2669 |
% \endgroup |
| 2670 |
% } |
| 2671 |
% \[ |
| 2672 |
% \myisotope{A}{Z}{X}\to \myisotope{A-4}{Z-2}{Y}+ |
| 2673 |
% \myisotope{4}{2}{\alpha} |
| 2674 |
% \] |
| 2675 |
% (Though a package like \pkg{mhchem} might be more suitable for this |
| 2676 |
% type of material.) |
| 2677 |
% |
| 2678 |
% |
| 2679 |
% \subsection{Declaring math sizes} |
| 2680 |
% |
| 2681 |
% \begin{codesyntax} |
| 2682 |
% \SpecialUsageIndex{\DeclareMathSizes} |
| 2683 |
% \cs{DeclareMathSizes}\marg{dimen}\marg{dimen}\marg{dimen}\marg{dimen} |
| 2684 |
% \end{codesyntax} |
| 2685 |
% \cttPosting{Michael J.~Downes}{2002/10/17} |
| 2686 |
% If you don't know about \cs{DeclareMathSizes}, then skip the rest |
| 2687 |
% of this text. If you do know, then all that is needed to say is |
| 2688 |
% that with \pkg{mathtools} it is patched so that all regular |
| 2689 |
% dimension suffixes are now valid in the last three arguments. Thus |
| 2690 |
% a declaration such as |
| 2691 |
% \begin{verbatim} |
| 2692 |
% \DeclareMathSize{9.5dd}{9.5dd}{7.5dd}{6.5dd} |
| 2693 |
% \end{verbatim} |
| 2694 |
% will now work (it doesn't in standard \LaTeX). When this bug has |
| 2695 |
% been fixed in \LaTeX, this fix will be removed from |
| 2696 |
% \pkg{mathtools}. |
| 2697 |
% |
| 2698 |
% The \CommentAdded{2015/11/12} fix was added to the \LaTeX{} kernel |
| 2699 |
% in 2015. We will continue to provide it on older kernels. |
| 2700 |
% |
| 2701 |
% \subsection{Spreading equations}\label{sec:spread} |
| 2702 |
% |
| 2703 |
% \begin{codesyntax} |
| 2704 |
% \SpecialEnvIndex{spreadlines} |
| 2705 |
% \cs{begin}\arg{spreadlines}\marg{dimen} \meta{contents} |
| 2706 |
% \cs{end}\arg{spreadlines} |
| 2707 |
% \end{codesyntax} |
| 2708 |
% \cttPosting{Michael J.~Downes}{2002/10/17} |
| 2709 |
% The spacing between lines in a multiline math environment such as |
| 2710 |
% \env{gather} is governed by the dimension \cs{jot}. The |
| 2711 |
% \env{spreadlines} environment takes one argument denoting the |
| 2712 |
% value of \cs{jot} inside the environment: |
| 2713 |
% \begin{verbatim} |
| 2714 |
% \begin{spreadlines}{20pt} |
| 2715 |
% Large spaces between the lines. |
| 2716 |
% \begin{gather} |
| 2717 |
% a=b\\ |
| 2718 |
% c=d |
| 2719 |
% \end{gather} |
| 2720 |
% \end{spreadlines} |
| 2721 |
% Back to normal spacing. |
| 2722 |
% \begin{gather} |
| 2723 |
% a=b\\ |
| 2724 |
% c=d |
| 2725 |
% \end{gather} |
| 2726 |
% \end{verbatim} |
| 2727 |
% \begin{spreadlines}{20pt} |
| 2728 |
% Large spaces between the lines. |
| 2729 |
% \begin{gather} |
| 2730 |
% a=b\\ |
| 2731 |
% c=d |
| 2732 |
% \end{gather} |
| 2733 |
% \end{spreadlines} |
| 2734 |
% Back to normal spacing. |
| 2735 |
% \begin{gather} |
| 2736 |
% a=b\\ |
| 2737 |
% c=d |
| 2738 |
% \end{gather} |
| 2739 |
% |
| 2740 |
% |
| 2741 |
% \subsection{Gathered environments}\label{subsec:gathered} |
| 2742 |
% |
| 2743 |
% \begin{codesyntax} |
| 2744 |
% \SpecialEnvIndex{lgathered}\cs{begin}\arg{lgathered}\oarg{pos} |
| 2745 |
% \meta{contents} \cs{end}\arg{lgathered} \\ |
| 2746 |
% \SpecialEnvIndex{rgathered}\cs{begin}\arg{rgathered}\oarg{pos} |
| 2747 |
% \meta{contents} \cs{end}\arg{rgathered} \\ |
| 2748 |
% \SpecialUsageIndex{\newgathered}\cs{newgathered}\marg{name}\marg{pre_line}\marg{post_line}\marg{after}\\ |
| 2749 |
% \SpecialUsageIndex{\renewgathered}\cs{renewgathered}\marg{name}\marg{pre_line}\marg{post_line}\marg{after} |
| 2750 |
% \end{codesyntax} |
| 2751 |
% \cttPosting{Michael J.~Downes}{2001/01/17} |
| 2752 |
% In a document set in \opt{fleqn}, you might sometimes want an |
| 2753 |
% inner \env{gathered} environment that doesn't center its lines but |
| 2754 |
% puts them flush left. The \env{lgathered} environment works just |
| 2755 |
% like the standard \env{gathered} except that it flushes its |
| 2756 |
% contents left: |
| 2757 |
% \begin{verbatim} |
| 2758 |
% \begin{equation} |
| 2759 |
% \begin{lgathered} |
| 2760 |
% x=1,\quad x+1=2 \\ |
| 2761 |
% y=2 |
| 2762 |
% \end{lgathered} |
| 2763 |
% \end{equation} |
| 2764 |
% \end{verbatim} |
| 2765 |
% \begin{equation} |
| 2766 |
% \begin{lgathered} |
| 2767 |
% x=1,\quad x+1=2 \\ |
| 2768 |
% y=2 |
| 2769 |
% \end{lgathered} |
| 2770 |
% \end{equation} |
| 2771 |
% Similarly the \env{rgathered} puts it contents flush right. |
| 2772 |
% |
| 2773 |
% More interesting is probably the command \cs{newgathered}. In this |
| 2774 |
% example we define a gathered version that centers the lines and |
| 2775 |
% also prints a star and a number at the left of each line. |
| 2776 |
% \begin{verbatim} |
| 2777 |
% \newcounter{steplinecnt} |
| 2778 |
% \newcommand\stepline{\stepcounter{steplinecnt}\thesteplinecnt} |
| 2779 |
% \newgathered{stargathered} |
| 2780 |
% {\llap{\stepline}$*$\quad\hfil}% \hfil for centering |
| 2781 |
% {\hfil}% \hfil for centering |
| 2782 |
% {\setcounter{steplinecnt}{0}}% reset counter |
| 2783 |
% \end{verbatim} |
| 2784 |
% \newcounter{steplinecnt} |
| 2785 |
% \newcommand\stepline{\stepcounter{steplinecnt}\thesteplinecnt} |
| 2786 |
% \newgathered{stargathered}{\llap{\stepline}$*$\quad\hfil}{\hfil}{\setcounter{steplinecnt}{0}} |
| 2787 |
% With these definitions we can get something like this: |
| 2788 |
% \begin{verbatim} |
| 2789 |
% \begin{gather} |
| 2790 |
% \begin{stargathered} |
| 2791 |
% x=1,\quad x+1=2 \\ |
| 2792 |
% y=2 |
| 2793 |
% \end{stargathered} |
| 2794 |
% \end{gather} |
| 2795 |
% \end{verbatim} |
| 2796 |
% \begin{gather} |
| 2797 |
% \begin{stargathered} |
| 2798 |
% x=1,\quad x+1=2 \\ |
| 2799 |
% y=2 |
| 2800 |
% \end{stargathered} |
| 2801 |
% \end{gather} |
| 2802 |
% \cs{renewgathered} renews a gathered environment of course. |
| 2803 |
% |
| 2804 |
% In all fairness it should be stated that the original concept by |
| 2805 |
% Michael has been extended quite a bit in \pkg{mathtools}. Only the |
| 2806 |
% end product of \env{lgathered} is the same. |
| 2807 |
% |
| 2808 |
% \subsection{Split fractions} |
| 2809 |
% |
| 2810 |
% \begin{codesyntax} |
| 2811 |
% \SpecialUsageIndex{\splitfrac}\cs{splitfrac}\marg{start line}\marg{continuation}\\ |
| 2812 |
% \SpecialUsageIndex{\splitdfrac}\cs{splitdfrac}\marg{start line}\marg{continuation} |
| 2813 |
% \end{codesyntax} |
| 2814 |
% \cttPosting{Michael J.~Downes}{2001/12/06} |
| 2815 |
% These commands provide split fractions, e.g., multiline fractions: |
| 2816 |
% \begin{verbatim} |
| 2817 |
% \[ |
| 2818 |
% a=\frac{ |
| 2819 |
% \splitfrac{xy + xy + xy + xy + xy} |
| 2820 |
% {+ xy + xy + xy + xy} |
| 2821 |
% } |
| 2822 |
% {z} |
| 2823 |
% =\frac{ |
| 2824 |
% \splitdfrac{xy + xy + xy + xy + xy} |
| 2825 |
% {+ xy + xy + xy + xy} |
| 2826 |
% } |
| 2827 |
% {z} |
| 2828 |
% \] |
| 2829 |
% \end{verbatim} |
| 2830 |
% \[ |
| 2831 |
% a=\frac{ |
| 2832 |
% \splitfrac{xy + xy + xy + xy + xy} |
| 2833 |
% {+ xy + xy + xy + xy} |
| 2834 |
% } |
| 2835 |
% {z} |
| 2836 |
% =\frac{ |
| 2837 |
% \splitdfrac{xy + xy + xy + xy + xy} |
| 2838 |
% {+ xy + xy + xy + xy} |
| 2839 |
% } |
| 2840 |
% {z} |
| 2841 |
% \] |
| 2842 |
% The difference between \cs{splitfrac} and \cs{splitdfrac} is that |
| 2843 |
% the former forces its arguments to be typeset in text-mode math, the |
| 2844 |
% latter does not. |
| 2845 |
% |
| 2846 |
% \medskip\noindent \textbf{Note:} If you try to nest \cs{splitfrac} |
| 2847 |
% inside each other you may need to add \cs{mathstrut} to the first |
| 2848 |
% argument of the nested fraction to get the spacing look even. It is |
| 2849 |
% not added by default as often a more cramped look is desired: |
| 2850 |
% \begin{verbatim} |
| 2851 |
% \[ |
| 2852 |
% \frac{ |
| 2853 |
% \splitfrac{xy + xy + xy + xy + xy} |
| 2854 |
% { |
| 2855 |
% \splitfrac{xy + xy + xy + xy + xy} |
| 2856 |
% {+ xy + xy + xy + xy} |
| 2857 |
% } |
| 2858 |
% } |
| 2859 |
% {z} |
| 2860 |
% =\frac{ |
| 2861 |
% \splitfrac{xy + xy + xy + xy + xy} |
| 2862 |
% { |
| 2863 |
% \splitfrac{\mathstrut xy + xy + xy + xy + xy} |
| 2864 |
% {+ xy + xy + xy + xy} |
| 2865 |
% } |
| 2866 |
% } |
| 2867 |
% {z} |
| 2868 |
% \] |
| 2869 |
% \end{verbatim} |
| 2870 |
% \[ |
| 2871 |
% \frac{ |
| 2872 |
% \splitfrac{xy + xy + xy + xy + xy} |
| 2873 |
% { |
| 2874 |
% \splitfrac{xy + xy + xy + xy + xy} |
| 2875 |
% {+ xy + xy + xy + xy} |
| 2876 |
% } |
| 2877 |
% } |
| 2878 |
% {z} |
| 2879 |
% =\frac{ |
| 2880 |
% \splitfrac{xy + xy + xy + xy + xy} |
| 2881 |
% { |
| 2882 |
% \splitfrac{\mathstrut xy + xy + xy + xy + xy} |
| 2883 |
% {+ xy + xy + xy + xy} |
| 2884 |
% } |
| 2885 |
% } |
| 2886 |
% {z} |
| 2887 |
% \] |
| 2888 |
% Note how the line spaces aren't even on the left hand side. |
| 2889 |
% |
| 2890 |
% For even more control, one can use \env{aligned} or \env{gathered} |
| 2891 |
% instead of \cs{splitfrac}. |
| 2892 |
% |
| 2893 |
% |
| 2894 |
% \newpage |
| 2895 |
% |
| 2896 |
% \section{New additions} |
| 2897 |
% |
| 2898 |
% \subsection{Variable math strut} |
| 2899 |
% \begin{codesyntax} |
| 2900 |
% \SpecialUsageIndex{\xmathstrut}\cs{xmathstrut}\oarg{depth increase}\marg{increase} |
| 2901 |
% \end{codesyntax} |
| 2902 |
% \FeatureRequest{Frank Mittelbach}{2020} In typography we use |
| 2903 |
% \emph{struts} to ensure specific line spacing. In text we have the |
| 2904 |
% \cs{strut} and in math \cs{mathstrut}. Both have no width, but |
| 2905 |
% equal the height and depth of an »(« from the current text/math |
| 2906 |
% font and size. In math we often need to make minute adjustments in |
| 2907 |
% macro definitions etc. The \emph{extended} math strut |
| 2908 |
% \cs{xmathstrut} allows to \emph{increase} (decrease if negative) |
| 2909 |
% the math strut in two ways. |
| 2910 |
% |
| 2911 |
% For an \meta{increase} (a decimal number), say~\verb|0.1|, |
| 2912 |
% \begin{center} |
| 2913 |
% \verb|\xmathstrut{0.1}| |
| 2914 |
% \end{center} |
| 2915 |
% will give you a new strut where 10\% of the \emph{total height of |
| 2916 |
% the normal math strut} (\verb|\mathstrut=\xmathstrut{0}|) will be |
| 2917 |
% added to both \emph{the height} and \emph{the depth} of the |
| 2918 |
% original strut (thus 20\% gets added in total). On the other hand |
| 2919 |
% \begin{center} |
| 2920 |
% \verb|\xmathstrut[0.2]{0.1}| |
| 2921 |
% \end{center} |
| 2922 |
% will result in a strut where 20\% is added to the depth and 10\% is |
| 2923 |
% added to the height, resulting in a strut that is 30\% larger than |
| 2924 |
% normal. |
| 2925 |
% |
| 2926 |
% The following example is inspired (with permission) from an example |
| 2927 |
% showcasing \cs{xmathstrut} in the upcoming third edition of |
| 2928 |
% \emph{The LaTeX Companion}. The example is very relevant as the |
| 2929 |
% entries of the \env{cases(*)} environment are typeset in \emph{text |
| 2930 |
% style} math and thus may end up looking quite |
| 2931 |
% squished.\footnote{Which is why Frank suggested the macro |
| 2932 |
% (including its implementation) in the first place.} |
| 2933 |
% \[ |
| 2934 |
% \begin{cases*} |
| 2935 |
% \frac{\frac{ x-1 }{ x-\sin x} }{ \sqrt{ 1 -x }} & $x >0$ \\ |
| 2936 |
% 0 & otherwise |
| 2937 |
% \end{cases*} |
| 2938 |
% \qquad\text{vs.}\qquad |
| 2939 |
% \begin{cases*} |
| 2940 |
% \frac{\frac{ \xmathstrut{0.1} x-1 }{ \xmathstrut{0.25} x-\sin x} }{\xmathstrut{0.4} \sqrt{ 1 -x }} & $x >0$ \\ |
| 2941 |
% 0 & otherwise |
| 2942 |
% \end{cases*} |
| 2943 |
% \] |
| 2944 |
% \begin{verbatim} |
| 2945 |
% \[ \begin{cases*} |
| 2946 |
% \frac{ \frac{ x-1 }{ x-\sin x } }{ \sqrt{ 1-x } } & $x>0$ \\ |
| 2947 |
% 0 & otherwise |
| 2948 |
% \end{cases*} |
| 2949 |
% \qquad\text{vs.}\qquad |
| 2950 |
% \begin{cases*} |
| 2951 |
% \frac{ \frac{ \xmathstrut{0.1} x-1 } |
| 2952 |
% { \xmathstrut{0.25} x-\sin x } } |
| 2953 |
% {\xmathstrut{0.4} \sqrt{ 1-x } } & $x>0$ \\ |
| 2954 |
% 0 & otherwise |
| 2955 |
% \end{cases*} \] |
| 2956 |
% \end{verbatim} |
| 2957 |
% |
| 2958 |
% To showcase the optional argument, it is |
| 2959 |
% probably easiest to make the strut visible. Here you'll see that |
| 2960 |
% \verb|\mathstrut| and \verb|\xmathstrut{0}| is the same: |
| 2961 |
% \newcommand\vfb[1]{\begingroup\fboxsep=0pt\boxed{\,#1\,}\endgroup} |
| 2962 |
% \[ |
| 2963 |
% \llap{\rlap{\rule{18mm}{0.1pt}}\quad}a \vfb{\mathstrut} \ \vfb{\xmathstrut{0}}\ |
| 2964 |
% \vfb{\xmathstrut{0.5} } \ \vfb{\xmathstrut{-0.1} }\ \vfb{\xmathstrut[0.5]{0}} a |
| 2965 |
% \] |
| 2966 |
% \newpage |
| 2967 |
% \begin{verbatim} |
| 2968 |
% \newcommand\vfb[1]{\begingroup\fboxsep=0pt\boxed{\,#1\,}\endgroup} |
| 2969 |
% \[ |
| 2970 |
% a |
| 2971 |
% \vfb{ \mathstrut } \ % normal strut |
| 2972 |
% \vfb{ \xmathstrut{0} } \ % just 0 => normal strut |
| 2973 |
% \vfb{ \xmathstrut{0.5} } \ % twice as large 50% + 50% |
| 2974 |
% \vfb{ \xmathstrut{-0.1} } \ % negative gives something smaller |
| 2975 |
% \vfb{ \xmathstrut[0.5]{0} } % change only the depth |
| 2976 |
% a |
| 2977 |
% \] |
| 2978 |
% \end{verbatim} |
| 2979 |
% -- the last box showcases a strut where we have only changed the |
| 2980 |
% depth of the strut. One can see \verb|\xmathstrut[0.5]{0}| kind of the |
| 2981 |
% opposite of \verb|\smash[b]{...}|, the former makes the depth larger |
| 2982 |
% and the latter ignores the depth. |
| 2983 |
% |
| 2984 |
% |
| 2985 |
% |
| 2986 |
% |
| 2987 |
% |
| 2988 |
% |
| 2989 |
% |
| 2990 |
% |
| 2991 |
% |
| 2992 |
% |
| 2993 |
% |
| 2994 |
% |
| 2995 |
% |
| 2996 |
% |
| 2997 |
% |
| 2998 |
% |
| 2999 |
% |
| 3000 |
% |
| 3001 |
% |
| 3002 |
% |
| 3003 |
% |
| 3004 |
% |
| 3005 |
% |
| 3006 |
% |
| 3007 |
% |
| 3008 |
% |
| 3009 |
% |
| 3010 |
% |
| 3011 |
% |
| 3012 |
% |
| 3013 |
% |
| 3014 |
% |
| 3015 |
% |
| 3016 |
% |
| 3017 |
% |
| 3018 |
% |
| 3019 |
% |
| 3020 |
% |
| 3021 |
% |
| 3022 |
% |
| 3023 |
% |
| 3024 |
% |
| 3025 |
% |
| 3026 |
% |
| 3027 |
% |
| 3028 |
% |
| 3029 |
% |
| 3030 |
% |
| 3031 |
% |
| 3032 |
% |
| 3033 |
% |
| 3034 |
% |
| 3035 |
% |
| 3036 |
% |
| 3037 |
% |
| 3038 |
% |
| 3039 |
% |
| 3040 |
% |
| 3041 |
% |
| 3042 |
% |
| 3043 |
% |
| 3044 |
% |
| 3045 |
% |
| 3046 |
% |
| 3047 |
% |
| 3048 |
% |
| 3049 |
% |
| 3050 |
% |
| 3051 |
% |
| 3052 |
% |
| 3053 |
% |
| 3054 |
% |
| 3055 |
% |
| 3056 |
% |
| 3057 |
% |
| 3058 |
% |
| 3059 |
% |
| 3060 |
% |
| 3061 |
% |
| 3062 |
% |
| 3063 |
% |
| 3064 |
% |
| 3065 |
% |
| 3066 |
% |
| 3067 |
% |
| 3068 |
% |
| 3069 |
% |
| 3070 |
% |
| 3071 |
% |
| 3072 |
% |
| 3073 |
% |
| 3074 |
% |
| 3075 |
% |
| 3076 |
% |
| 3077 |
% |
| 3078 |
% |
| 3079 |
% |
| 3080 |
% |
| 3081 |
% |
| 3082 |
% |
| 3083 |
% |
| 3084 |
% |
| 3085 |
% |
| 3086 |
% |
| 3087 |
% |
| 3088 |
% \begin{thebibliography}{9} |
| 3089 |
% \bibitem{Perlis01} Alexander R. Perlis, \emph{A complement to |
| 3090 |
% \cs{smash}, \cs{llap}, and \cs{rlap}}, TUGboat 22(4) |
| 3091 |
% (2001). Available at |
| 3092 |
% \url{https://www.tug.org/TUGboat/tb22-4/tb72perlS.pdf}. |
| 3093 |
% \bibitem{Ams99} American Mathematical Society and Michael Downes, |
| 3094 |
% \emph{Technical notes on the \pkg{amsmath} package}. Version 2.0, |
| 3095 |
% 1999/10/29. Available via |
| 3096 |
% \url{http://mirrors.ctan.org/macros/latex/required/amsmath/technote.pdf}. |
| 3097 |
% \bibitem{Ams00} Frank Mittelbach, Rainer Sch\"opf, Michael Downes, |
| 3098 |
% David M.~Jones and David Carlisle, \emph{The \pkg{amsmath} |
| 3099 |
% package}. Version 2.17e, 2020/01/20. Maintained by the \LaTeX3 |
| 3100 |
% project. Available as file |
| 3101 |
% \url{http://mirrors.ctan.org/macros/latex/required/amsmath/amsmath.dtx}. |
| 3102 |
% \bibitem{A-W:MG04} |
| 3103 |
% Frank Mittelbach and Michel Goossens. |
| 3104 |
% \emph{The {\LaTeX} Companion}. |
| 3105 |
% Tools and Techniques for Computer Typesetting. Addison-Wesley, |
| 3106 |
% Boston, Massachusetts, 2 edition, 2004. |
| 3107 |
% With Johannes Braams, David Carlisle, and Chris Rowley. |
| 3108 |
% |
| 3109 |
% \bibitem{Carl99} David Carlisle, \emph{The \pkg{keyval} Package}. |
| 3110 |
% Version 1.15, 2014/10/28. Available via |
| 3111 |
% \url{https://ctan.org/pkg/keyval}. |
| 3112 |
% |
| 3113 |
% \bibitem{Voss:2004} Herbert Vo\ss, \emph{Math mode}. Version 2.47, |
| 3114 |
% 2014/01/30. Available as |
| 3115 |
% \url{http://mirrors.ctan.org/obsolete/info/math/voss/mathmode/Mathmode.pdf}. Please |
| 3116 |
% note that the author has marked the document as \emph{obsolete}. |
| 3117 |
% |
| 3118 |
% \bibitem{Swanson} |
| 3119 |
% Ellen Swanson, |
| 3120 |
% \emph{Mathematics into type}. |
| 3121 |
% American Mathematical Society, updated edition, 1999. |
| 3122 |
% Updated by Arlene O'Sean and Antoinette Schleyer. Available from |
| 3123 |
% the AMS at \url{https://www.ams.org/arc/styleguide/mit-2.pdf}. |
| 3124 |
% |
| 3125 |
% \bibitem{TBT} Victor Eijkhout, \emph{\TeX\ by Topic, A Texnician's |
| 3126 |
% Reference}, 2007. The book is available at |
| 3127 |
% \url{https://ctan.org/pkg/texbytopic}. |
| 3128 |
% \end{thebibliography} |
| 3129 |
% |
| 3130 |
% |
| 3131 |
% \StopEventually{} |
| 3132 |
% |
| 3133 |
% |
| 3134 |
% \section{Options and package loading} |
| 3135 |
% |
| 3136 |
% |
| 3137 |
% Lets start the package. |
| 3138 |
% \begin{macrocode} |
| 3139 |
%<*package> |
| 3140 |
\ProvidesPackage{mathtools}% |
| 3141 |
[2024/10/04 v1.31 mathematical typesetting tools] |
| 3142 |
% \end{macrocode} |
| 3143 |
% \changes{v1.10}{2011/02/12}{Might as well make sure that we need the |
| 3144 |
% latest version of \texttt{mhsetup}} |
| 3145 |
% \begin{macrocode} |
| 3146 |
\RequirePackage{keyval,calc} |
| 3147 |
\RequirePackage{mhsetup}[2021/03/18] |
| 3148 |
\MHInternalSyntaxOn |
| 3149 |
% \end{macrocode} |
| 3150 |
% \changes{v1.13}{2013/02/11}{Robustifying \cs{(}\cs{)}\cs{[}\cs{]}} |
| 3151 |
% We'd like to make \cs{(}\cs{)} and \cs{[}\cs{]} robust. This can |
| 3152 |
% easily be done via the \pkg{fixltx2e} package, but auto loading that |
| 3153 |
% package may cause problems for some. We make copies instead. |
| 3154 |
% Update 2021: We have removed robustifying \cs{(}\cs{)}\cs{[}\cs{]} |
| 3155 |
% as this is now in the \LaTeX\ kernel. We still use |
| 3156 |
% \verb|\EQ_MakeRobust| elsewhere though. |
| 3157 |
% \begin{macro}{\EQ_MakeRobust} |
| 3158 |
% \begin{macro}{\forced_EQ_MakeRobust} |
| 3159 |
% \begin{macrocode} |
| 3160 |
% borrowed from fixltx2e |
| 3161 |
\def\EQ_MakeRobust#1{% |
| 3162 |
\@ifundefined{\expandafter\@gobble\string#1}{% |
| 3163 |
\@latex@error{The~control~sequence~`\string#1'~is~undefined!% |
| 3164 |
\MessageBreak There~is~nothing~here~to~make~robust}% |
| 3165 |
\@eha |
| 3166 |
}% |
| 3167 |
{% |
| 3168 |
\@ifundefined{\expandafter\@gobble\string#1\space}% |
| 3169 |
{% |
| 3170 |
\expandafter\let\csname |
| 3171 |
\expandafter\@gobble\string#1\space\endcsname=#1% |
| 3172 |
\edef\reserved@a{\string#1}% |
| 3173 |
\def\reserved@b{#1}% |
| 3174 |
\edef\reserved@b{\expandafter\strip@prefix\meaning\reserved@b}% |
| 3175 |
\edef#1{% |
| 3176 |
\ifx\reserved@a\reserved@b |
| 3177 |
\noexpand\x@protect\noexpand#1% |
| 3178 |
\fi |
| 3179 |
\noexpand\protect\expandafter\noexpand |
| 3180 |
\csname\expandafter\@gobble\string#1\space\endcsname}% |
| 3181 |
}% |
| 3182 |
{\@latex@info{The~control~sequence~`\string#1'~is~already~robust}}% |
| 3183 |
}% |
| 3184 |
} |
| 3185 |
% \end{macrocode} |
| 3186 |
% We also provide a handy alternativ version, that will robustify no |
| 3187 |
% matter what. Useful for the \texttt{mathic} option. |
| 3188 |
% \begin{macrocode} |
| 3189 |
\def\forced_EQ_MakeRobust#1{% |
| 3190 |
\@ifundefined{\expandafter\@gobble\string#1}{% |
| 3191 |
\@latex@error{The~control~sequence~`\string#1'~is~undefined!% |
| 3192 |
\MessageBreak There~is~nothing~here~to~make~robust}% |
| 3193 |
\@eha |
| 3194 |
}% |
| 3195 |
{% |
| 3196 |
% \@ifundefined{\expandafter\@gobble\string#1\space}% |
| 3197 |
% {% |
| 3198 |
\expandafter\let\csname |
| 3199 |
\expandafter\@gobble\string#1\space\endcsname=#1% |
| 3200 |
\edef\reserved@a{\string#1}% |
| 3201 |
\def\reserved@b{#1}% |
| 3202 |
\edef\reserved@b{\expandafter\strip@prefix\meaning\reserved@b}% |
| 3203 |
\edef#1{% |
| 3204 |
\ifx\reserved@a\reserved@b |
| 3205 |
\noexpand\x@protect\noexpand#1% |
| 3206 |
\fi |
| 3207 |
\noexpand\protect\expandafter\noexpand |
| 3208 |
\csname\expandafter\@gobble\string#1\space\endcsname}% |
| 3209 |
% }% |
| 3210 |
% {\@latex@info{The control sequence `\string#1' is already robust}}% |
| 3211 |
}% |
| 3212 |
} |
| 3213 |
% \end{macrocode} |
| 3214 |
% \end{macro} |
| 3215 |
% \end{macro} |
| 3216 |
% |
| 3217 |
% \begin{macro}{\MT_options_name:} |
| 3218 |
% \begin{macro}{\mathtoolsset} |
| 3219 |
% The name for the options and a user interface for setting keys. |
| 3220 |
% \begin{macrocode} |
| 3221 |
\def\MT_options_name:{mathtools} |
| 3222 |
\newcommand*\mathtoolsset[1]{\setkeys{\MT_options_name:}{#1}} |
| 3223 |
% \end{macrocode} |
| 3224 |
% \end{macro} |
| 3225 |
% \end{macro} |
| 3226 |
% |
| 3227 |
% Fix \pkg{amsmath} bugs (strongly recommended!). It requires a |
| 3228 |
% great deal of typing to avoid fixing the bugs. He he. |
| 3229 |
% \begin{macrocode} |
| 3230 |
\MH_new_boolean:n {fixamsmath} |
| 3231 |
\DeclareOption{fixamsmath}{ |
| 3232 |
\MH_set_boolean_T:n {fixamsmath} |
| 3233 |
} |
| 3234 |
\DeclareOption{donotfixamsmathbugs}{ |
| 3235 |
\MH_set_boolean_F:n {fixamsmath} |
| 3236 |
} |
| 3237 |
% \end{macrocode} |
| 3238 |
% Disallow spaces before optional arguments in certain \pkg{amsmath} |
| 3239 |
% building blocks. |
| 3240 |
% \begin{macrocode} |
| 3241 |
\DeclareOption{allowspaces}{ |
| 3242 |
\MH_let:NwN \MaybeMHPrecedingSpacesOff |
| 3243 |
\relax |
| 3244 |
\MH_let:NwN \MH_maybe_nospace_ifnextchar:Nnn \kernel@ifnextchar |
| 3245 |
} |
| 3246 |
\DeclareOption{disallowspaces}{ |
| 3247 |
\MH_let:NwN \MaybeMHPrecedingSpacesOff |
| 3248 |
\MHPrecedingSpacesOff |
| 3249 |
\MH_let:NwN \MH_maybe_nospace_ifnextchar:Nnn \MH_nospace_ifnextchar:Nnn |
| 3250 |
} |
| 3251 |
% \end{macrocode} |
| 3252 |
% \changes{v1.13}{2013/02/11}{Option to disable robustifying |
| 3253 |
% \cs{(}\cs{)} and \cs{[}\cs{]}} |
| 3254 |
% Option to disallow robustifying \cs{(}\cs{)} and \cs{[}\cs{]}. |
| 3255 |
% \begin{macrocode} |
| 3256 |
\MH_new_boolean:n {robustify} |
| 3257 |
\MH_set_boolean_T:n {robustify} |
| 3258 |
\DeclareOption{nonrobust}{ |
| 3259 |
\MH_set_boolean_F:n {robustify} |
| 3260 |
} |
| 3261 |
% \end{macrocode} |
| 3262 |
% \changes{v1.29}{2022/06/24}{Added package option to bring back old |
| 3263 |
% colon symbols} |
| 3264 |
% As of juni/july 2022 we've had to rename several of the provided |
| 3265 |
% \cs{...colon...} macros. If needed this package option brings them back. |
| 3266 |
% \begin{macrocode} |
| 3267 |
\MH_new_boolean:n {legacycolonsymbols} |
| 3268 |
\MH_set_boolean_F:n {legacycolonsymbols} |
| 3269 |
\DeclareOption{legacycolonsymbols}{ |
| 3270 |
\MH_set_boolean_T:n {legacycolonsymbols} |
| 3271 |
} |
| 3272 |
% \end{macrocode} |
| 3273 |
% Pass all other options directly to \pkg{amsmath}. |
| 3274 |
% \begin{macrocode} |
| 3275 |
\DeclareOption*{ |
| 3276 |
\PassOptionsToPackage{\CurrentOption}{amsmath} |
| 3277 |
} |
| 3278 |
% \end{macrocode} |
| 3279 |
% Executing options |
| 3280 |
% \begin{macrocode} |
| 3281 |
\ExecuteOptions{fixamsmath,disallowspaces} |
| 3282 |
\ProcessOptions\relax |
| 3283 |
% \end{macrocode} |
| 3284 |
% We have to turn off the new syntax when \pkg{amstext} is loaded. |
| 3285 |
% \begin{macrocode} |
| 3286 |
\MHInternalSyntaxOff |
| 3287 |
\RequirePackage{amsmath}[2016/11/05] |
| 3288 |
% \end{macrocode} |
| 3289 |
% \changes{v1.29}{2022/06/27}{Added \pkg{unicode-math} warning} |
| 3290 |
% \begin{macrocode} |
| 3291 |
\@ifpackageloaded{unicode-math}{ |
| 3292 |
\PackageWarning{mathtools}{For best results, please load mathtools |
| 3293 |
*before* \MessageBreak unicode-math} |
| 3294 |
}{} |
| 3295 |
% \end{macrocode} |
| 3296 |
% \begin{macrocode} |
| 3297 |
\MHInternalSyntaxOn |
| 3298 |
\AtEndOfPackage{\MHInternalSyntaxOff} |
| 3299 |
% \end{macrocode} |
| 3300 |
% \begin{macro}{\MT_true_false_error:} |
| 3301 |
% Make sure the user selects either `true' or `false' when asked too. |
| 3302 |
% \begin{macrocode} |
| 3303 |
\def\MT_true_false_error:{ |
| 3304 |
\PackageError{mathtools} |
| 3305 |
{You~ have~ to~ select~ either~ `true'~ or~ `false'} |
| 3306 |
{I'll~ assume~ you~ chose~ `false'~ for~ now.} |
| 3307 |
} |
| 3308 |
% \end{macrocode} |
| 3309 |
% \end{macro} |
| 3310 |
% ^^A \changes{v1.13}{2013/02/11}{Make \cs{(}\cs{)} and \cs{[}\cs{]} |
| 3311 |
% ^^A robust} |
| 3312 |
% ^^A We start of with making \cs{(}\cs{)} and \cs{[}\cs{]} robust, |
| 3313 |
% ^^A unless the user explicitly asked us not to. |
| 3314 |
% ^^A \changes{v1.28}{2021/12/31}{Removed robustifying \cs{(}\cs{)} and |
| 3315 |
% ^^A \cs{[}\cs{]} as this is now in the \LaTeX{} kernel.} |
| 3316 |
% ^^A % \begin{macrocode} |
| 3317 |
% ^^A \MH_if_boolean:nT {robustify}{ |
| 3318 |
% ^^A \EQ_MakeRobust\( |
| 3319 |
% ^^A \EQ_MakeRobust\) |
| 3320 |
% ^^A \EQ_MakeRobust\[ |
| 3321 |
% ^^A \EQ_MakeRobust\] |
| 3322 |
% ^^A } |
| 3323 |
% ^^A % \end{macrocode} |
| 3324 |
% |
| 3325 |
% |
| 3326 |
% \section{Macros I got ideas for myself} |
| 3327 |
% |
| 3328 |
% |
| 3329 |
% |
| 3330 |
% \subsection{Tag forms} |
| 3331 |
% This is quite simple, but why isn't it then a part of some widely |
| 3332 |
% distributed package? Beats me. |
| 3333 |
% |
| 3334 |
% \begin{macro}{\MT_define_tagform:nwnn} |
| 3335 |
% We start out by defining a command that will allow us to define |
| 3336 |
% commands similar to \cs{tagform@} only this will give us tag form |
| 3337 |
% \emph{types}. The actual code is very similar to the one in |
| 3338 |
% \pkg{amsmath}. |
| 3339 |
% \changes{v1.30}{2024/01/19}{Add group so \#2 (the inner format) does not leak} |
| 3340 |
% \begin{macrocode} |
| 3341 |
\def\MT_define_tagform:nwnn #1[#2]#3#4{ |
| 3342 |
\@namedef{MT_tagform_#1:n}##1 |
| 3343 |
{\maketag@@@{#3\ignorespaces{#2{##1}}\unskip\@@italiccorr#4}} |
| 3344 |
} |
| 3345 |
% \end{macrocode} |
| 3346 |
% \end{macro} |
| 3347 |
% |
| 3348 |
% \begin{macro}{\newtagform} |
| 3349 |
% Similar to \cs{newcommand}. Check if defined and scan for presence |
| 3350 |
% of optional argument. Then call generic command. |
| 3351 |
% \begin{macrocode} |
| 3352 |
\providecommand*\newtagform[1]{% |
| 3353 |
\@ifundefined{MT_tagform_#1:n} |
| 3354 |
{\@ifnextchar[% |
| 3355 |
{\MT_define_tagform:nwnn #1}% |
| 3356 |
{\MT_define_tagform:nwnn #1[]}% |
| 3357 |
}{\PackageError{mathtools} |
| 3358 |
{The~ tag~ form~ `#1'~ is~ already~ defined\MessageBreak |
| 3359 |
You~ probably~ want~ to~ look~ up~ \@backslashchar renewtagform~ |
| 3360 |
instead} |
| 3361 |
{I~ will~ just~ ignore~ your~ wish~ for~ now.}} |
| 3362 |
} |
| 3363 |
% \end{macrocode} |
| 3364 |
% Provide a default tag form which---surprise, surprise---is |
| 3365 |
% identical to the standard definition. |
| 3366 |
% \begin{macrocode} |
| 3367 |
\newtagform{default}{(}{)} |
| 3368 |
% \end{macrocode} |
| 3369 |
% \end{macro} |
| 3370 |
% \begin{macro}{\renewtagform} |
| 3371 |
% Similar to \cs{renewcommand}. |
| 3372 |
% \begin{macrocode} |
| 3373 |
\providecommand*\renewtagform[1]{% |
| 3374 |
\@ifundefined{MT_tagform_#1:n} |
| 3375 |
{\PackageError{mathtools} |
| 3376 |
{The~ tag~ form~ `#1'~ is~ not~ defined\MessageBreak |
| 3377 |
You~ probably~ want~ to~ look~ up~ \@backslashchar newtagform~ instead} |
| 3378 |
{I~ will~ just~ ignore~ your~ wish~ for~ now.}} |
| 3379 |
{\@ifnextchar[% |
| 3380 |
{\MT_define_tagform:nwnn #1}% |
| 3381 |
{\MT_define_tagform:nwnn #1[]}% |
| 3382 |
} |
| 3383 |
} |
| 3384 |
% \end{macrocode} |
| 3385 |
% \end{macro} |
| 3386 |
% \begin{macro}{\usetagform} |
| 3387 |
% Then the activator. Test if the tag form is defined and then |
| 3388 |
% activate it by redefining \cs{tagform@}. |
| 3389 |
% \begin{macrocode} |
| 3390 |
\providecommand*\usetagform[1]{% |
| 3391 |
\@ifundefined{MT_tagform_#1:n} |
| 3392 |
{ |
| 3393 |
\PackageError{mathtools}{% |
| 3394 |
You~ have~ chosen~ the~ tag~ form~ `#1'\MessageBreak |
| 3395 |
but~ it~ appears~ to~ be~ undefined} |
| 3396 |
{I~ will~ use~ the~ default~ tag~ form~ instead.}% |
| 3397 |
\@namedef{tagform@}{\@nameuse{MT_tagform_default:n}} |
| 3398 |
} |
| 3399 |
{ \@namedef{tagform@}{\@nameuse{MT_tagform_#1:n}} } |
| 3400 |
% \end{macrocode} |
| 3401 |
% Here we patch if we're using the special ``show only referenced |
| 3402 |
% equations'' feature. |
| 3403 |
% \begin{macrocode} |
| 3404 |
\MH_if_boolean:nT {show_only_refs}{ |
| 3405 |
\MH_let:NwN \MT_prev_tagform:n \tagform@ |
| 3406 |
\def\tagform@##1{\MT_extended_tagform:n {##1}} |
| 3407 |
} |
| 3408 |
} |
| 3409 |
% \end{macrocode} |
| 3410 |
% \end{macro} |
| 3411 |
% |
| 3412 |
% \subsubsection{Showing only referenced tags} |
| 3413 |
% A little more interesting is the way to print only the equation |
| 3414 |
% numbers that are actually referenced. |
| 3415 |
% |
| 3416 |
% A few booleans to help determine which situations we're in. |
| 3417 |
% \begin{macrocode} |
| 3418 |
\MH_new_boolean:n {manual_tag} |
| 3419 |
\MH_new_boolean:n {raw_maketag} |
| 3420 |
% \end{macrocode} |
| 3421 |
% \begin{macro}{\MT_AmS_tag_in_align:} |
| 3422 |
% \begin{macro}{\tag@in@align} |
| 3423 |
% \begin{macro}{\tag@in@display} |
| 3424 |
% We'll need to know when the user has put in a manual tag, and since |
| 3425 |
% \cs{tag} is \cs{let} to all sorts of things inside the \pkg{amsmath} |
| 3426 |
% code it is safer to provide a small hack to the functions it is copied |
| 3427 |
% from. Note that we can't use \cs{iftag@}. |
| 3428 |
% \begin{macrocode} |
| 3429 |
\MH_let:NwN \MT_AmS_tag_in_align: \tag@in@align |
| 3430 |
\def\tag@in@align{ |
| 3431 |
\global\MH_set_boolean_T:n {manual_tag} |
| 3432 |
\MT_AmS_tag_in_align: |
| 3433 |
} |
| 3434 |
\def\tag@in@display#1#{ |
| 3435 |
\relax |
| 3436 |
\global\MH_set_boolean_T:n {manual_tag} |
| 3437 |
\tag@in@display@a{#1} |
| 3438 |
} |
| 3439 |
% \end{macrocode} |
| 3440 |
% \end{macro} |
| 3441 |
% \end{macro} |
| 3442 |
% \end{macro} |
| 3443 |
% |
| 3444 |
% \begin{macro}{\MT_extended_tagform:n} |
| 3445 |
% \changes{v1.01}{2004/08/03}{Simplified quite a bit} |
| 3446 |
% The extended version of \cs{tagform@}. |
| 3447 |
% \begin{macrocode} |
| 3448 |
\def\MT_extended_tagform:n #1{ |
| 3449 |
\MH_set_boolean_F:n {raw_maketag} |
| 3450 |
% \end{macrocode} |
| 3451 |
% We test if the equation was labelled. We already know if it was |
| 3452 |
% tagged manually. Have to watch out for \TeX\ inserting a blank line |
| 3453 |
% so do not let the tag have width zero. Rememeber |
| 3454 |
% \cs{@safe@activestrue/false} in order to handle active chars in labels. |
| 3455 |
% \changes{v1.12}{2012/04/24}{Added \cs{@safe@activestrue/false}} |
| 3456 |
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} |
| 3457 |
% \begin{macrocode} |
| 3458 |
\MH_if_meaning:NN \df@label\@empty |
| 3459 |
\MH_if_boolean:nTF {manual_tag}% this was \MH_if_boolean:nT before |
| 3460 |
{ \MH_if_boolean:nTF {show_manual_tags} |
| 3461 |
{ \MT_prev_tagform:n {#1} } |
| 3462 |
{ \stepcounter{equation} } |
| 3463 |
}{\kern1sp}% this last {\kern1sp} is new. |
| 3464 |
\MH_else: |
| 3465 |
\MH_if_boolean:nTF {manual_tag} |
| 3466 |
{ \MH_if_boolean:nTF {show_manual_tags} |
| 3467 |
{ \MT_prev_tagform:n {#1} } |
| 3468 |
{ \@safe@activestrue |
| 3469 |
\@ifundefined{MT_r_\df@label} |
| 3470 |
% \end{macrocode} |
| 3471 |
% Next we need to remember to deactivate the manual tags switch. This |
| 3472 |
% is usually done using \verb|\MT_extended_maketag:n|, but this is not |
| 3473 |
% the case if the show manual tags is false and the manual tag is not |
| 3474 |
% referred to. |
| 3475 |
% \changes{v1.12}{2011/06/08}{Added the falsification of manual tag |
| 3476 |
% when show manual tags is off and maual tag is not referred to} |
| 3477 |
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} |
| 3478 |
% \changes{v1.23}{2020/01/17}{Added \cs{kern1sp} in a few places to |
| 3479 |
% make sure the tag has a non zero width.} |
| 3480 |
% \begin{macrocode} |
| 3481 |
{ \global\MH_set_boolean_F:n {manual_tag} \kern1sp } % kern added 2020 |
| 3482 |
{ \MT_prev_tagform:n {#1} } |
| 3483 |
\@safe@activesfalse |
| 3484 |
} |
| 3485 |
} |
| 3486 |
{ |
| 3487 |
\@safe@activestrue |
| 3488 |
\@ifundefined{MT_r_\df@label} |
| 3489 |
{ \kern1sp }% kern added 2020 |
| 3490 |
{ \refstepcounter{equation}\MT_prev_tagform:n {#1} } |
| 3491 |
\@safe@activesfalse |
| 3492 |
} |
| 3493 |
\MH_fi: |
| 3494 |
\global\MH_set_boolean_T:n {raw_maketag} |
| 3495 |
} |
| 3496 |
% \end{macrocode} |
| 3497 |
% \end{macro} |
| 3498 |
% \begin{macro}{\MT_extended_maketag:n} |
| 3499 |
% The extended version of \cs{maketag@@@}. |
| 3500 |
% \changes{v1.12}{2012/04/24}{Added \cs{@safe@activestrue/false}} |
| 3501 |
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} |
| 3502 |
% \begin{macrocode} |
| 3503 |
\def\MT_extended_maketag:n #1{ |
| 3504 |
\ifx\df@label\@empty |
| 3505 |
\MT_maketag:n {#1} |
| 3506 |
\MH_else: |
| 3507 |
\MH_if_boolean:nTF {raw_maketag} |
| 3508 |
{ |
| 3509 |
\MH_if_boolean:nTF {show_manual_tags} |
| 3510 |
{ \MT_maketag:n {#1} } |
| 3511 |
{ \@safe@activestrue |
| 3512 |
\@ifundefined{MT_r_\df@label} |
| 3513 |
{ } |
| 3514 |
{ \MT_maketag:n {#1} } |
| 3515 |
\@safe@activesfalse |
| 3516 |
} |
| 3517 |
} |
| 3518 |
{ \MT_maketag:n {#1} } |
| 3519 |
\MH_fi: |
| 3520 |
% \end{macrocode} |
| 3521 |
% As this function is always called we let it set the marker for a manual |
| 3522 |
% tag false when exiting (well actually not true, see above). |
| 3523 |
% \begin{macrocode} |
| 3524 |
\global\MH_set_boolean_F:n {manual_tag} |
| 3525 |
} |
| 3526 |
% \end{macrocode} |
| 3527 |
% \end{macro} |
| 3528 |
% \begin{macro}{\MT_extended_eqref:n} |
| 3529 |
% \changes{v1.01}{2004/08/03}{Make it robust} |
| 3530 |
% We let \cs{eqref} write the label to the \file{aux} file, which is |
| 3531 |
% read at the beginning of the next run. Then we print the equation |
| 3532 |
% number as usual. |
| 3533 |
% \changes{v1.14}{2013/03/07}{It was not really robust} |
| 3534 |
% \begin{macrocode} |
| 3535 |
\def\MT_extended_eqref:n #1{ |
| 3536 |
\protected@write\@auxout{} |
| 3537 |
{\string\MT@newlabel{#1}} |
| 3538 |
% \end{macrocode} |
| 3539 |
% \changes{v1.16}{2015/05/11}{Fix bug in \cs{eqref} in \cs{text} vs. \textsf{showonlyrefs}} |
| 3540 |
% The manner in which \key{showonlyrefs} is implemented causes |
| 3541 |
% problems when \cs{eqref} is used within \cs{text}. The problem is |
| 3542 |
% that \cs{MT_prev_tagform:n} is used both in \cs{eqref} and within, |
| 3543 |
% say, \env{align}. Thus a test within \cs{MT_prev_tagform:n} fails |
| 3544 |
% for \cs{eqref}. We fix this by making sure we end up in the proper |
| 3545 |
% branch of the test, when \cs{MT_prev_tagform:n} is used to typeset \cs{eqref}. |
| 3546 |
% \begin{macrocode} |
| 3547 |
\textup{\let\df@label\@empty\MT_prev_tagform:n {\ref{#1}}} |
| 3548 |
} |
| 3549 |
\EQ_MakeRobust\MT_extended_eqref:n |
| 3550 |
% \end{macrocode} |
| 3551 |
% \end{macro} |
| 3552 |
% |
| 3553 |
% \begin{macro}{\refeq} |
| 3554 |
% \begin{macro}{\MT_extended_refeq:n} |
| 3555 |
% Similar to \cs{eqref} and \cs{MT_extended_eqref:n}. |
| 3556 |
% \begin{macrocode} |
| 3557 |
\newcommand*\refeq[1]{ |
| 3558 |
\textup{\ref{#1}} |
| 3559 |
} |
| 3560 |
\def\MT_extended_refeq:n #1{ |
| 3561 |
\protected@write\@auxout{} |
| 3562 |
{\string\MT@newlabel{#1}} |
| 3563 |
\textup{\ref{#1}} |
| 3564 |
} |
| 3565 |
% \end{macrocode} |
| 3566 |
% \end{macro} |
| 3567 |
% \end{macro} |
| 3568 |
% |
| 3569 |
% \begin{macro}{\MT@newlabel} |
| 3570 |
% We can't use |:| or |_| in the command name (yet). We define the |
| 3571 |
% special labels for the equations that have been referenced in the |
| 3572 |
% previous run. |
| 3573 |
% \begin{macrocode} |
| 3574 |
\newcommand*\MT@newlabel[1]{ \global\@namedef{MT_r_#1}{} } |
| 3575 |
% \end{macrocode} |
| 3576 |
% \end{macro} |
| 3577 |
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} |
| 3578 |
% \begin{macrocode} |
| 3579 |
\MH_new_boolean:n {show_only_refs} |
| 3580 |
\MH_new_boolean:n {show_manual_tags} |
| 3581 |
\define@key{\MT_options_name:}{showmanualtags}[true]{ |
| 3582 |
\@ifundefined{MH_boolean_show_manual_tags_#1:} |
| 3583 |
{ \MT_true_false_error: |
| 3584 |
\@nameuse{MH_boolean_show_manual_tags_false:} |
| 3585 |
} |
| 3586 |
{ \@nameuse{MH_boolean_show_manual_tags_#1:} } |
| 3587 |
} |
| 3588 |
% \end{macrocode} |
| 3589 |
% \begin{macro}{\MT_showonlyrefs_true:} |
| 3590 |
% The implementation is based on the idea that \cs{tagform@} can be |
| 3591 |
% called in two circumstances: when the tag is being printed in the |
| 3592 |
% equation and when it is being printed during a reference. |
| 3593 |
% \begin{macrocode} |
| 3594 |
\newcommand*\MT_showonlyrefs_true:{ |
| 3595 |
\MH_if_boolean:nF {show_only_refs}{ |
| 3596 |
\MH_set_boolean_T:n {show_only_refs} |
| 3597 |
% \end{macrocode} |
| 3598 |
% Save the definitions of the original commands. |
| 3599 |
% \begin{macrocode} |
| 3600 |
\MH_let:NwN \MT_incr_eqnum: \incr@eqnum |
| 3601 |
\MH_let:NwN \incr@eqnum \@empty |
| 3602 |
\MH_let:NwN \MT_array_parbox_restore: \@arrayparboxrestore |
| 3603 |
\@xp\def\@xp\@arrayparboxrestore\@xp{\@arrayparboxrestore |
| 3604 |
\MH_let:NwN \incr@eqnum \@empty |
| 3605 |
} |
| 3606 |
\MH_let:NwN \MT_prev_tagform:n \tagform@ |
| 3607 |
\MH_let:NwN \MT_eqref:n \eqref |
| 3608 |
\MH_let:NwN \MT_refeq:n \refeq |
| 3609 |
\MH_let:NwN \MT_maketag:n \maketag@@@ |
| 3610 |
\MH_let:NwN \maketag@@@ \MT_extended_maketag:n |
| 3611 |
% \end{macrocode} |
| 3612 |
% We redefine \cs{tagform@}. |
| 3613 |
% \begin{macrocode} |
| 3614 |
\def\tagform@##1{\MT_extended_tagform:n {##1}} |
| 3615 |
% \end{macrocode} |
| 3616 |
% Then \cs{eqref}: |
| 3617 |
% \begin{macrocode} |
| 3618 |
\MH_let:NwN \eqref \MT_extended_eqref:n |
| 3619 |
\MH_let:NwN \refeq \MT_extended_refeq:n |
| 3620 |
} |
| 3621 |
} |
| 3622 |
% \end{macrocode} |
| 3623 |
% \end{macro} |
| 3624 |
% \begin{macro}{\MT_showonlyrefs_false:} |
| 3625 |
% This macro reverts the settings. |
| 3626 |
% \begin{macrocode} |
| 3627 |
\def\MT_showonlyrefs_false: { |
| 3628 |
\MH_if_boolean:nT {show_only_refs}{ |
| 3629 |
\MH_set_boolean_F:n {show_only_refs} |
| 3630 |
\MH_let:NwN \tagform@ \MT_prev_tagform:n |
| 3631 |
\MH_let:NwN \eqref \MT_eqref:n |
| 3632 |
\MH_let:NwN \refeq \MT_refeq:n |
| 3633 |
\MH_let:NwN \maketag@@@ \MT_maketag:n |
| 3634 |
\MH_let:NwN \incr@eqnum \MT_incr_eqnum: |
| 3635 |
\MH_let:NwN \@arrayparboxrestore \MT_array_parbox_restore: |
| 3636 |
} |
| 3637 |
} |
| 3638 |
\define@key{\MT_options_name:}{showonlyrefs}[true]{ |
| 3639 |
\@nameuse{MT_showonlyrefs_#1:} |
| 3640 |
} |
| 3641 |
% \end{macrocode} |
| 3642 |
% \end{macro} |
| 3643 |
% |
| 3644 |
% |
| 3645 |
% \begin{macro}{\nonumber} |
| 3646 |
% \changes{v1.01}{2004/08/03}{Fixed using \cs{notag} or \cs{nonumber} |
| 3647 |
% with the \key{showonlyrefs} feature} |
| 3648 |
% We have to redefine \cs{nonumber} else it will subtract one from the |
| 3649 |
% equation number where we don't want it. This is probably not needed |
| 3650 |
% since \cs{nonumber} is unnecessary when \key{showonlyrefs} is in |
| 3651 |
% effect, but now you can use it with old documents as well. |
| 3652 |
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} |
| 3653 |
% \begin{macrocode} |
| 3654 |
\renewcommand\nonumber{ |
| 3655 |
\if@eqnsw |
| 3656 |
\MH_if_meaning:NN \incr@eqnum\@empty |
| 3657 |
% \end{macrocode} |
| 3658 |
% Only subtract the number if |show_only_refs| is false. |
| 3659 |
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} |
| 3660 |
% \begin{macrocode} |
| 3661 |
\MH_if_boolean:nF {show_only_refs} |
| 3662 |
{\addtocounter{equation}\m@ne} |
| 3663 |
\MH_fi: |
| 3664 |
\MH_fi: |
| 3665 |
\MH_let:NwN \print@eqnum\@empty \MH_let:NwN \incr@eqnum\@empty |
| 3666 |
\global\@eqnswfalse |
| 3667 |
} |
| 3668 |
% \end{macrocode} |
| 3669 |
% \end{macro} |
| 3670 |
% |
| 3671 |
% \begin{macro}{\noeqref} |
| 3672 |
% \changes{v1.04}{2008/03/26}{Added \cs{noeqref} (daleif)} |
| 3673 |
% \changes{v1.12}{2012/04/20}{Labels containing active chars (babel) |
| 3674 |
% are now allowed} |
| 3675 |
% \changes{v1.12}{2012/04/24}{\cs{noeqref} will now make a reference |
| 3676 |
% warning if users use undefined labels in \cs{noeqref}, requested |
| 3677 |
% by Tue Christensen} |
| 3678 |
% Macro for adding numbers to non-referred equations. Syntax similar |
| 3679 |
% to \cs{nocite}. |
| 3680 |
% \begin{macrocode} |
| 3681 |
\MHInternalSyntaxOff |
| 3682 |
\newcommand\noeqref[1]{\@bsphack% |
| 3683 |
\@for\@tempa:=#1\do{% |
| 3684 |
\@safe@activestrue% |
| 3685 |
\edef\@tempa{\expandafter\@firstofone\@tempa}% |
| 3686 |
\@ifundefined{r@\@tempa}{% |
| 3687 |
\protect\G@refundefinedtrue% |
| 3688 |
\@latex@warning{Reference `\@tempa' on page \thepage \space |
| 3689 |
undefined (\string\noeqref)}% |
| 3690 |
}{}% |
| 3691 |
\if@filesw\protected@write\@auxout{}% |
| 3692 |
{\string\MT@newlabel{\@tempa}}\fi% |
| 3693 |
\@safe@activesfalse}% |
| 3694 |
\@esphack} |
| 3695 |
|
| 3696 |
% \end{macrocode} |
| 3697 |
% \end{macro} |
| 3698 |
% |
| 3699 |
% \begin{macro}{\@safe@activestrue} |
| 3700 |
% \begin{macro}{\@safe@activesfalse} |
| 3701 |
% These macros are provided by babel. We \emph{provide} them here, |
| 3702 |
% just to make sure they exist. |
| 3703 |
% \begin{macrocode} |
| 3704 |
\providecommand\@safe@activestrue{}% |
| 3705 |
\providecommand\@safe@activesfalse{}% |
| 3706 |
|
| 3707 |
\MHInternalSyntaxOn |
| 3708 |
% \end{macrocode} |
| 3709 |
% |
| 3710 |
% \end{macro} |
| 3711 |
% \end{macro} |
| 3712 |
% |
| 3713 |
% \subsection{Extensible arrows etc.} |
| 3714 |
% |
| 3715 |
% \begin{macro}{\xleftrightarrow} |
| 3716 |
% \begin{macro}{\MT_leftrightarrow_fill:} |
| 3717 |
% \begin{macro}{\xLeftarrow} |
| 3718 |
% \begin{macro}{\xRightarrow} |
| 3719 |
% \begin{macro}{\xLeftrightarrow} |
| 3720 |
% |
| 3721 |
% These are straight adaptions from \pkg{amsmath}. |
| 3722 |
% \changes{v1.24}{2020/03/13}{Added spaces to move the argument away |
| 3723 |
% from the arrow head in \cs{xLeftarrow}, \cs{xRightarrow} and |
| 3724 |
% \cs{xLeftrightarrow}. Suggested by FM} |
| 3725 |
% \changes{1.28}{2022/01/01}{Added \cs{xlongrightarrow} and |
| 3726 |
% \cs{xlongleftarrow} as suggested in Issue \#12} |
| 3727 |
% \begin{macrocode} |
| 3728 |
\providecommand*\xleftrightarrow[2][]{% |
| 3729 |
\ext@arrow 3095\MT_leftrightarrow_fill:{#1}{#2}} |
| 3730 |
\def\MT_leftrightarrow_fill:{% |
| 3731 |
\arrowfill@\leftarrow\relbar\rightarrow} |
| 3732 |
\providecommand*\xLeftarrow[2][]{% |
| 3733 |
\ext@arrow 0055{\Leftarrowfill@}{\ #1}{\ #2}} |
| 3734 |
\providecommand*\xRightarrow[2][]{% |
| 3735 |
\ext@arrow 0055{\Rightarrowfill@}{#1\ }{#2\ }} |
| 3736 |
\providecommand*\xLeftrightarrow[2][]{% |
| 3737 |
\ext@arrow 0055{\Leftrightarrowfill@}{\ #1\ }{\ #2\ }} |
| 3738 |
% \end{macrocode} |
| 3739 |
% \end{macro} |
| 3740 |
% \end{macro} |
| 3741 |
% \end{macro} |
| 3742 |
% \end{macro} |
| 3743 |
% \end{macro} |
| 3744 |
% \begin{macro}{\MT_rightharpoondown_fill:} |
| 3745 |
% \begin{macro}{\MT_rightharpoonup_fill:} |
| 3746 |
% \begin{macro}{\MT_leftharpoondown_fill:} |
| 3747 |
% \begin{macro}{\MT_leftharpoonup_fill:} |
| 3748 |
% \begin{macro}{\xrightharpoondown} |
| 3749 |
% \begin{macro}{\xrightharpoonup} |
| 3750 |
% \begin{macro}{\xleftharpoondown} |
| 3751 |
% \begin{macro}{\xleftharpoonup} |
| 3752 |
% \begin{macro}{\xleftrightharpoons} |
| 3753 |
% \begin{macro}{\xrightleftharpoons} |
| 3754 |
% The harpoons. |
| 3755 |
% \begin{macrocode} |
| 3756 |
\def\MT_rightharpoondown_fill:{% |
| 3757 |
\arrowfill@\relbar\relbar\rightharpoondown} |
| 3758 |
\def\MT_rightharpoonup_fill:{% |
| 3759 |
\arrowfill@\relbar\relbar\rightharpoonup} |
| 3760 |
\def\MT_leftharpoondown_fill:{% |
| 3761 |
\arrowfill@\leftharpoondown\relbar\relbar} |
| 3762 |
\def\MT_leftharpoonup_fill:{% |
| 3763 |
\arrowfill@\leftharpoonup\relbar\relbar} |
| 3764 |
% \end{macrocode} |
| 3765 |
% 2022: added \verb+_fill:+ macros based upon \cs{longrightarrow} and \cs{longleftarrow} |
| 3766 |
% \begin{macrocode} |
| 3767 |
\def\MT_longrightarrow_fill:{% |
| 3768 |
\arrowfill@\relbar\relbar\longrightarrow} |
| 3769 |
\def\MT_longleftarrow_fill:{% |
| 3770 |
\arrowfill@\longleftarrow\relbar\relbar} |
| 3771 |
\providecommand*\xrightharpoondown[2][]{% |
| 3772 |
\ext@arrow 0359\MT_rightharpoondown_fill:{#1}{#2}} |
| 3773 |
\providecommand*\xrightharpoonup[2][]{% |
| 3774 |
\ext@arrow 0359\MT_rightharpoonup_fill:{#1}{#2}} |
| 3775 |
\providecommand*\xleftharpoondown[2][]{% |
| 3776 |
\ext@arrow 3095\MT_leftharpoondown_fill:{#1}{#2}} |
| 3777 |
\providecommand*\xleftharpoonup[2][]{% |
| 3778 |
\ext@arrow 3095\MT_leftharpoonup_fill:{#1}{#2}} |
| 3779 |
\providecommand*\xleftrightharpoons[2][]{\mathrel{% |
| 3780 |
\raise.22ex\hbox{% |
| 3781 |
$\ext@arrow 3095\MT_leftharpoonup_fill:{\phantom{#1}}{#2}$}% |
| 3782 |
\setbox0=\hbox{% |
| 3783 |
$\ext@arrow 0359\MT_rightharpoondown_fill:{#1}{\phantom{#2}}$}% |
| 3784 |
\kern-\wd0 \lower.22ex\box0}} |
| 3785 |
\providecommand*\xrightleftharpoons[2][]{\mathrel{% |
| 3786 |
\raise.22ex\hbox{% |
| 3787 |
$\ext@arrow 0359\MT_rightharpoonup_fill:{\phantom{#1}}{#2}$}% |
| 3788 |
\setbox0=\hbox{% |
| 3789 |
$\ext@arrow 3095\MT_leftharpoondown_fill:{#1}{\phantom{#2}}$}% |
| 3790 |
\kern-\wd0 \lower.22ex\box0}} |
| 3791 |
% \end{macrocode} |
| 3792 |
% 2022: added \verb+\xlong...+ macros based upon \cs{longrightarrow} |
| 3793 |
% and \cs{longleftarrow} |
| 3794 |
% \begin{macrocode} |
| 3795 |
\providecommand*\xlongrightarrow[2][]{% |
| 3796 |
\ext@arrow 0359\MT_longrightarrow_fill:{#1}{#2}} |
| 3797 |
\providecommand*\xlongleftarrow[2][]{% |
| 3798 |
\ext@arrow 3095\MT_longleftarrow_fill:{#1}{#2}} |
| 3799 |
% \end{macrocode} |
| 3800 |
% \end{macro} |
| 3801 |
% \end{macro} |
| 3802 |
% \end{macro} |
| 3803 |
% \end{macro} |
| 3804 |
% \end{macro} |
| 3805 |
% \end{macro} |
| 3806 |
% \end{macro} |
| 3807 |
% \end{macro} |
| 3808 |
% \end{macro} |
| 3809 |
% \end{macro} |
| 3810 |
% \begin{macro}{\xhookleftarrow} |
| 3811 |
% \begin{macro}{\xhookrightarrow} |
| 3812 |
% \begin{macro}{\MT_hookright_fill:} |
| 3813 |
% The hooks. |
| 3814 |
% \begin{macrocode} |
| 3815 |
\providecommand*\xhookleftarrow[2][]{% |
| 3816 |
\ext@arrow 3095\MT_hookleft_fill:{#1}{#2}} |
| 3817 |
\def\MT_hookleft_fill:{% |
| 3818 |
\arrowfill@\leftarrow\relbar{\relbar\joinrel\rhook}} |
| 3819 |
\providecommand*\xhookrightarrow[2][]{% |
| 3820 |
\ext@arrow 3095\MT_hookright_fill:{#1}{#2}} |
| 3821 |
\def\MT_hookright_fill:{% |
| 3822 |
\arrowfill@{\lhook\joinrel\relbar}\relbar\rightarrow} |
| 3823 |
% \end{macrocode} |
| 3824 |
% \end{macro} |
| 3825 |
% \end{macro} |
| 3826 |
% \end{macro} |
| 3827 |
% \begin{macro}{\xmapsto} |
| 3828 |
% \begin{macro}{\MT_mapsto_fill:} |
| 3829 |
% The maps-to arrow. |
| 3830 |
% \begin{macrocode} |
| 3831 |
\providecommand*\xmapsto[2][]{% |
| 3832 |
\ext@arrow 0395\MT_mapsto_fill:{#1}{#2}} |
| 3833 |
\def\MT_mapsto_fill:{% |
| 3834 |
\arrowfill@{\mapstochar\relbar}\relbar\rightarrow} |
| 3835 |
% \end{macrocode} |
| 3836 |
% \end{macro} |
| 3837 |
% \end{macro} |
| 3838 |
% 2024 (v1.30): Added \verb+\xLongrightarrow+ and \verb+\xLongleftarrow+. Code by muzimuchi on GitHub. I added extra spaces like for |\xRightarrow| above. |
| 3839 |
% \begin{macro}{\MT_Longrightarrow_fill:} |
| 3840 |
% \begin{macro}{\MT_Longleftarrow_fill:} |
| 3841 |
% \begin{macro}{\xLongrightarrow} |
| 3842 |
% \begin{macro}{\xLongleftarrow} |
| 3843 |
% \begin{macrocode} |
| 3844 |
\def\MT_Longrightarrow_fill:{% |
| 3845 |
\arrowfill@\Relbar\Relbar\Longrightarrow} |
| 3846 |
\def\MT_Longleftarrow_fill:{% |
| 3847 |
\arrowfill@\Longleftarrow\Relbar\Relbar} |
| 3848 |
|
| 3849 |
\providecommand*\xLongrightarrow[2][]{% |
| 3850 |
\ext@arrow 0359\MT_Longrightarrow_fill:{#1\ }{#2\ }} |
| 3851 |
\providecommand*\xLongleftarrow[2][]{% |
| 3852 |
\ext@arrow 3095\MT_Longleftarrow_fill:{\ #1}{\ #2}} |
| 3853 |
|
| 3854 |
% \end{macrocode} |
| 3855 |
% \end{macro} |
| 3856 |
% \end{macro} |
| 3857 |
% \end{macro} |
| 3858 |
% \end{macro} |
| 3859 |
% |
| 3860 |
% \subsection{Underbrackets etc.} |
| 3861 |
% |
| 3862 |
% \begin{macro}{\underbracket} |
| 3863 |
% \begin{macro}{\MT_underbracket_I:w} |
| 3864 |
% \begin{macro}{\MT_underbracket_II:w} |
| 3865 |
% \begin{macro}{\upbracketfill} |
| 3866 |
% \begin{macro}{\upbracketend} |
| 3867 |
% The \cs{underbracket} macro. Scan for two optional arguments. When |
| 3868 |
% \pkg{xparse} becomes the standard this will be so much easier. |
| 3869 |
% \begin{macrocode} |
| 3870 |
\providecommand*\underbracket{ |
| 3871 |
\@ifnextchar[ |
| 3872 |
{\MT_underbracket_I:w} |
| 3873 |
{\MT_underbracket_I:w[\l_MT_bracketheight_fdim]}} |
| 3874 |
\def\MT_underbracket_I:w[#1]{ |
| 3875 |
\@ifnextchar[ |
| 3876 |
{\MT_underbracket_II:w[#1]} |
| 3877 |
{\MT_underbracket_II:w[#1][.7\fontdimen5\textfont2]}} |
| 3878 |
\def\MT_underbracket_II:w[#1][#2]#3{% |
| 3879 |
\mathop{\vtop{\m@th\ialign{## |
| 3880 |
\crcr |
| 3881 |
$\hfil\displaystyle{#3}\hfil$% |
| 3882 |
\crcr |
| 3883 |
\noalign{\kern .2\fontdimen5\textfont2 \nointerlineskip}% |
| 3884 |
\upbracketfill {#1}{#2}% |
| 3885 |
\crcr}}} |
| 3886 |
\limits} |
| 3887 |
\def\upbracketfill#1#2{% |
| 3888 |
\sbox\z@{$\braceld$} |
| 3889 |
\edef\l_MT_bracketheight_fdim{\the\ht\z@}% |
| 3890 |
\upbracketend{#1}{#2} |
| 3891 |
\leaders \vrule \@height \z@ \@depth #1 \hfill |
| 3892 |
\upbracketend{#1}{#2}% |
| 3893 |
} |
| 3894 |
\def\upbracketend#1#2{\vrule \@height #2 \@width #1\relax} |
| 3895 |
% \end{macrocode} |
| 3896 |
% \end{macro} |
| 3897 |
% \end{macro} |
| 3898 |
% \end{macro} |
| 3899 |
% \end{macro} |
| 3900 |
% \end{macro} |
| 3901 |
% \begin{macro}{\overbracket} |
| 3902 |
% \begin{macro}{\MT_overbracket_I:w} |
| 3903 |
% \begin{macro}{\MT_overbracket_II:w} |
| 3904 |
% \begin{macro}{\downbracketfill} |
| 3905 |
% \begin{macro}{\downbracketend} |
| 3906 |
% The overbracket is quite similar. |
| 3907 |
% \begin{macrocode} |
| 3908 |
\providecommand*\overbracket{ |
| 3909 |
\@ifnextchar[ |
| 3910 |
{\MT_overbracket_I:w} |
| 3911 |
{\MT_overbracket_I:w[\l_MT_bracketheight_fdim]}} |
| 3912 |
\def\MT_overbracket_I:w[#1]{ |
| 3913 |
\@ifnextchar[ |
| 3914 |
{\MT_overbracket_II:w[#1]} |
| 3915 |
{\MT_overbracket_II:w[#1][.7\fontdimen5\textfont2]}} |
| 3916 |
\def\MT_overbracket_II:w[#1][#2]#3{% |
| 3917 |
\mathop{\vbox{\m@th\ialign{## |
| 3918 |
\crcr |
| 3919 |
\downbracketfill{#1}{#2}% |
| 3920 |
\crcr |
| 3921 |
\noalign{\kern .2\fontdimen5\textfont2 \nointerlineskip}% |
| 3922 |
$\hfil\displaystyle{#3}\hfil$ |
| 3923 |
\crcr}}}% |
| 3924 |
\limits} |
| 3925 |
\def\downbracketfill#1#2{% |
| 3926 |
\sbox\z@{$\braceld$}\edef\l_MT_bracketheight_fdim{\the\ht\z@} |
| 3927 |
\downbracketend{#1}{#2} |
| 3928 |
\leaders \vrule \@height #1 \@depth \z@ \hfill |
| 3929 |
\downbracketend{#1}{#2}% |
| 3930 |
} |
| 3931 |
\def\downbracketend#1#2{\vrule \@width #1\@depth #2\relax} |
| 3932 |
% \end{macrocode} |
| 3933 |
% \end{macro} |
| 3934 |
% \end{macro} |
| 3935 |
% \end{macro} |
| 3936 |
% \end{macro} |
| 3937 |
% \end{macro} |
| 3938 |
% \begin{macro}{\LaTeXunderbrace} |
| 3939 |
% \begin{macro}{\underbrace} |
| 3940 |
% Redefinition of \cs{underbrace} and \cs{overbrace}. |
| 3941 |
% \begin{macrocode} |
| 3942 |
\MH_let:NwN \LaTeXunderbrace \underbrace |
| 3943 |
\def\underbrace#1{\mathop{\vtop{\m@th\ialign{##\crcr |
| 3944 |
$\hfil\displaystyle{#1}\hfil$\crcr |
| 3945 |
\noalign{\kern.7\fontdimen5\textfont2\nointerlineskip}% |
| 3946 |
% \end{macrocode} |
| 3947 |
% |.5\fontdimen5\textfont2| is the height of the tip of the brace. |
| 3948 |
% the remaining |.2\fontdimen5\textfont2| is for space between |
| 3949 |
% \begin{macrocode} |
| 3950 |
\upbracefill\crcr\noalign{\kern.5\fontdimen5\textfont2}}}}\limits} |
| 3951 |
% \end{macrocode} |
| 3952 |
% \end{macro} |
| 3953 |
% \end{macro} |
| 3954 |
% \begin{macro}{\LaTeXoverbrace} |
| 3955 |
% \begin{macro}{\overbrace} |
| 3956 |
% Same technique for \cs{overbrace}. |
| 3957 |
% \begin{macrocode} |
| 3958 |
\MH_let:NwN \LaTeXoverbrace \overbrace |
| 3959 |
\def\overbrace#1{\mathop{\vbox{\m@th\ialign{##\crcr |
| 3960 |
\noalign{\kern.5\fontdimen5\textfont2}% |
| 3961 |
% \end{macrocode} |
| 3962 |
% Adjust for tip height |
| 3963 |
% \begin{macrocode} |
| 3964 |
\downbracefill\crcr |
| 3965 |
\noalign{\kern.7\fontdimen5\textfont2\nointerlineskip}% |
| 3966 |
% \end{macrocode} |
| 3967 |
% |.5\fontdimen5\textfont2| is the height of the tip of the brace. |
| 3968 |
% The remaining |.2\fontdimen5\textfont2| is for space between |
| 3969 |
% \begin{macrocode} |
| 3970 |
$\hfil\displaystyle{#1}\hfil$\crcr}}}\limits} |
| 3971 |
% \end{macrocode} |
| 3972 |
% \end{macro} |
| 3973 |
% \end{macro} |
| 3974 |
% |
| 3975 |
% |
| 3976 |
% |
| 3977 |
% |
| 3978 |
% |
| 3979 |
% \subsection{Special symbols} |
| 3980 |
% |
| 3981 |
% \subsubsection{Command names for parentheses} |
| 3982 |
% \begin{macro}{\lparen} |
| 3983 |
% \begin{macro}{\rparen} |
| 3984 |
% Just an addition to the \LaTeXe\ kernel. |
| 3985 |
% \begin{macrocode} |
| 3986 |
\providecommand*\lparen{(} |
| 3987 |
\providecommand*\rparen{)} |
| 3988 |
% \end{macrocode} |
| 3989 |
% \end{macro} |
| 3990 |
% \end{macro} |
| 3991 |
|
| 3992 |
% \subsubsection{Vertically centered colon} |
| 3993 |
% |
| 3994 |
% \begin{macro}{\vcentcolon} |
| 3995 |
% \begin{macro}{\ordinarycolon} |
| 3996 |
% \begin{macro}{\MT_active_colon_true:} |
| 3997 |
% \begin{macro}{\MT_active_colon_false:} |
| 3998 |
% This is from the hands of Donald Arseneau. Somehow it is not |
| 3999 |
% distributed, so I include it here. Here's the original text by |
| 4000 |
% Donald: |
| 4001 |
% \begin{verbatim} |
| 4002 |
% centercolon.sty Dec 7, 2000 |
| 4003 |
% Donald Arseneau [email protected] |
| 4004 |
% Public domain. |
| 4005 |
% Vertically center colon characters (:) in math mode. |
| 4006 |
% Particularly useful for $ a:=b$, and still correct for |
| 4007 |
% $f : x\to y$. May be used in any TeX. |
| 4008 |
% \end{verbatim} |
| 4009 |
% |
| 4010 |
% Slight change: the colon meaning is given only if \verb|centercolon| |
| 4011 |
% is explicitly requested (before it was always assigned even if : remained |
| 4012 |
% catcode 12). This allows better interaction with packages like babel |
| 4013 |
% that also make colon active. |
| 4014 |
% \begin{macrocode} |
| 4015 |
\def\vcentcolon{\mathrel{\mathop\ordinarycolon}} |
| 4016 |
\providecommand\ordinarycolon{:} |
| 4017 |
\begingroup |
| 4018 |
\catcode`\:=\active |
| 4019 |
\lowercase{\endgroup |
| 4020 |
\def\MT_activate_colon{% |
| 4021 |
\ifnum\mathcode`\:=32768\relax |
| 4022 |
\let\ordinarycolon= :% |
| 4023 |
\else |
| 4024 |
\mathchardef\ordinarycolon\mathcode`\: % |
| 4025 |
\fi |
| 4026 |
\let :\vcentcolon |
| 4027 |
} |
| 4028 |
} |
| 4029 |
% \end{macrocode} |
| 4030 |
% Option processing. |
| 4031 |
% The `false' branch can only be requested if the option has previously been set `true'. |
| 4032 |
% (By default neither are set.) |
| 4033 |
% \begin{macrocode} |
| 4034 |
\MH_new_boolean:n {center_colon} |
| 4035 |
\define@key{\MT_options_name:}{centercolon}[true]{ |
| 4036 |
\@ifundefined{MT_active_colon_#1:} |
| 4037 |
{ \MT_true_false_error:n |
| 4038 |
\@nameuse{MT_active_colon_false:} |
| 4039 |
} |
| 4040 |
{ \@nameuse{MT_active_colon_#1:} } |
| 4041 |
} |
| 4042 |
\def\MT_active_colon_true: { |
| 4043 |
\MT_activate_colon |
| 4044 |
\MH_if_boolean:nF {center_colon}{ |
| 4045 |
\MH_set_boolean_T:n {center_colon} |
| 4046 |
\edef\MT_active_colon_false: |
| 4047 |
{\mathcode`\noexpand\:=\the\mathcode`\:\relax} |
| 4048 |
\mathcode`\:=32768 |
| 4049 |
} |
| 4050 |
} |
| 4051 |
% \end{macrocode} |
| 4052 |
% |
| 4053 |
% \changes{v1.30}{2022/11/15}{Forgot to define a default |
| 4054 |
% \cs{MT\_active\_colon_false:}, who would run centercolon=false |
| 4055 |
% before it being true?} |
| 4056 |
% \begin{macrocode} |
| 4057 |
\def\MT_active_colon_false:{} |
| 4058 |
% \end{macrocode} |
| 4059 |
% \end{macro} |
| 4060 |
% \end{macro} |
| 4061 |
% \end{macro} |
| 4062 |
% \end{macro} |
| 4063 |
% \begin{macro}{\MATHT@dblcolon} |
| 4064 |
% \begin{macro}{\MATHT@coloneq} |
| 4065 |
% \begin{macro}{\MATHT@dblcoloneq} |
| 4066 |
% \begin{macro}{\MATHT@colondash} |
| 4067 |
% \begin{macro}{\MATHT@dblcolondash} |
| 4068 |
% \begin{macro}{\MATHT@eqcolon} |
| 4069 |
% \begin{macro}{\MATHT@eqdblcolon} |
| 4070 |
% \begin{macro}{\MATHT@dashcolon} |
| 4071 |
% \begin{macro}{\MATHT@dashdblcolon} |
| 4072 |
% \begin{macro}{\MATHT@colonapprox} |
| 4073 |
% \begin{macro}{\MATHT@dblcolonapprox} |
| 4074 |
% \begin{macro}{\MATHT@approxcolon} |
| 4075 |
% \begin{macro}{\MATHT@approxdblcolon} |
| 4076 |
% \begin{macro}{\MATHT@colonsim} |
| 4077 |
% \begin{macro}{\MATHT@dblcolonsim} |
| 4078 |
% \begin{macro}{\MATHT@simcolon} |
| 4079 |
% \begin{macro}{\MATHT@simdblcolon} |
| 4080 |
% We can now use \cs{vcentcolon} to define some colon related |
| 4081 |
% symbols. Orinally the names of these macro names came from |
| 4082 |
% \pkg{txfonts} and \pkg{pxfonts}. Though it turned out that some of |
| 4083 |
% them we named inconsistently. Instead we now first name the macros |
| 4084 |
% using an internal name and then later map these onto names similar |
| 4085 |
% to those coming from \pkg{newtxmath} and \pkg{newpxmath}. |
| 4086 |
% \changes{v1.08c}{2010/11/17}{Enclosed all in \cs{mathrel}} |
| 4087 |
% \changes{v1.18}{2015/11/12}{Moved the enclosing \cs{mathrel} to |
| 4088 |
% \cs{mkern}. This is a result of |
| 4089 |
% \url{http://chat.stackexchange.com/transcript/message/23630342#23630342} and \url{http://chat.stackexchange.com/transcript/message/25348032#25348032}} |
| 4090 |
% \changes{v1.29}{2022/06/27}{Moved symbol defs into separate MATHT named |
| 4091 |
% macros} |
| 4092 |
% \begin{macrocode} |
| 4093 |
\newcommand*\MATHT@dblcolon{\vcentcolon\mathrel{\mkern-.9mu}\vcentcolon} |
| 4094 |
\newcommand*\MATHT@coloneq{\vcentcolon\mathrel{\mkern-1.2mu}=} |
| 4095 |
\newcommand*\MATHT@dblcoloneq{\dblcolon\mathrel{\mkern-1.2mu}=} |
| 4096 |
\newcommand*\MATHT@colondash{\vcentcolon\mathrel{\mkern-1.2mu}\mathrel{-}} |
| 4097 |
\newcommand*\MATHT@dblcolondash{\dblcolon\mathrel{\mkern-1.2mu}\mathrel{-}} |
| 4098 |
\newcommand*\MATHT@eqcolon{=\mathrel{\mkern-1.2mu}\vcentcolon} |
| 4099 |
\newcommand*\MATHT@eqdblcolon{=\mathrel{\mkern-1.2mu}\dblcolon} |
| 4100 |
\newcommand*\MATHT@dashcolon{\mathrel{-}\mathrel{\mkern-1.2mu}\vcentcolon} |
| 4101 |
\newcommand*\MATHT@dashdblcolon{\mathrel{-}\mathrel{\mkern-1.2mu}\dblcolon} |
| 4102 |
\newcommand*\MATHT@colonapprox{\vcentcolon\mathrel{\mkern-1.2mu}\approx} |
| 4103 |
\newcommand*\MATHT@dblcolonapprox{\dblcolon\mathrel{\mkern-1.2mu}\approx} |
| 4104 |
\newcommand*\MATHT@approxcolon{\approx\mathrel{\mkern-1.2mu}\vcentcolon} |
| 4105 |
\newcommand*\MATHT@approxdblcolon{\approx\mathrel{\mkern-1.2mu}\dblcolon} |
| 4106 |
\newcommand*\MATHT@colonsim{\vcentcolon\mathrel{\mkern-1.2mu}\sim} |
| 4107 |
\newcommand*\MATHT@dblcolonsim{\dblcolon\mathrel{\mkern-1.2mu}\sim} |
| 4108 |
\newcommand*\MATHT@simcolon{\sim\mathrel{\mkern-1.2mu}\vcentcolon} |
| 4109 |
\newcommand*\MATHT@simdblcolon{\sim\mathrel{\mkern-1.2mu}\dblcolon} |
| 4110 |
% \end{macrocode} |
| 4111 |
% \end{macro} |
| 4112 |
% \end{macro} |
| 4113 |
% \end{macro} |
| 4114 |
% \end{macro} |
| 4115 |
% \end{macro} |
| 4116 |
% \end{macro} |
| 4117 |
% \end{macro} |
| 4118 |
% \end{macro} |
| 4119 |
% \end{macro} |
| 4120 |
% \end{macro} |
| 4121 |
% \end{macro} |
| 4122 |
% \end{macro} |
| 4123 |
% \end{macro} |
| 4124 |
% \end{macro} |
| 4125 |
% \end{macro} |
| 4126 |
% \end{macro} |
| 4127 |
% \end{macro} |
| 4128 |
% \begin{macro}{\dblcolon} |
| 4129 |
% \begin{macro}{\coloneqq} |
| 4130 |
% \begin{macro}{\Coloneqq} |
| 4131 |
% \begin{macro}{\coloneq} |
| 4132 |
% \begin{macro}{\Coloneq} |
| 4133 |
% \begin{macro}{\eqqcolon} |
| 4134 |
% \begin{macro}{\Eqqcolon} |
| 4135 |
% \begin{macro}{\eqcolon} |
| 4136 |
% \begin{macro}{\Eqcolon} |
| 4137 |
% \begin{macro}{\colonapprox} |
| 4138 |
% \begin{macro}{\Colonapprox} |
| 4139 |
% \begin{macro}{\colonsim} |
| 4140 |
% \begin{macro}{\Colonsim} |
| 4141 |
% This is just to simulate all the \cs{..colon..} symbols from |
| 4142 |
% % \pkg{txfonts} and \pkg{pxfonts}. |
| 4143 |
% \noindent |
| 4144 |
% \textbf{2022/06/24:} Actually these were inconsistenly named in \pkg{txfonts} |
| 4145 |
% and \pkg{pxfonts}. Some was properly renamed in \pkg{newtxmath} and |
| 4146 |
% \pkg{newpxmath}, but not all. |
| 4147 |
% \begin{macrocode} |
| 4148 |
\MH_if_boolean:nTF {legacycolonsymbols}{ |
| 4149 |
\AtBeginDocument{ |
| 4150 |
\providecommand*\dblcolon{\MATHT@dblcolon} |
| 4151 |
\providecommand*\coloneqq{\MATHT@coloneq} |
| 4152 |
\providecommand*\Coloneqq{\MATHT@dblcoloneq} |
| 4153 |
\providecommand*\coloneq{\MATHT@colondash} |
| 4154 |
\providecommand*\Coloneq{\MATHT@dblcolondash} |
| 4155 |
\providecommand*\eqqcolon{\MATHT@eqcolon} |
| 4156 |
\providecommand*\Eqqcolon{\MATHT@eqdblcolon} |
| 4157 |
\providecommand*\eqcolon{\MATHT@dashcolon} |
| 4158 |
\providecommand*\Eqcolon{\MATHT@dashdblcolon} |
| 4159 |
\providecommand*\colonapprox{\MATHT@colonapprox} |
| 4160 |
\providecommand*\Colonapprox{\MATHT@dblcolonapprox} |
| 4161 |
\providecommand*\colonsim{\MATHT@colonsim} |
| 4162 |
\providecommand*\Colonsim{\MATHT@dblcolonsim} |
| 4163 |
% new |
| 4164 |
\providecommand*\approxcolon{\MATHT@approxcolon} |
| 4165 |
\providecommand*\Approxcolon{\MATHT@approxdblcolon} |
| 4166 |
\providecommand*\simcolon{\MATHT@simcolon} |
| 4167 |
\providecommand*\Simcolon{\MATHT@simdblcolon} |
| 4168 |
\providecommand*\colondash{\MATHT@colondash} |
| 4169 |
\providecommand*\Colondash{\MATHT@dblcolondash} |
| 4170 |
\providecommand*\dashcolon{\MATHT@dashcolon} |
| 4171 |
\providecommand*\Dashcolon{\MATHT@dashdblcolon} |
| 4172 |
} |
| 4173 |
}{ |
| 4174 |
\AtBeginDocument{ |
| 4175 |
\providecommand*\dblcolon{\MATHT@dblcolon} |
| 4176 |
\providecommand*\coloneqq{\MATHT@coloneq} % duplet |
| 4177 |
\providecommand*\Coloneqq{\MATHT@dblcoloneq}% duplet |
| 4178 |
\providecommand*\coloneq{\MATHT@coloneq} % changed |
| 4179 |
\providecommand*\Coloneq{\MATHT@dblcoloneq} % changed |
| 4180 |
\providecommand*\eqqcolon{\MATHT@eqcolon} % duplet |
| 4181 |
\providecommand*\Eqqcolon{\MATHT@eqdblcolon}% duplet |
| 4182 |
\providecommand*\eqcolon{\MATHT@eqcolon} % changed |
| 4183 |
\providecommand*\Eqcolon{\MATHT@eqdblcolon} % changed |
| 4184 |
\providecommand*\colonapprox{\MATHT@colonapprox} |
| 4185 |
\providecommand*\Colonapprox{\MATHT@dblcolonapprox} |
| 4186 |
\providecommand*\colonsim{\MATHT@colonsim} |
| 4187 |
\providecommand*\Colonsim{\MATHT@dblcolonsim} |
| 4188 |
% new |
| 4189 |
\providecommand*\approxcolon{\MATHT@approxcolon} |
| 4190 |
\providecommand*\Approxcolon{\MATHT@approxdblcolon} |
| 4191 |
\providecommand*\simcolon{\MATHT@simcolon} |
| 4192 |
\providecommand*\Simcolon{\MATHT@simdblcolon} |
| 4193 |
\providecommand*\colondash{\MATHT@colondash} |
| 4194 |
\providecommand*\Colondash{\MATHT@dblcolondash} |
| 4195 |
\providecommand*\dashcolon{\MATHT@dashcolon} |
| 4196 |
\providecommand*\Dashcolon{\MATHT@dashdblcolon} |
| 4197 |
} |
| 4198 |
} |
| 4199 |
% \end{macrocode} |
| 4200 |
% \end{macro} |
| 4201 |
% \end{macro} |
| 4202 |
% \end{macro} |
| 4203 |
% \end{macro} |
| 4204 |
% \end{macro} |
| 4205 |
% \end{macro} |
| 4206 |
% \end{macro} |
| 4207 |
% \end{macro} |
| 4208 |
% \end{macro} |
| 4209 |
% \end{macro} |
| 4210 |
% \end{macro} |
| 4211 |
% \end{macro} |
| 4212 |
% \end{macro} |
| 4213 |
% |
| 4214 |
% |
| 4215 |
% \subsection{Multlined} |
| 4216 |
% |
| 4217 |
% \begin{macro}{\g_MT_multlinerow_int} |
| 4218 |
% \begin{macro}{\l_MT_multwidth_dim} |
| 4219 |
% Helpers. |
| 4220 |
% \begin{macrocode} |
| 4221 |
\let \AMS@math@cr@@ \math@cr@@ |
| 4222 |
\MH_new_boolean:n {mult_firstline} |
| 4223 |
\MH_new_boolean:n {outer_mult} |
| 4224 |
\newcount\g_MT_multlinerow_int |
| 4225 |
\newdimen\l_MT_multwidth_dim |
| 4226 |
% \end{macrocode} |
| 4227 |
% \end{macro} |
| 4228 |
% \end{macro} |
| 4229 |
% \begin{macro}{\MT_test_for_tcb_other:nnnnn} |
| 4230 |
% This tests if the token(s) is/are equal to either t, c, or~b, or |
| 4231 |
% something entirely different. |
| 4232 |
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} |
| 4233 |
% \begin{macrocode} |
| 4234 |
\newcommand*\MT_test_for_tcb_other:nnnnn [1]{ |
| 4235 |
\MH_if:w t#1\relax |
| 4236 |
\expandafter\MH_use_choice_i:nnnn |
| 4237 |
\MH_else: |
| 4238 |
\MH_if:w c#1\relax |
| 4239 |
\expandafter\expandafter\expandafter\MH_use_choice_ii:nnnn |
| 4240 |
\MH_else: |
| 4241 |
\MH_if:w b#1\relax |
| 4242 |
\expandafter\expandafter\expandafter |
| 4243 |
\expandafter\expandafter\expandafter\expandafter |
| 4244 |
\MH_use_choice_iii:nnnn |
| 4245 |
\MH_else: |
| 4246 |
\expandafter\expandafter\expandafter |
| 4247 |
\expandafter\expandafter\expandafter\expandafter |
| 4248 |
\MH_use_choice_iv:nnnn |
| 4249 |
\MH_fi: |
| 4250 |
\MH_fi: |
| 4251 |
\MH_fi: |
| 4252 |
} |
| 4253 |
% \end{macrocode} |
| 4254 |
% \end{macro} |
| 4255 |
% \begin{macro}{\MT_mult_invisible_line:} |
| 4256 |
% An invisible line. |
| 4257 |
% \textbf{BUG:} \cs{baselineskip} is zero inside an array or matrix, |
| 4258 |
% thus in those cases the line is \emph{not} invisible. |
| 4259 |
% \changes{v1.14}{2014/05/21}{Added -\cs{jot}} |
| 4260 |
% \changes{v1.19}{2017/05/24}{Removed -\cs{jot} again, do not |
| 4261 |
% remember why we added it in the first place} |
| 4262 |
% \begin{macrocode} |
| 4263 |
\def\MT_mult_invisible_line: { |
| 4264 |
\crcr |
| 4265 |
\global\MH_set_boolean_F:n {mult_firstline} |
| 4266 |
\hbox to \l_MT_multwidth_dim{}\crcr |
| 4267 |
\noalign{\vskip-\baselineskip \vskip-\normallineskip} |
| 4268 |
} |
| 4269 |
% \end{macrocode} |
| 4270 |
% \end{macro} |
| 4271 |
% \begin{macro}{\MT_mult_mathcr_atat:w} |
| 4272 |
% The normal \cs{math@cr@@} with our hooks. |
| 4273 |
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} |
| 4274 |
% \begin{macrocode} |
| 4275 |
\def\MT_mult_mathcr_atat:w [#1]{% |
| 4276 |
\MH_if_num:w 0=`{\MH_fi: \iffalse}\MH_fi: |
| 4277 |
\MH_if_boolean:nT {mult_firstline}{ |
| 4278 |
\kern\l_MT_mult_left_fdim |
| 4279 |
\MT_mult_invisible_line: |
| 4280 |
} |
| 4281 |
\crcr |
| 4282 |
\noalign{\vskip#1\relax} |
| 4283 |
\global\advance\g_MT_multlinerow_int\@ne |
| 4284 |
\MH_if_num:w \g_MT_multlinerow_int=\l_MT_multline_lastline_fint |
| 4285 |
\MH_let:NwN \math@cr@@\MT_mult_last_mathcr:w |
| 4286 |
\MH_fi: |
| 4287 |
} |
| 4288 |
% \end{macrocode} |
| 4289 |
% \end{macro} |
| 4290 |
% \begin{macro}{\MT_mult_firstandlast_mathcr:w} |
| 4291 |
% The special case where there is a two-line \env{multlined}. We |
| 4292 |
% insert the first kern, then the invisible line of the desired |
| 4293 |
% width, the optional vertical space and then the last kern. |
| 4294 |
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} |
| 4295 |
% \begin{macrocode} |
| 4296 |
\def\MT_mult_firstandlast_mathcr:w [#1]{% |
| 4297 |
\MH_if_num:w 0=`{\MH_fi: \iffalse}\MH_fi: |
| 4298 |
\kern\l_MT_mult_left_fdim |
| 4299 |
\MT_mult_invisible_line: |
| 4300 |
\noalign{\vskip#1\relax} |
| 4301 |
\kern\l_MT_mult_right_fdim |
| 4302 |
} |
| 4303 |
% \end{macrocode} |
| 4304 |
% \end{macro} |
| 4305 |
% \begin{macro}{\MT_mult_last_mathcr:w} |
| 4306 |
% The normal last \cs{math@cr@@} which inserts the last kern. |
| 4307 |
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} |
| 4308 |
% \begin{macrocode} |
| 4309 |
\def\MT_mult_last_mathcr:w [#1]{ |
| 4310 |
\MH_if_num:w 0=`{\MH_fi: \iffalse}\MH_fi:\math@cr@@@ |
| 4311 |
\noalign{\vskip#1\relax} |
| 4312 |
\kern\l_MT_mult_right_fdim} |
| 4313 |
% \end{macrocode} |
| 4314 |
% \end{macro} |
| 4315 |
% \begin{macro}{\MT_start_mult:N} |
| 4316 |
% Setup for \env{multlined}. Finds the position. |
| 4317 |
% \begin{macrocode} |
| 4318 |
\newcommand\MT_start_mult:N [1]{ |
| 4319 |
\MT_test_for_tcb_other:nnnnn {#1} |
| 4320 |
{ \MH_let:NwN \MT_next:\vtop } |
| 4321 |
{ \MH_let:NwN \MT_next:\vcenter } |
| 4322 |
{ \MH_let:NwN \MT_next:\vbox } |
| 4323 |
{ |
| 4324 |
\PackageError{mathtools} |
| 4325 |
{Invalid~ position~ specifier.~ I'll~ try~ to~ recover~ with~ |
| 4326 |
`c'}\@ehc |
| 4327 |
} |
| 4328 |
\collect@body\MT_mult_internal:n |
| 4329 |
} |
| 4330 |
% \end{macrocode} |
| 4331 |
% \end{macro} |
| 4332 |
% \begin{macro}{\MT_shoveright:wn} |
| 4333 |
% \begin{macro}{\MT_shoveleft:wn} |
| 4334 |
% Extended versions of \cs{shoveleft} and \cs{shoveright}. |
| 4335 |
% \begin{macrocode} |
| 4336 |
\newcommand*\MT_shoveright:wn [2][0pt]{% |
| 4337 |
#2\hfilneg |
| 4338 |
\setlength\@tempdima{#1} |
| 4339 |
\kern\@tempdima |
| 4340 |
} |
| 4341 |
\newcommand*\MT_shoveleft:wn [2][0pt]{% |
| 4342 |
\hfilneg |
| 4343 |
\setlength\@tempdima{#1} |
| 4344 |
\kern\@tempdima |
| 4345 |
#2 |
| 4346 |
} |
| 4347 |
% \end{macrocode} |
| 4348 |
% \end{macro} |
| 4349 |
% \end{macro} |
| 4350 |
% \begin{macro}{\MT_mult_internal:n} |
| 4351 |
% \changes{v1.01a}{2004/10/10}{Added Ord atom to beginning of each line} |
| 4352 |
% The real internal \env{multlined}. |
| 4353 |
% \changes{v1.19}{2017/05/22}{Added \cs{alignedspace@left} instead of |
| 4354 |
% \cs{null}\cs{,}} |
| 4355 |
% \begin{macrocode} |
| 4356 |
\newcommand*\MT_mult_internal:n [1]{ |
| 4357 |
\MH_if_boolean:nF {outer_mult}{\alignedspace@left} %<-- requires amsmath 2016/11/05 |
| 4358 |
\MT_next: |
| 4359 |
\bgroup |
| 4360 |
% \end{macrocode} |
| 4361 |
% Restore the meaning of \cmd{\\} inside \env{multlined}, else it |
| 4362 |
% wouldn't work in the \env{equation} environment. Set the fake row |
| 4363 |
% counter to zero. |
| 4364 |
% \begin{macrocode} |
| 4365 |
\Let@ |
| 4366 |
\def\l_MT_multline_lastline_fint{0 } |
| 4367 |
\chardef\dspbrk@context\@ne \restore@math@cr |
| 4368 |
% \end{macrocode} |
| 4369 |
% Use private versions. |
| 4370 |
% \begin{macrocode} |
| 4371 |
\MH_let:NwN \math@cr@@\MT_mult_mathcr_atat:w |
| 4372 |
\MH_let:NwN \shoveleft\MT_shoveleft:wn |
| 4373 |
\MH_let:NwN \shoveright\MT_shoveright:wn |
| 4374 |
\spread@equation |
| 4375 |
\MH_set_boolean_F:n {mult_firstline} |
| 4376 |
% \end{macrocode} |
| 4377 |
% Do some measuring. |
| 4378 |
% \begin{macrocode} |
| 4379 |
\MT_measure_mult:n {#1} |
| 4380 |
% \end{macrocode} |
| 4381 |
% Make sure the box is wide enough. |
| 4382 |
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} |
| 4383 |
% \begin{macrocode} |
| 4384 |
\MH_if_dim:w \l_MT_multwidth_dim<\l_MT_multline_measure_fdim |
| 4385 |
\MH_setlength:dn \l_MT_multwidth_dim{\l_MT_multline_measure_fdim} |
| 4386 |
\fi |
| 4387 |
\MH_set_boolean_T:n {mult_firstline} |
| 4388 |
% \end{macrocode} |
| 4389 |
% Tricky bit: If we only encountered one \cmd{\\} then use a very |
| 4390 |
% special \cs{math@cr@@} that inserts everything needed. |
| 4391 |
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} |
| 4392 |
% \begin{macrocode} |
| 4393 |
\MH_if_num:w \l_MT_multline_lastline_fint=\@ne |
| 4394 |
\MH_let:NwN \math@cr@@ \MT_mult_firstandlast_mathcr:w |
| 4395 |
\MH_fi: |
| 4396 |
% \end{macrocode} |
| 4397 |
% Do the typesetting. |
| 4398 |
% \begin{macrocode} |
| 4399 |
\ialign\bgroup |
| 4400 |
\hfil\strut@$\m@th\displaystyle{}##$\hfil |
| 4401 |
\crcr |
| 4402 |
\hfilneg |
| 4403 |
#1 |
| 4404 |
} |
| 4405 |
% \end{macrocode} |
| 4406 |
% \end{macro} |
| 4407 |
% \begin{macro}{\MT_measure_mult:n} |
| 4408 |
% \changes{v1.01a}{2004/10/10}{Added Ord atom to beginning of each line} |
| 4409 |
% Measuring. Disable all labelling and check the number of lines. |
| 4410 |
% \changes{v1.18}{2015/11/12}{Added \cs{measuring@true} inside the |
| 4411 |
% \env{multlined}} |
| 4412 |
% \begin{macrocode} |
| 4413 |
\newcommand\MT_measure_mult:n [1]{ |
| 4414 |
\begingroup |
| 4415 |
\measuring@true |
| 4416 |
\g_MT_multlinerow_int\@ne |
| 4417 |
\MH_let:NwN \label\MT_gobblelabel:w |
| 4418 |
\MH_let:NwN \tag\gobble@tag |
| 4419 |
\setbox\z@\vbox{ |
| 4420 |
\ialign{\strut@$\m@th\displaystyle{}##$ |
| 4421 |
\crcr |
| 4422 |
#1 |
| 4423 |
\crcr |
| 4424 |
} |
| 4425 |
} |
| 4426 |
\xdef\l_MT_multline_measure_fdim{\the\wdz@} |
| 4427 |
\advance\g_MT_multlinerow_int\m@ne |
| 4428 |
\xdef\l_MT_multline_lastline_fint{\number\g_MT_multlinerow_int} |
| 4429 |
\endgroup |
| 4430 |
\g_MT_multlinerow_int\@ne |
| 4431 |
} |
| 4432 |
% \end{macrocode} |
| 4433 |
% \end{macro} |
| 4434 |
% \begin{macro}{\MT_multlined_second_arg:w} |
| 4435 |
% Scan for a second optional argument. |
| 4436 |
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} |
| 4437 |
% \begin{macrocode} |
| 4438 |
\MaybeMHPrecedingSpacesOff |
| 4439 |
\newcommand*\MT_multlined_second_arg:w [1][\@empty]{ |
| 4440 |
\MT_test_for_tcb_other:nnnnn {#1} |
| 4441 |
{\def\MT_mult_default_pos:{#1}} |
| 4442 |
{\def\MT_mult_default_pos:{#1}} |
| 4443 |
{\def\MT_mult_default_pos:{#1}} |
| 4444 |
{ |
| 4445 |
\MH_if_meaning:NN \@empty#1\@empty |
| 4446 |
\MH_else: |
| 4447 |
\setlength \l_MT_multwidth_dim{#1} |
| 4448 |
\MH_fi: |
| 4449 |
} |
| 4450 |
\MT_start_mult:N \MT_mult_default_pos: |
| 4451 |
} |
| 4452 |
% \end{macrocode} |
| 4453 |
% \end{macro} |
| 4454 |
% |
| 4455 |
% \begin{macro}{\MultlinedHook} |
| 4456 |
% \changes{v1.18}{2015/11/12}{Added this hook} |
| 4457 |
% Due to the methods used by \env{multlined}, some constructions may |
| 4458 |
% fail. We already know that \env{multlined} does not work well inside |
| 4459 |
% arrays or matrices. Be things used inside \cs{multlined} may also |
| 4460 |
% fail. Thus we provide a hook that can be added to in order to make |
| 4461 |
% redefinitions of these constructions when used inside |
| 4462 |
% \env{multlined}. The default value include a fix to \env{subarray} |
| 4463 |
% and thus \cs{substack}. The fix to this environment was suggested by |
| 4464 |
% Ulrike Fisher, \url{http://chat.stackexchange.com/transcript/message/25105970#25105970} |
| 4465 |
% \changes{v1.22}{2019/07/22}{Also added crampedsubarray} |
| 4466 |
% \changes{v1.22}{2019/07/22}{Also added fixes for smallmatrix and the |
| 4467 |
% MT versions of these} |
| 4468 |
% \changes{v1.26}{2021/03/27}{We need a lualatex branch of this as |
| 4469 |
% well. We need to find a better way to manage this. Patching?} |
| 4470 |
% \begin{macrocode} |
| 4471 |
\ifx\directlua\@undefined |
| 4472 |
% THIS IS NORMAL |
| 4473 |
\newcommand\MultlinedHook{ |
| 4474 |
\renewenvironment{subarray}[1]{% |
| 4475 |
\vcenter\bgroup |
| 4476 |
\Let@ \restore@math@cr \default@tag |
| 4477 |
\let\math@cr@@\AMS@math@cr@@ % <--- the fix |
| 4478 |
\baselineskip\fontdimen10 \scriptfont\tw@ |
| 4479 |
\advance\baselineskip\fontdimen12 \scriptfont\tw@ |
| 4480 |
\lineskip\thr@@\fontdimen8 \scriptfont\thr@@ |
| 4481 |
\lineskiplimit\lineskip |
| 4482 |
\ialign\bgroup\ifx c##1\hfil\fi |
| 4483 |
$\m@th\scriptstyle####$\hfil\crcr |
| 4484 |
}{% |
| 4485 |
\crcr\egroup\egroup |
| 4486 |
} |
| 4487 |
\renewenvironment{crampedsubarray}[1]{% |
| 4488 |
\vcenter\bgroup |
| 4489 |
\Let@ \restore@math@cr \default@tag |
| 4490 |
\let\math@cr@@\AMS@math@cr@@ % <--- the fix |
| 4491 |
\baselineskip\fontdimen10 \scriptfont\tw@ |
| 4492 |
\advance\baselineskip\fontdimen12 \scriptfont\tw@ |
| 4493 |
\lineskip\thr@@\fontdimen8 \scriptfont\thr@@ |
| 4494 |
\lineskiplimit\lineskip |
| 4495 |
\ialign\bgroup\ifx c##1\hfil\fi |
| 4496 |
% \end{macrocode} |
| 4497 |
% \changes{v1.25}{2021/03/18}{use \cs{MT_cramped_internal:Nn} instead, |
| 4498 |
% see issue \#17} |
| 4499 |
% Here we should use the proper cramped internal macro |
| 4500 |
% \begin{macrocode} |
| 4501 |
\span\MT_cramped_internal:Nn \scriptstyle {####}% |
| 4502 |
\hfil\crcr |
| 4503 |
}{% |
| 4504 |
\crcr\egroup\egroup |
| 4505 |
} |
| 4506 |
% from mathtools |
| 4507 |
\def\MT_smallmatrix_begin:N ##1{% |
| 4508 |
\Let@\restore@math@cr\default@tag |
| 4509 |
\let\math@cr@@\AMS@math@cr@@ % <--- the fix |
| 4510 |
\baselineskip6\ex@ \lineskip1.5\ex@ \lineskiplimit\lineskip |
| 4511 |
\csname MT_smallmatrix_##1_begin:\endcsname |
| 4512 |
} |
| 4513 |
% from amsmath |
| 4514 |
\renewenvironment{smallmatrix}{\null\,\vcenter\bgroup |
| 4515 |
\Let@\restore@math@cr\default@tag |
| 4516 |
\let\math@cr@@\AMS@math@cr@@ % <--- the fix |
| 4517 |
\baselineskip6\ex@ \lineskip1.5\ex@ \lineskiplimit\lineskip |
| 4518 |
\ialign\bgroup\hfil$\m@th\scriptstyle####$\hfil&&\thickspace\hfil |
| 4519 |
$\m@th\scriptstyle####$\hfil\crcr |
| 4520 |
}{% |
| 4521 |
\crcr\egroup\egroup\,% |
| 4522 |
} |
| 4523 |
} |
| 4524 |
\else |
| 4525 |
% \end{macrocode} |
| 4526 |
% The LuaLaTeX version, only difference is the definition of crampedsubarray |
| 4527 |
% \begin{macrocode} |
| 4528 |
% THIS IS LUALATEX |
| 4529 |
\newcommand\MultlinedHook{ |
| 4530 |
% from amsmath |
| 4531 |
% \end{macrocode} |
| 4532 |
% \changes{1.27}{2021/04/12}{need to be \cs{renewenvironment}} |
| 4533 |
% \begin{macrocode} |
| 4534 |
\renewenvironment{subarray}[1]{% |
| 4535 |
\vcenter\bgroup |
| 4536 |
\Let@ \restore@math@cr \default@tag |
| 4537 |
\let\math@cr@@\AMS@math@cr@@ % <--- the fix |
| 4538 |
\baselineskip \Umathstacknumup \scriptstyle |
| 4539 |
\advance\baselineskip \Umathstackdenomdown \scriptstyle |
| 4540 |
\lineskip \Umathstackvgap \scriptstyle |
| 4541 |
\lineskiplimit \lineskip |
| 4542 |
\ialign\bgroup\ifx c##1\hfil\fi |
| 4543 |
\Ustartmath |
| 4544 |
\m@th\scriptstyle#### |
| 4545 |
\Ustopmath |
| 4546 |
\hfil\crcr |
| 4547 |
}{% |
| 4548 |
\crcr\egroup\egroup |
| 4549 |
} |
| 4550 |
% from mathtools |
| 4551 |
% \end{macrocode} |
| 4552 |
% \changes{1.27}{2021/04/12}{need to be \cs{renewenvironment}} |
| 4553 |
% \begin{macrocode} |
| 4554 |
\renewenvironment{crampedsubarray}[1]{% |
| 4555 |
\vcenter\bgroup |
| 4556 |
\Let@ \restore@math@cr \default@tag |
| 4557 |
\let\math@cr@@\AMS@math@cr@@ % <--- the fix |
| 4558 |
\baselineskip \Umathstacknumup \scriptstyle |
| 4559 |
\advance\baselineskip \Umathstackdenomdown \scriptstyle |
| 4560 |
\lineskip \Umathstackvgap \scriptstyle |
| 4561 |
\lineskiplimit \lineskip |
| 4562 |
\ialign\bgroup\ifx c##1\hfil\fi |
| 4563 |
\Ustartmath |
| 4564 |
\crampedscriptstyle{####} |
| 4565 |
\Ustopmath |
| 4566 |
\hfil\crcr |
| 4567 |
}{% |
| 4568 |
\crcr\egroup\egroup |
| 4569 |
} |
| 4570 |
% from mathtools |
| 4571 |
\def\MT_smallmatrix_begin:N ##1{% |
| 4572 |
\Let@\restore@math@cr\default@tag |
| 4573 |
\let\math@cr@@\AMS@math@cr@@ % <--- the fix |
| 4574 |
\baselineskip6\ex@ \lineskip1.5\ex@ \lineskiplimit\lineskip |
| 4575 |
\csname MT_smallmatrix_##1_begin:\endcsname |
| 4576 |
} |
| 4577 |
% from amsmath |
| 4578 |
\renewenvironment{smallmatrix}{\null\,\vcenter\bgroup |
| 4579 |
\Let@\restore@math@cr\default@tag |
| 4580 |
\let\math@cr@@\AMS@math@cr@@ % <--- the fix |
| 4581 |
\baselineskip6\ex@ \lineskip1.5\ex@ \lineskiplimit\lineskip |
| 4582 |
\ialign\bgroup\hfil$\m@th\scriptstyle####$\hfil&&\thickspace\hfil |
| 4583 |
$\m@th\scriptstyle####$\hfil\crcr |
| 4584 |
}{% |
| 4585 |
\crcr\egroup\egroup\,% |
| 4586 |
} |
| 4587 |
} |
| 4588 |
\fi |
| 4589 |
|
| 4590 |
|
| 4591 |
% \end{macrocode} |
| 4592 |
% \end{macro} |
| 4593 |
% |
| 4594 |
% \begin{environment}{multlined} |
| 4595 |
% The user environment. Scan for an optional argument. |
| 4596 |
% \changes{v1.18}{2015/11/12}{Added \cs{MultlinedHook}} |
| 4597 |
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} |
| 4598 |
% \begin{macrocode} |
| 4599 |
\newenvironment{multlined}[1][] |
| 4600 |
{\MH_group_align_safe_begin: |
| 4601 |
\MultlinedHook |
| 4602 |
\MT_test_for_tcb_other:nnnnn {#1} |
| 4603 |
{\def\MT_mult_default_pos:{#1}} |
| 4604 |
{\def\MT_mult_default_pos:{#1}} |
| 4605 |
{\def\MT_mult_default_pos:{#1}} |
| 4606 |
{ |
| 4607 |
\MH_if_meaning:NN \@empty#1\@empty |
| 4608 |
\MH_else: |
| 4609 |
\setlength \l_MT_multwidth_dim{#1} |
| 4610 |
\MH_fi: |
| 4611 |
} |
| 4612 |
\MT_multlined_second_arg:w |
| 4613 |
} |
| 4614 |
{ |
| 4615 |
\hfilneg \endaligned \MH_group_align_safe_end: |
| 4616 |
} |
| 4617 |
\MHPrecedingSpacesOn |
| 4618 |
% \end{macrocode} |
| 4619 |
% \end{environment} |
| 4620 |
% The keys needed. |
| 4621 |
% \begin{macrocode} |
| 4622 |
\define@key{\MT_options_name:} |
| 4623 |
{firstline-afterskip}{\def\l_MT_mult_left_fdim{#1}} |
| 4624 |
\define@key{\MT_options_name:} |
| 4625 |
{lastline-preskip}{\def\l_MT_mult_right_fdim{#1}} |
| 4626 |
\define@key{\MT_options_name:} |
| 4627 |
{multlined-width}{\setlength \l_MT_multwidth_dim{#1}} |
| 4628 |
\define@key{\MT_options_name:} |
| 4629 |
{multlined-pos}{\def\MT_mult_default_pos:{#1}} |
| 4630 |
\setkeys{\MT_options_name:}{ |
| 4631 |
firstline-afterskip=\multlinegap, |
| 4632 |
lastline-preskip=\multlinegap, |
| 4633 |
multlined-width=0pt, |
| 4634 |
multlined-pos=c, |
| 4635 |
} |
| 4636 |
% \end{macrocode} |
| 4637 |
% \begin{macro}{\MT_gobblelabel:w} |
| 4638 |
% Better than to assume that \cs{label} has exactly one mandatory |
| 4639 |
% argument, hence the \texttt{w} specifier. |
| 4640 |
% \begin{macrocode} |
| 4641 |
\def\MT_gobblelabel:w #1{} |
| 4642 |
% \end{macrocode} |
| 4643 |
% \end{macro} |
| 4644 |
% |
| 4645 |
% |
| 4646 |
% |
| 4647 |
% |
| 4648 |
% \section{Macros suggested/requested by Lars Madsen} |
| 4649 |
% |
| 4650 |
% The macros in this section are all requests made by Lars Madsen. |
| 4651 |
% |
| 4652 |
% \subsection{Paired delimiters} |
| 4653 |
% |
| 4654 |
% \changes{v1.13}{2012/05/10}{Extended \cs{DeclarePairedDelimiter(X)}} |
| 4655 |
% \begin{macro}{\MT_delim_default_inner_wrappers:n} |
| 4656 |
% In some cases users may want to control the internals a bit more. We |
| 4657 |
% therefore create two call back macros each time the |
| 4658 |
% \cs{DeclarePaired...} macro is issued. The default value of these |
| 4659 |
% call backs are provided by |\MT_delim_default_inner_wrappers:n| |
| 4660 |
% \begin{macrocode} |
| 4661 |
\newcommand\MT_delim_default_inner_wrappers:n [1]{ |
| 4662 |
\@namedef{MT_delim_\MH_cs_to_str:N #1 _star_wrapper:nnn}##1##2##3{ |
| 4663 |
\mathopen{}\mathclose\bgroup ##1 ##2 \aftergroup\egroup ##3 |
| 4664 |
} |
| 4665 |
% \end{macrocode} |
| 4666 |
% Turns out that there is a difference between \verb|\mathclose{)}| |
| 4667 |
% and \verb|\mathclose)| (placement of for example superscript), so instead of two wrappers, we need three. |
| 4668 |
% \changes{v1.19}{2017/05/22}{added \cs{...nostarnonscaled..} wrapper} |
| 4669 |
% \changes{v1.19}{2017/05/22}{renamed \cs{...nostar..} to \cs{...nostarscaled..} } |
| 4670 |
% \begin{macrocode} |
| 4671 |
\@namedef{MT_delim_\MH_cs_to_str:N #1 _nostarscaled_wrapper:nnn}##1##2##3{ |
| 4672 |
\mathopen{##1}##2\mathclose{##3} |
| 4673 |
} |
| 4674 |
% \end{macrocode} |
| 4675 |
% \changes{v1.30}{2024/01/18}{Changed the nostarnonscaled to support the empty scaler (dot).} |
| 4676 |
% If we want to support the empty scaler (dot) we need a test in the non-scaled case, otherwise a dot would be left in the output. |
| 4677 |
% Test sugggested by David Carlisle. |
| 4678 |
% \begin{macrocode} |
| 4679 |
\@namedef{MT_delim_\MH_cs_to_str:N #1 _nostarnonscaled_wrapper:nnn}##1##2##3{ |
| 4680 |
\ifx.##1\else\mathopen##1\fi##2\ifx.##3\else\mathclose##3\fi |
| 4681 |
} |
| 4682 |
} |
| 4683 |
|
| 4684 |
% \end{macrocode} |
| 4685 |
% \end{macro} |
| 4686 |
% |
| 4687 |
% \begin{macro}{\reDeclarePairedDelimiterInnerWrapper} |
| 4688 |
% Macro enabling the user to alter an existing call back. First |
| 4689 |
% argument is the name of the macro we are altering (as defined via |
| 4690 |
% \cs{DeclarePaired...}), the second is \texttt{star}, |
| 4691 |
% \texttt{nostarnonscaled} or \texttt{nostarscaled}. In the last |
| 4692 |
% argument \texttt{\#1} and \texttt{\#3} respectively refer to the |
| 4693 |
% scaled fences and \texttt{\#2} refer to whatever come between. |
| 4694 |
% \changes{v1.19}{2017/05/23}{Added a test and error} |
| 4695 |
% \begin{macrocode} |
| 4696 |
\newcommand\reDeclarePairedDelimiterInnerWrapper[3]{ |
| 4697 |
\@ifundefined{MT_delim_\MH_cs_to_str:N #1 _ #2 _wrapper:nnn}{ |
| 4698 |
\PackageError{mathtools}{ |
| 4699 |
Wrapper~not~found~for~\string#1~and~option~'#2'.\MessageBreak |
| 4700 |
Either~\string#1~is~ not~ defined,~or~ you~ are~using~ the~ |
| 4701 |
\MessageBreak |
| 4702 |
'nostar'~ option,~which~ is~ no~ longer~ supported.~ |
| 4703 |
\MessageBreak |
| 4704 |
Please~ use~ 'nostarnonscaled'~ or~ 'nostarscaled~ |
| 4705 |
\MessageBreak instead.~ |
| 4706 |
}{See the manual} |
| 4707 |
}{ |
| 4708 |
\@namedef{MT_delim_\MH_cs_to_str:N #1 _ #2 _wrapper:nnn}##1##2##3{ |
| 4709 |
#3 |
| 4710 |
} |
| 4711 |
} |
| 4712 |
} |
| 4713 |
|
| 4714 |
% \end{macrocode} |
| 4715 |
% |
| 4716 |
% \begin{macro}{\MT_etb_ifdefempty_x:nnn} |
| 4717 |
% \begin{macro}{\MT_etb_ifblank:nnn} |
| 4718 |
% \changes{v1.19}{2017/05/23}{Added so we can test for empty args} |
| 4719 |
% This is a copy of \cs{etb@ifdefempty} (it is \emph{not} the same |
| 4720 |
% as \cs{ifdefempty}) and \cs{ifblank} from \pkg{etoolbox}, |
| 4721 |
% currently we do not want to make \pkg{etoolbox} a requirement, |
| 4722 |
% that may change in the future. We need a reliable method to check |
| 4723 |
% whether a macro is blank or not (including spaces). |
| 4724 |
% \begin{macrocode} |
| 4725 |
\def\MT_etb_ifdefempty_x:nnn #1{ |
| 4726 |
\expandafter\expandafter\expandafter |
| 4727 |
\MT_etb_ifblank:nnn |
| 4728 |
\expandafter\expandafter\expandafter{% |
| 4729 |
\expandafter\strip@prefix\meaning#1} |
| 4730 |
} |
| 4731 |
\def\MT_etb_ifblank:nnn #1{ |
| 4732 |
\expandafter\ifx\expandafter\relax\detokenize\expandafter{\@gobble#1?}\relax |
| 4733 |
\expandafter\@firstoftwo |
| 4734 |
\else |
| 4735 |
\expandafter\@secondoftwo |
| 4736 |
\fi |
| 4737 |
} |
| 4738 |
|
| 4739 |
|
| 4740 |
% \end{macrocode} |
| 4741 |
% \end{macro} |
| 4742 |
% \end{macro} |
| 4743 |
% % |
| 4744 |
% |
| 4745 |
% \end{macro} |
| 4746 |
% \begin{macro}{\DeclarePairedDelimiter} |
| 4747 |
% \changes{v1.06}{2008/08/01}{Made user command robust} |
| 4748 |
% This macro defines |#1| to be a control sequence that takes either |
| 4749 |
% a star or an optional argument and one mandatory argument. |
| 4750 |
% \begin{macrocode} |
| 4751 |
\newcommand*\DeclarePairedDelimiter[3]{% |
| 4752 |
\@ifdefinable{#1}{ |
| 4753 |
% \end{macrocode} |
| 4754 |
% Define the starred command to just put \cs{left} and \cs{right} |
| 4755 |
% before the delimiters, wrapped in a callback function. |
| 4756 |
% \changes{1.08e}{2010/09/02}{`Fixed' \cs{left}\dots\cs{right} bad spacing} |
| 4757 |
% \changes{1.08e}{2010/09/14}{redid the \cs{left}\dots\cs{right} fix, |
| 4758 |
% see \cs{DeclarePairedDelimiterXPP} for details.} |
| 4759 |
% \changes{v1.13}{2012/05/10}{Using call back instead} |
| 4760 |
% \begin{macrocode} |
| 4761 |
\MT_delim_default_inner_wrappers:n{#1} % define the wrappers |
| 4762 |
\@namedef{MT_delim_\MH_cs_to_str:N #1 _star:}##1 |
| 4763 |
{ \@nameuse{MT_delim_\MH_cs_to_str:N #1 _star_wrapper:nnn}% |
| 4764 |
{\left#2}{##1}{\right#3} }% |
| 4765 |
% \end{macrocode} |
| 4766 |
% The command with optional argument. It should be \cs{bigg} or |
| 4767 |
% alike. |
| 4768 |
% \begin{macrocode} |
| 4769 |
\@xp\@xp\@xp |
| 4770 |
\newcommand |
| 4771 |
\@xp\csname MT_delim_\MH_cs_to_str:N #1 _nostar:\endcsname |
| 4772 |
[2][\\@gobble] |
| 4773 |
{ |
| 4774 |
% \end{macrocode} |
| 4775 |
% With the default optional argument we wind up with \cs{relax}, |
| 4776 |
% else we get \cs{biggr} and \cs{biggl} etc. |
| 4777 |
% \changes{v1.13}{2012/05/10}{Using call back instead} |
| 4778 |
% \changes{v1.19}{2017/05/23}{Split the wrappers in two, so know |
| 4779 |
% \cs{}\cs{@gobble} is now only used to check if the optional |
| 4780 |
% argument is empty.} |
| 4781 |
% \begin{macrocode} |
| 4782 |
\def\@tempa{\\@gobble} |
| 4783 |
\def\@tempb{##1} |
| 4784 |
\ifx\@tempa\@tempb |
| 4785 |
% \end{macrocode} |
| 4786 |
% As of May 2017, we now run explicit wrapper in the nonscaled |
| 4787 |
% version, so we can remove the feature to to add l and r version of |
| 4788 |
% the scaler (as there is none). |
| 4789 |
% \begin{macrocode} |
| 4790 |
\@nameuse{MT_delim_\MH_cs_to_str:N #1 _nostarnonscaled_wrapper:nnn}% |
| 4791 |
{#2} |
| 4792 |
{##2} |
| 4793 |
{#3} |
| 4794 |
\else |
| 4795 |
% \end{macrocode} |
| 4796 |
% Next we need to check whether \texttt{\#\#1} is blank as that |
| 4797 |
% should not be scaled |
| 4798 |
% \begin{macrocode} |
| 4799 |
\MT_etb_ifblank:nnn {##1}{ |
| 4800 |
\@nameuse{MT_delim_\MH_cs_to_str:N #1 _nostarnonscaled_wrapper:nnn}% |
| 4801 |
{#2} |
| 4802 |
{##2} |
| 4803 |
{#3} |
| 4804 |
}{ |
| 4805 |
\@nameuse{MT_delim_\MH_cs_to_str:N #1 _nostarscaled_wrapper:nnn}% |
| 4806 |
{\@nameuse {\MH_cs_to_str:N ##1 l} #2} |
| 4807 |
{##2} |
| 4808 |
{\@nameuse {\MH_cs_to_str:N ##1 r} #3} |
| 4809 |
} |
| 4810 |
\fi |
| 4811 |
} |
| 4812 |
% \end{macrocode} |
| 4813 |
% The user command comes here. Just check for the star and choose |
| 4814 |
% the right internal command. |
| 4815 |
% \begin{macrocode} |
| 4816 |
\DeclareRobustCommand{#1}{ |
| 4817 |
\@ifstar |
| 4818 |
{\@nameuse{MT_delim_\MH_cs_to_str:N #1 _star:}} |
| 4819 |
{\@nameuse{MT_delim_\MH_cs_to_str:N #1 _nostar:}} |
| 4820 |
} |
| 4821 |
} |
| 4822 |
} |
| 4823 |
% \end{macrocode} |
| 4824 |
% \end{macro} |
| 4825 |
% |
| 4826 |
% \begin{macro}{\MT_paired_delimx_arg_test:n} |
| 4827 |
% This tests the \oarg{num args} part of |
| 4828 |
% \cs{DeclarePairedDelimiterX} and \cs{DeclarePairedDelimiterXPP} |
| 4829 |
% (code reuse), and complains if it is not 1,\dots,9. |
| 4830 |
% \changes{v1.14}{2014/05/20}{Added} |
| 4831 |
% \begin{macrocode} |
| 4832 |
\def\MT_paired_delimx_arg_test:n #1{ |
| 4833 |
\ifnum#1>9\relax |
| 4834 |
\PackageError{mathtools}{No~ more~ than~ 9~ arguments}{} |
| 4835 |
\else |
| 4836 |
\ifnum#1<1\relax |
| 4837 |
\PackageError{mathtools}{Macro~ need~ 1~ or~ more~ |
| 4838 |
arguments.\MessageBreak Please~ change~ [#1]~ to~ [1]~ ... [9]}{} |
| 4839 |
\fi |
| 4840 |
\fi |
| 4841 |
} |
| 4842 |
|
| 4843 |
% \end{macrocode} |
| 4844 |
% \end{macro} |
| 4845 |
% \begin{macro}{\MT_delim_inner_generator:n..n} |
| 4846 |
% \changes{v1.19}{2017/05/14}{Macro added, changes notes in the |
| 4847 |
% implementation are taken from when this code was not factored out} |
| 4848 |
% This generates the internal macro from |
| 4849 |
% \cs{DeclarePairedDelimiterX} and \cs{DeclarePairedDelimiterXPP} |
| 4850 |
% that handles the non-starred part of the generated macro. The |
| 4851 |
% macro takes 7 arguments mimicing the arguments of |
| 4852 |
% \cs{DeclarePairedDelimiterXPP}: |
| 4853 |
% \begin{enumerate}\setlength\itemsep{0pt} |
| 4854 |
% \item external macro name |
| 4855 |
% \item number of arguments, 1-9, already checked at this stage |
| 4856 |
% \item predata |
| 4857 |
% \item left scaler |
| 4858 |
% \item right scaler |
| 4859 |
% \item postdata |
| 4860 |
% \item body |
| 4861 |
% \end{enumerate} |
| 4862 |
% |
| 4863 |
% \begin{macrocode} |
| 4864 |
\def\@MHempty{} |
| 4865 |
\newcommand\MT_delim_inner_generator:nnnnnnn [7]{ |
| 4866 |
% \end{macrocode} |
| 4867 |
% In order for the starred and non-starred version of |
| 4868 |
% \cs{DeclarePairedDelimiterX(PP)} to have the same arguments, we need |
| 4869 |
% to introduce an extra macro to catch the optional argument (this |
| 4870 |
% means that the non-starred version can actually support ten |
| 4871 |
% arguments!). Here we do things a little differently than with |
| 4872 |
% \cs{DeclarePairedDelimiter}. The optional argument have |
| 4873 |
% \cs{@MHempty} as the default. This was earlier locally redefined to |
| 4874 |
% eat l/r additions to the scaler when there were no scaler. In this |
| 4875 |
% implementation, we just look for that macro to see if no scaler has |
| 4876 |
% been given at all. |
| 4877 |
% \begin{macrocode} |
| 4878 |
\@xp\@xp\@xp |
| 4879 |
\newcommand |
| 4880 |
\@xp\csname MT_delim_\MH_cs_to_str:N #1 _nostar_inner:\endcsname |
| 4881 |
[#2] |
| 4882 |
{ |
| 4883 |
% \end{macrocode} |
| 4884 |
% Add the (possibly empty) precode: |
| 4885 |
% \begin{macrocode} |
| 4886 |
#3 |
| 4887 |
% \end{macrocode} |
| 4888 |
% Next we provide the inner workhorse. We need a bit of expansion |
| 4889 |
% magic to get \cs{delimsize} to work. |
| 4890 |
% \changes{v1.13}{2012/05/10}{Using call backs for \cs{mathopen} and |
| 4891 |
% \cs{mathclose} additions} |
| 4892 |
% \changes{v1.19}{2017/04/27}{Added resetting code for \cs{@MHempty}, |
| 4893 |
% cannot rely on groups here. 2017/05/23 removed because of reimplementation} |
| 4894 |
% |
| 4895 |
% May 2017: Due to \verb+\mathclose{|}^2+ generally not being equal to |
| 4896 |
% \verb+\mathclose|^2+ we needed to split the wrapper macro into |
| 4897 |
% separate nonscaled and scaled versions. This also have the benefit |
| 4898 |
% of completely eliminating the need to gobble any chars. There is now |
| 4899 |
% the nonscaled version, which we do not add any scalers to and the |
| 4900 |
% manually scaled version where we \emph{know} there is a scaler. The |
| 4901 |
% complication is now that we need to be able to check for blank |
| 4902 |
% input, thus the including of a few macros from \pkg{etoolbox}. |
| 4903 |
% \changes{v1.19}{2017/05/23}{Split into two wrappers and some tests} |
| 4904 |
% First we need to look at \cs{delimsize} to see if it is equal to |
| 4905 |
% \cs{@MHempty}. If it is run the nonscaled version. |
| 4906 |
% \begin{macrocode} |
| 4907 |
\def\@tempa{\@MHempty} |
| 4908 |
\@xp\def\@xp\@tempb\@xp{\delimsize} |
| 4909 |
\ifx\@tempa\@tempb |
| 4910 |
\@nameuse{MT_delim_\MH_cs_to_str:N #1 _nostarnonscaled_wrapper:nnn} |
| 4911 |
{#4}{#7}{#5} |
| 4912 |
\else |
| 4913 |
% \end{macrocode} |
| 4914 |
% Next we use a copy of a macro from \pkg{etoolbox} to determine |
| 4915 |
% whether \cs{delimsize} is empty or not. This is to be sure that |
| 4916 |
% \verb|\abs[]| and similar still end up in the unscaled branch. |
| 4917 |
% \begin{macrocode} |
| 4918 |
\MT_etb_ifdefempty_x:nnn {\delimsize}{ |
| 4919 |
\@nameuse{MT_delim_\MH_cs_to_str:N #1 _nostarnonscaled_wrapper:nnn} |
| 4920 |
{#4}{#7}{#5} |
| 4921 |
}{ |
| 4922 |
% \end{macrocode} |
| 4923 |
% In the scaled version we add features to convert til scaler to its |
| 4924 |
% l/r versions. |
| 4925 |
% \begin{macrocode} |
| 4926 |
\@nameuse{MT_delim_\MH_cs_to_str:N #1 _nostarscaled_wrapper:nnn} |
| 4927 |
{ |
| 4928 |
\@xp\@xp\@xp\csname\@xp\MH_cs_to_str:N \delimsize l\endcsname #4 |
| 4929 |
} |
| 4930 |
{#7} |
| 4931 |
{ |
| 4932 |
\@xp\@xp\@xp\csname\@xp\MH_cs_to_str:N \delimsize r\endcsname #5 |
| 4933 |
} |
| 4934 |
} |
| 4935 |
\fi |
| 4936 |
% \end{macrocode} |
| 4937 |
% Add the (possibly empty) post code |
| 4938 |
% \begin{macrocode} |
| 4939 |
#6 |
| 4940 |
\endgroup |
| 4941 |
} |
| 4942 |
} |
| 4943 |
|
| 4944 |
% \end{macrocode} |
| 4945 |
% |
| 4946 |
% \end{macro} |
| 4947 |
% \begin{macro}{\DeclarePairedDelimiterXPP} |
| 4948 |
% \changes{v1.19}{2017/05/24}{Rewritten as we might as well |
| 4949 |
% implement ...X via ...XPP} It turns out it is useful to have a |
| 4950 |
% more general version of \cs{DeclarePairedDelimiter} where we can |
| 4951 |
% access the body and perhaps even add stuff on the outside of the |
| 4952 |
% fences. Historically, we added \cs{DeclarePairedDelimiterX} first, |
| 4953 |
% giving access to the body and the most general |
| 4954 |
% \cs{DeclarePairedDelimiterXPP} was requested after that, thus |
| 4955 |
% ending up with two macros so not to break existing document. As of |
| 4956 |
% May 2017, since \cs{DeclarePairedDelimiterX} is just |
| 4957 |
% \cs{DeclarePairedDelimiterXPP} with no pre- or postcode, we will |
| 4958 |
% use this update to just define \cs{DeclarePairedDelimiterXPP} and |
| 4959 |
% define \cs{DeclarePairedDelimiterX} from that. |
| 4960 |
% |
| 4961 |
% The arguments for \cs{DeclarePairedDelimiterXPP} are interpreted |
| 4962 |
% as |
| 4963 |
% \begin{center} |
| 4964 |
% \marg{macroname}\oarg{num~args}\allowbreak\marg{pre~code}\allowbreak\marg{left |
| 4965 |
% delim}\goodbreak \marg{right delim}\marg{post code}\marg{body} |
| 4966 |
% \end{center} |
| 4967 |
% Inside \marg{body} \cs{delimsize} |
| 4968 |
% refers to the current size of the scaler (\cs{middle} in the starred version). |
| 4969 |
% \begin{macrocode} |
| 4970 |
\def\DeclarePairedDelimiterXPP#1[#2]#3#4#5#6#7{% |
| 4971 |
\@ifdefinable{#1}{ |
| 4972 |
% \end{macrocode} |
| 4973 |
% The constructor takes five arguments, the name of the macro, the |
| 4974 |
% number of arguments (1-9), the left and right delimiter, the inner |
| 4975 |
% code for the two macros. First we verify that the number of arguments fit. |
| 4976 |
% \changes{v1.14}{2014/05/20}{Factored out in separate macro |
| 4977 |
% (\cs{MT_paired_delimx_arg_test:n}) for reuse. Comment refers back to |
| 4978 |
% old \cs{DeclarePairedDelimiterX} implementation.} |
| 4979 |
% \begin{macrocode} |
| 4980 |
\MT_paired_delimx_arg_test:n{#2} |
| 4981 |
% \end{macrocode} |
| 4982 |
% \changes{v1.13}{2012/05/10}{Using call back instead} |
| 4983 |
% Define the default call backs. |
| 4984 |
% \begin{macrocode} |
| 4985 |
\MT_delim_default_inner_wrappers:n{#1} |
| 4986 |
% \end{macrocode} |
| 4987 |
% We make sure to store the delimiter size in the local variable |
| 4988 |
% \cs{delimsize}. Then users can refer to the size in the \marg{body} |
| 4989 |
% argument. In the starred version it will refer to \cs{middle} and in |
| 4990 |
% the normal version it will hold the provided optional argument. |
| 4991 |
% \begin{macrocode} |
| 4992 |
\@xp\@xp\@xp |
| 4993 |
\newcommand |
| 4994 |
\@xp\csname MT_delim_\MH_cs_to_str:N #1 _star:\endcsname |
| 4995 |
[#2] |
| 4996 |
{ |
| 4997 |
\begingroup |
| 4998 |
\def\delimsize{\middle} |
| 4999 |
% \end{macrocode} |
| 5000 |
% Adding the \marg{precode} (possibly empty) |
| 5001 |
% \begin{macrocode} |
| 5002 |
#3 |
| 5003 |
% \end{macrocode} |
| 5004 |
% This is slightly controversial, \cs{left}\dots\cs{right} are known |
| 5005 |
% to produce an inner atom, thus may cause different spacing than |
| 5006 |
% normal delimiters. We `fix' this by introducing \cs{mathopen} and |
| 5007 |
% \cs{mathclose}. This change is now factored out into call backs. |
| 5008 |
% \changes{v1.08e}{2010/09/14}{redid the left/right fix, inspired by |
| 5009 |
% ctt thread named `spacing after \cs{right}) and before \cs{left})' |
| 5010 |
% started 2010-08-12.} |
| 5011 |
% \changes{v1.13}{2012/05/10}{Using call back instead} |
| 5012 |
% \begin{macrocode} |
| 5013 |
\@nameuse{MT_delim_\MH_cs_to_str:N #1 _star_wrapper:nnn} |
| 5014 |
{\left#4}{#7}{\right#5} |
| 5015 |
#6 |
| 5016 |
\endgroup |
| 5017 |
} |
| 5018 |
% \end{macrocode} |
| 5019 |
% In order for the starred and non-starred version to have the same |
| 5020 |
% arguments, we need to introduce an extra macro to catch the optional |
| 5021 |
% argument (this means that the non-starred version can actually |
| 5022 |
% support ten arguments!). |
| 5023 |
% \begin{macrocode} |
| 5024 |
\@xp\@xp\@xp |
| 5025 |
\newcommand |
| 5026 |
\@xp\csname MT_delim_\MH_cs_to_str:N #1 _nostar:\endcsname |
| 5027 |
[1][\@MHempty] |
| 5028 |
{ |
| 5029 |
% \end{macrocode} |
| 5030 |
% We need to introduce a local group in order to support nesting. It |
| 5031 |
% is ended inside \verb|\MT_delim_\MH_cs_to_str:N #1 _nostar_inner:|, |
| 5032 |
% here we also stores the scaler in \cs{delimsize}. |
| 5033 |
% \begin{macrocode} |
| 5034 |
\begingroup |
| 5035 |
\def\delimsize{##1} |
| 5036 |
\@nameuse{MT_delim_\MH_cs_to_str:N #1 _nostar_inner:} |
| 5037 |
} |
| 5038 |
% \end{macrocode} |
| 5039 |
% To make the code easier to work with we factored the next macro |
| 5040 |
% out. Since \cs{DeclarePairedDelimiterX} is now implemented via |
| 5041 |
% \cs{DeclarePairedDelimiterXPP} we did not need to. But it makes the |
| 5042 |
% code a bit simpler. \cs{MT_delim_inner_generator:nnnnnnn} just |
| 5043 |
% takes care of generating the appropriate \cs{..._nostar_inner:} macro. |
| 5044 |
% \begin{macrocode} |
| 5045 |
\MT_delim_inner_generator:nnnnnnn {#1}{#2}{#3}{#4}{#5}{#6}{#7} |
| 5046 |
% \end{macrocode} |
| 5047 |
% At the end, generate the actual user command. |
| 5048 |
% \begin{macrocode} |
| 5049 |
\DeclareRobustCommand{#1}{ |
| 5050 |
\@ifstar |
| 5051 |
{\@nameuse{MT_delim_\MH_cs_to_str:N #1 _star:}} |
| 5052 |
{\@nameuse{MT_delim_\MH_cs_to_str:N #1 _nostar:}} |
| 5053 |
} |
| 5054 |
} |
| 5055 |
} |
| 5056 |
|
| 5057 |
% \end{macrocode} |
| 5058 |
% \end{macro} |
| 5059 |
% \begin{macro}{\DeclarePairedDelimiterX} |
| 5060 |
% \changes{v1.08}{2010/06/10}{Added |
| 5061 |
% \cs{DeclarePairedDelimiterX}. 2017/05/24: old comment, kept for |
| 5062 |
% historic reasons.} |
| 5063 |
% \changes{v1.08e}{2010/09/02}{Provided better implementation of |
| 5064 |
% \cs{DeclarePairedDelimiterX}. 2017/05/24: old comment, kept for |
| 5065 |
% historic reasons.} |
| 5066 |
% As of May 2017, this is now just a call to \cs{DeclarePairedDelimiterXPP}. |
| 5067 |
% \begin{macrocode} |
| 5068 |
\def\DeclarePairedDelimiterX#1[#2]#3#4#5{ |
| 5069 |
\DeclarePairedDelimiterXPP{#1}[#2]{}{#3}{#4}{}{#5} |
| 5070 |
} |
| 5071 |
% \end{macrocode} |
| 5072 |
% \end{macro} |
| 5073 |
% |
| 5074 |
|
| 5075 |
|
| 5076 |
% |
| 5077 |
% \subsection{A \texttt{\textbackslash displaystyle} \env{cases} environment} |
| 5078 |
% |
| 5079 |
% \begin{macro}{\MT_start_cases:nnn} |
| 5080 |
% We define a single command that does all the hard work. |
| 5081 |
% \changes{v1.08}{2010/06/10}{made \cs{MT_start_cases:nnnn} more general} |
| 5082 |
% \begin{macrocode} |
| 5083 |
\def\MT_start_cases:nnnn #1#2#3#4{ % #1=sep,#2=lpreamble,#3=rpreamble,#4=delim |
| 5084 |
\RIfM@\else |
| 5085 |
\nonmatherr@{\begin{\@currenvir}} |
| 5086 |
\fi |
| 5087 |
\MH_group_align_safe_begin: |
| 5088 |
\left#4 |
| 5089 |
\vcenter \bgroup |
| 5090 |
\Let@ \chardef\dspbrk@context\@ne \restore@math@cr |
| 5091 |
\let \math@cr@@\AMS@math@cr@@ |
| 5092 |
\spread@equation |
| 5093 |
\ialign\bgroup |
| 5094 |
% \end{macrocode} |
| 5095 |
% Set the first column flush left in \cs{displaystyle} math and the |
| 5096 |
% second as specified by the second argument. The first argument is |
| 5097 |
% the separation between the columns. It could be a \cs{quad} or |
| 5098 |
% something entirely different. |
| 5099 |
% \begin{macrocode} |
| 5100 |
\strut@#2 \strut@ |
| 5101 |
#3 |
| 5102 |
\crcr |
| 5103 |
} |
| 5104 |
% \end{macrocode} |
| 5105 |
% \end{macro} |
| 5106 |
% \begin{macro}{\MH_end_cases:} |
| 5107 |
% \begin{macrocode} |
| 5108 |
\def\MH_end_cases:{\crcr\egroup |
| 5109 |
\restorecolumn@ |
| 5110 |
\egroup |
| 5111 |
\MH_group_align_safe_end: |
| 5112 |
} |
| 5113 |
% \end{macrocode} |
| 5114 |
% \end{macro} |
| 5115 |
% \begin{macro}{\newcases} |
| 5116 |
% \begin{macro}{\renewcases} |
| 5117 |
% Easy creation of new \env{cases}-like environments. |
| 5118 |
% \changes{v1.08}{2010/06/10}{changed to match the change in \cs{MT_start_cases:nnnn}} |
| 5119 |
% \begin{macrocode} |
| 5120 |
\newcommand*\newcases[6]{% #1=name, #2=sep, #3=preamble, #4=left, #5=right |
| 5121 |
\newenvironment{#1} |
| 5122 |
{\MT_start_cases:nnnn {#2}{#3}{#4}{#5}} |
| 5123 |
{\MH_end_cases:\right#6} |
| 5124 |
} |
| 5125 |
\newcommand*\renewcases[6]{ |
| 5126 |
\renewenvironment{#1} |
| 5127 |
{\MT_start_cases:nnnn {#2}{#3}{#4}{#5}} |
| 5128 |
{\MH_end_cases:\right#6} |
| 5129 |
} |
| 5130 |
% \end{macrocode} |
| 5131 |
% \begin{environment}{dcases} |
| 5132 |
% \begin{environment}{dcases*} |
| 5133 |
% \begin{environment}{rcases} |
| 5134 |
% \begin{environment}{rcases*} |
| 5135 |
% \begin{environment}{drcases} |
| 5136 |
% \begin{environment}{drcases*} |
| 5137 |
% \begin{environment}{cases*} |
| 5138 |
% \env{dcases} is a traditional cases with display style math in |
| 5139 |
% both columns, while \env{dcases*} has text in the second column. |
| 5140 |
% \changes{v1.08}{2010/06/10}{changed to match the change in |
| 5141 |
% \cs{newcases} plus added rcases and drcases} |
| 5142 |
% \changes{v1.25}{2021/01/14}{Replaced \texttt{\{\#\#\}} by |
| 5143 |
% \texttt{\#\#}, otherwise one cannot counteract the \cs{hfil} in the |
| 5144 |
% definition with a \cs{hfil(l)} in a cell. Related to issue \#20 and https://tex.stackexchange.com/a/252412/3929} |
| 5145 |
% \begin{macrocode} |
| 5146 |
\newcases{dcases}{\quad}{% |
| 5147 |
$\m@th\displaystyle##$\hfil}{$\m@th\displaystyle##$\hfil}{\lbrace}{.} |
| 5148 |
\newcases{dcases*}{\quad}{% |
| 5149 |
$\m@th\displaystyle##$\hfil}{##\hfil}{\lbrace}{.} |
| 5150 |
\newcases{rcases}{\quad}{% |
| 5151 |
$\m@th##$\hfil}{$\m@th##$\hfil}{.}{\rbrace} |
| 5152 |
\newcases{rcases*}{\quad}{% |
| 5153 |
$\m@th##$\hfil}{##\hfil}{.}{\rbrace} |
| 5154 |
\newcases{drcases}{\quad}{% |
| 5155 |
$\m@th\displaystyle##$\hfil}{$\m@th\displaystyle##$\hfil}{.}{\rbrace} |
| 5156 |
\newcases{drcases*}{\quad}{% |
| 5157 |
$\m@th\displaystyle##$\hfil}{##\hfil}{.}{\rbrace} |
| 5158 |
\newcases{cases*}{\quad}{% |
| 5159 |
$\m@th##$\hfil}{##\hfil}{\lbrace}{.} |
| 5160 |
% \end{macrocode} |
| 5161 |
% \end{environment} |
| 5162 |
% \end{environment} |
| 5163 |
% \end{environment} |
| 5164 |
% \end{environment} |
| 5165 |
% \end{environment} |
| 5166 |
% \end{environment} |
| 5167 |
% \end{environment} |
| 5168 |
% \end{macro} |
| 5169 |
% \end{macro} |
| 5170 |
% |
| 5171 |
% \subsection{New matrix environments} |
| 5172 |
% \begin{macro}{\MT_matrix_begin:N} |
| 5173 |
% \begin{macro}{\MT_matrix_end:} |
| 5174 |
% Here are a few helpers for the matrices. \cs{MT_matrix_begin:N} |
| 5175 |
% takes one argument specifying the column type for the array inside |
| 5176 |
% the matrix. and \cs{MT_matrix_end:} inserts the correct ending. |
| 5177 |
% \begin{macrocode} |
| 5178 |
\def\MT_matrix_begin:N #1{% |
| 5179 |
\hskip -\arraycolsep |
| 5180 |
\MH_let:NwN \@ifnextchar \MH_nospace_ifnextchar:Nnn |
| 5181 |
\array{*\c@MaxMatrixCols #1}} |
| 5182 |
\def\MT_matrix_end:{\endarray \hskip -\arraycolsep} |
| 5183 |
% \end{macrocode} |
| 5184 |
% \end{macro} |
| 5185 |
% \end{macro} |
| 5186 |
% Before we define the environments we better make sure that spaces |
| 5187 |
% before the optional argument is disallowed. Else a user who types |
| 5188 |
% \begin{verbatim} |
| 5189 |
% \[ |
| 5190 |
% \begin{pmatrix*} |
| 5191 |
% [c] & a \\ |
| 5192 |
% b & d |
| 5193 |
% \end{pmatrix*} |
| 5194 |
% \] |
| 5195 |
% \end{verbatim} |
| 5196 |
% will lose the \texttt{[c]}! |
| 5197 |
% \begin{macrocode} |
| 5198 |
\MaybeMHPrecedingSpacesOff |
| 5199 |
% \end{macrocode} |
| 5200 |
% \begin{environment}{matrix*} |
| 5201 |
% This environment is just like \env{matrix} only it takes an |
| 5202 |
% optional argument specifying the column type. |
| 5203 |
% \begin{macrocode} |
| 5204 |
\newenvironment{matrix*}[1][c] |
| 5205 |
{\MT_matrix_begin:N #1} |
| 5206 |
{\MT_matrix_end:} |
| 5207 |
% \end{macrocode} |
| 5208 |
% \end{environment} |
| 5209 |
% \begin{environment}{pmatrix*} |
| 5210 |
% \begin{environment}{bmatrix*} |
| 5211 |
% \begin{environment}{Bmatrix*} |
| 5212 |
% \begin{environment}{vmatrix*} |
| 5213 |
% \begin{environment}{Vmatrix*} |
| 5214 |
% Then starred versions of the other \AmS{} matrices. |
| 5215 |
% \begin{macrocode} |
| 5216 |
\newenvironment{pmatrix*}[1][c] |
| 5217 |
{\left(\MT_matrix_begin:N #1} |
| 5218 |
{\MT_matrix_end:\right)} |
| 5219 |
\newenvironment{bmatrix*}[1][c] |
| 5220 |
{\left[\MT_matrix_begin:N #1} |
| 5221 |
{\MT_matrix_end:\right]} |
| 5222 |
\newenvironment{Bmatrix*}[1][c] |
| 5223 |
{\left\lbrace\MT_matrix_begin:N #1} |
| 5224 |
{\MT_matrix_end:\right\rbrace} |
| 5225 |
\newenvironment{vmatrix*}[1][c] |
| 5226 |
{\left\lvert\MT_matrix_begin:N #1} |
| 5227 |
{\MT_matrix_end:\right\rvert} |
| 5228 |
\newenvironment{Vmatrix*}[1][c] |
| 5229 |
{\left\lVert\MT_matrix_begin:N #1} |
| 5230 |
{\MT_matrix_end:\right\lVert} |
| 5231 |
% \end{macrocode} |
| 5232 |
% \end{environment} |
| 5233 |
% \end{environment} |
| 5234 |
% \end{environment} |
| 5235 |
% \end{environment} |
| 5236 |
% \end{environment} |
| 5237 |
% |
| 5238 |
% \changes{v1.10}{2011/02/12}{Added the code below, courtesy of Rasmus Villemoes} |
| 5239 |
% Now we are at it why not provide fenced versions of the |
| 5240 |
% \env{smallmatrix} construction as well. We will only provide a |
| 5241 |
% version that can be adjusted as \env{matrix*} above, thus we keep |
| 5242 |
% the * in the name. The implementation is courtesy of Rasmus |
| 5243 |
% Villemoes. Rasmus also suggested making the default alignment in |
| 5244 |
% these environments globally adjustable, so we did |
| 5245 |
% (\texttt{smallmatrix-align=c} by default). It \emph{is} possible to |
| 5246 |
% do something similar with the large matrix environments, but that |
| 5247 |
% might cause problems with the \texttt{array} package, thus for now |
| 5248 |
% we lease that feature alone. |
| 5249 |
% |
| 5250 |
% The base code is a variation over the original \env{smallmatrix} |
| 5251 |
% environmetn fround in \texttt{amsmath}, thus we will not comment it further. |
| 5252 |
% |
| 5253 |
% TODO: make the code check that the optional argument is either |
| 5254 |
% \texttt{c}, \texttt{l} or \texttt{r}. |
| 5255 |
% \begin{macrocode} |
| 5256 |
\def\MT_smallmatrix_begin:N #1{% |
| 5257 |
\Let@\restore@math@cr\default@tag |
| 5258 |
\baselineskip6\ex@ \lineskip1.5\ex@ \lineskiplimit\lineskip |
| 5259 |
\csname MT_smallmatrix_#1_begin:\endcsname |
| 5260 |
} |
| 5261 |
\def\MT_smallmatrix_end:{\crcr\egroup\egroup\MT_smallmatrix_inner_space:} |
| 5262 |
\def\MT_smallmatrix_l_begin:{\null\MT_smallmatrix_inner_space:\vcenter\bgroup |
| 5263 |
\ialign\bgroup$\m@th\scriptstyle##$\hfil&&\thickspace |
| 5264 |
$\m@th\scriptstyle##$\hfil\crcr |
| 5265 |
} |
| 5266 |
\def\MT_smallmatrix_c_begin:{\null\MT_smallmatrix_inner_space:\vcenter\bgroup |
| 5267 |
\ialign\bgroup\hfil$\m@th\scriptstyle##$\hfil&&\thickspace\hfil |
| 5268 |
$\m@th\scriptstyle##$\hfil\crcr |
| 5269 |
} |
| 5270 |
\def\MT_smallmatrix_r_begin:{\null\MT_smallmatrix_inner_space:\vcenter\bgroup |
| 5271 |
\ialign\bgroup\hfil$\m@th\scriptstyle##$&&\thickspace\hfil |
| 5272 |
$\m@th\scriptstyle##$\crcr |
| 5273 |
} |
| 5274 |
\newenvironment{smallmatrix*}[1][\MT_smallmatrix_default_align:] |
| 5275 |
{\MT_smallmatrix_begin:N #1} |
| 5276 |
{\MT_smallmatrix_end:} |
| 5277 |
% \end{macrocode} |
| 5278 |
% We would like to keep to the tradition of the \verb?Xmatrix? and |
| 5279 |
% \verb?Xmatrix*? macros we added earlier, since most code is similar |
| 5280 |
% we define them using a constructor macro. We also apply the trick |
| 5281 |
% used within \verb?\DeclarePairedDelimiter(X)? such that \verb?\left? |
| 5282 |
% \verb?\right? constructions produce spacings corresponding to |
| 5283 |
% \verb?\mathopen? and \verb?\mathclose?. |
| 5284 |
% \begin{macrocode} |
| 5285 |
\def\MT_fenced_sm_generator:nnn #1#2#3{% |
| 5286 |
\@ifundefined{#1}{% |
| 5287 |
\newenvironment{#1} |
| 5288 |
{\@nameuse{#1hook}\mathopen{}\mathclose\bgroup\left#2\MT_smallmatrix_begin:N c}% |
| 5289 |
{\MT_smallmatrix_end:\aftergroup\egroup\right#3}% |
| 5290 |
}{}% |
| 5291 |
\@ifundefined{#1*}{% |
| 5292 |
\newenvironment{#1*}[1][\MT_smallmatrix_default_align:]% |
| 5293 |
{\@nameuse{#1hook}\mathopen{}\mathclose\bgroup\left#2\MT_smallmatrix_begin:N ##1}% |
| 5294 |
{\MT_smallmatrix_end:\aftergroup\egroup\right#3}% |
| 5295 |
}{}% |
| 5296 |
} |
| 5297 |
\MT_fenced_sm_generator:nnn{psmallmatrix}() |
| 5298 |
\MT_fenced_sm_generator:nnn{bsmallmatrix}[] |
| 5299 |
\MT_fenced_sm_generator:nnn{Bsmallmatrix}\lbrace\rbrace |
| 5300 |
\MT_fenced_sm_generator:nnn{vsmallmatrix}\lvert\rvert |
| 5301 |
\MT_fenced_sm_generator:nnn{Vsmallmatrix}\lVert\rVert |
| 5302 |
% \end{macrocode} |
| 5303 |
% |
| 5304 |
% The options associated with this. |
| 5305 |
% \begin{macrocode} |
| 5306 |
\define@key{\MT_options_name:} |
| 5307 |
{smallmatrix-align}{\def\MT_smallmatrix_default_align:{#1}} |
| 5308 |
\define@key{\MT_options_name:} |
| 5309 |
{smallmatrix-inner-space}{\def\MT_smallmatrix_inner_space:{#1}} |
| 5310 |
\setkeys{\MT_options_name:}{ |
| 5311 |
smallmatrix-align=c, |
| 5312 |
smallmatrix-inner-space=\, |
| 5313 |
} |
| 5314 |
|
| 5315 |
% \end{macrocode} |
| 5316 |
% Restore the usual spacing behavior. |
| 5317 |
% \begin{macrocode} |
| 5318 |
\MHPrecedingSpacesOn |
| 5319 |
% \end{macrocode} |
| 5320 |
% |
| 5321 |
% |
| 5322 |
% |
| 5323 |
% \subsection{Smashing an operator with limits} |
| 5324 |
% |
| 5325 |
% \begin{macro}{\smashoperator} |
| 5326 |
% The user command. Define \cs{MT_smop_use:NNNNN} to be one of the |
| 5327 |
% specialized commands \cs{MT_smop_smash_l:NNNNN}, |
| 5328 |
% \cs{MT_smop_smash_r:NNNNN}, or the default |
| 5329 |
% \cs{MT_smop_smash_lr:NNNNN}. |
| 5330 |
% \changes{v1.25}{2021/03/04}{Verify that opt arg corresponds to |
| 5331 |
% something predefined} |
| 5332 |
% \begin{macrocode} |
| 5333 |
\newcommand*\smashoperator[2][lr]{ |
| 5334 |
\@ifundefined{MT_smop_smash_#1:NNNNN}{ |
| 5335 |
\PackageError{mathtools}{Opt~ arg~ '#1'~ for~ \@backslashchar smashoperator~ |
| 5336 |
is~ not~ supported.\MessageBreak Use~ l,~r~or~lr~ (default)}{} |
| 5337 |
}{ |
| 5338 |
\def\MT_smop_use:NNNNN {\@nameuse{MT_smop_smash_#1:NNNNN}} |
| 5339 |
\toks@{#2} |
| 5340 |
\expandafter\MT_smop_get_args:wwwNnNn |
| 5341 |
\the\toks@\@nil\@nil\@nil\@nil\@nil\@nil\@@nil |
| 5342 |
} |
| 5343 |
} |
| 5344 |
% \end{macrocode} |
| 5345 |
% \end{macro} |
| 5346 |
% \begin{macro}{\MT_smop_remove_nil_vi:N} |
| 5347 |
% \begin{macro}{\MT_smop_mathop:n} |
| 5348 |
% \begin{macro}{\MT_smop_limits:} |
| 5349 |
% Some helper functions. |
| 5350 |
% \begin{macrocode} |
| 5351 |
\def\MT_smop_remove_nil_vi:N #1\@nil\@nil\@nil\@nil\@nil\@nil{#1} |
| 5352 |
\def\MT_smop_mathop:n {\mathop} |
| 5353 |
\def\MT_smop_limits: {\limits} |
| 5354 |
% \end{macrocode} |
| 5355 |
% \end{macro} |
| 5356 |
% \end{macro} |
| 5357 |
% \end{macro} |
| 5358 |
% Some conditionals. |
| 5359 |
% \begin{macrocode} |
| 5360 |
\MH_new_boolean:n {smop_one} |
| 5361 |
\MH_new_boolean:n {smop_two} |
| 5362 |
% \end{macrocode} |
| 5363 |
% \begin{macro}{\MT_smop_get_args:wwwNnNn} |
| 5364 |
% The argument stripping. There are three different valid types of |
| 5365 |
% input: |
| 5366 |
% \begin{enumerate} |
| 5367 |
% \item An operator with neither subscript nor superscript. |
| 5368 |
% \item An operator with one subscript or superscript. |
| 5369 |
% \item An operator with both subscript and superscript. |
| 5370 |
% \end{enumerate} |
| 5371 |
% Additionally an operator can be either a single macro as in |
| 5372 |
% \cs{sum} or in \cs{mathop}\arg{A} and people might be tempted to |
| 5373 |
% put a \cs{limits} after the operator, even though it's not |
| 5374 |
% necessary. Thus the input with most tokens would be something like |
| 5375 |
% \begin{verbatim} |
| 5376 |
% \mathop{TTT}\limits_{sub}^{sup} |
| 5377 |
% \end{verbatim} |
| 5378 |
% Therefore we have to scan for seven arguments, but there might |
| 5379 |
% only be one actually. So let's list the possible situations: |
| 5380 |
% \begin{enumerate} |
| 5381 |
% \item \verb|\mathop{TTT}\limits_{subsub}^{supsup}| |
| 5382 |
% \item \verb|\mathop{TTT}_{subsub}^{supsup}| |
| 5383 |
% \item \verb|\sum\limits_{subsub}^{supsup}| |
| 5384 |
% \item \verb|\sum_{subsub}^{supsup}| |
| 5385 |
% \end{enumerate} |
| 5386 |
% Furthermore the |_{subsub}^{supsup}| part can also just be |
| 5387 |
% |_{subsub}| or empty. |
| 5388 |
% \begin{macrocode} |
| 5389 |
\def\MT_smop_get_args:wwwNnNn #1#2#3#4#5#6#7\@@nil{% |
| 5390 |
\begingroup |
| 5391 |
\def\MT_smop_arg_A: {#1} \def\MT_smop_arg_B: {#2} |
| 5392 |
\def\MT_smop_arg_C: {#3} \def\MT_smop_arg_D: {#4} |
| 5393 |
\def\MT_smop_arg_E: {#5} \def\MT_smop_arg_F: {#6} |
| 5394 |
\def\MT_smop_arg_G: {#7} |
| 5395 |
% \end{macrocode} |
| 5396 |
% Check if A is \cs{mathop}. If it is, we know that B is the argument |
| 5397 |
% of the \cs{mathop}. |
| 5398 |
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} |
| 5399 |
% \begin{macrocode} |
| 5400 |
\MH_if_meaning:NN \MT_smop_arg_A: \MT_smop_mathop:n |
| 5401 |
% \end{macrocode} |
| 5402 |
% If A was \cs{mathop} we check if C is \cs{limits} |
| 5403 |
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} |
| 5404 |
% \begin{macrocode} |
| 5405 |
\MH_if_meaning:NN \MT_smop_arg_C:\MT_smop_limits: |
| 5406 |
\def\MT_smop_final_arg_A:{#1{#2}}% |
| 5407 |
% \end{macrocode} |
| 5408 |
% Now we have something like \verb|\mathop{TTT}\limits|. Then check |
| 5409 |
% if D is \cs{@nil}. |
| 5410 |
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} |
| 5411 |
% \begin{macrocode} |
| 5412 |
\MH_if_meaning:NN \MT_smop_arg_D: \@nnil |
| 5413 |
\MH_else: |
| 5414 |
\MH_set_boolean_T:n {smop_one} |
| 5415 |
\MH_let:NwN \MT_smop_final_arg_B: \MT_smop_arg_D: |
| 5416 |
\MH_let:NwN \MT_smop_final_arg_C: \MT_smop_arg_E: |
| 5417 |
\MH_if_meaning:NN \MT_smop_arg_F: \@nnil |
| 5418 |
\MH_else: |
| 5419 |
\MH_set_boolean_T:n {smop_two} |
| 5420 |
\MH_let:NwN \MT_smop_final_arg_D: \MT_smop_arg_F: |
| 5421 |
\edef\MT_smop_final_arg_E: |
| 5422 |
{\expandafter\MT_smop_remove_nil_vi:N \MT_smop_arg_G: } |
| 5423 |
\MH_fi: |
| 5424 |
\MH_fi: |
| 5425 |
\MH_else: |
| 5426 |
% \end{macrocode} |
| 5427 |
% Here we have something like \verb|\mathop{TTT}|. Still check |
| 5428 |
% if D is \cs{@nil}. |
| 5429 |
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} |
| 5430 |
% \begin{macrocode} |
| 5431 |
\def\MT_smop_final_arg_A:{#1{#2}}% |
| 5432 |
\MH_if_meaning:NN \MT_smop_arg_D: \@nnil |
| 5433 |
\MH_else: |
| 5434 |
\MH_set_boolean_T:n {smop_one} |
| 5435 |
\MH_let:NwN \MT_smop_final_arg_B: \MT_smop_arg_C: |
| 5436 |
\MH_let:NwN \MT_smop_final_arg_C: \MT_smop_arg_D: |
| 5437 |
\MH_if_meaning:NN \MT_smop_arg_F: \@nnil |
| 5438 |
\MH_else: |
| 5439 |
\MH_set_boolean_T:n {smop_two} |
| 5440 |
\MH_let:NwN \MT_smop_final_arg_D: \MT_smop_arg_E: |
| 5441 |
\MH_let:NwN \MT_smop_final_arg_E: \MT_smop_arg_F: |
| 5442 |
\MH_fi: |
| 5443 |
\MH_fi: |
| 5444 |
\MH_fi: |
| 5445 |
% \end{macrocode} |
| 5446 |
% If A was not \cs{mathop}, it is an operator in itself, so we check |
| 5447 |
% if B is \cs{limits} |
| 5448 |
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} |
| 5449 |
% \begin{macrocode} |
| 5450 |
\MH_else: |
| 5451 |
\MH_if_meaning:NN \MT_smop_arg_B:\MT_smop_limits: |
| 5452 |
\def\MT_smop_final_arg_A:{#1}% |
| 5453 |
\MH_if_meaning:NN \MT_smop_arg_D: \@nnil |
| 5454 |
\MH_else: |
| 5455 |
\MH_set_boolean_T:n {smop_one} |
| 5456 |
\MH_let:NwN \MT_smop_final_arg_B: \MT_smop_arg_C: |
| 5457 |
\MH_let:NwN \MT_smop_final_arg_C: \MT_smop_arg_D: |
| 5458 |
\MH_if_meaning:NN \MT_smop_arg_F: \@nnil |
| 5459 |
\MH_else: |
| 5460 |
\MH_set_boolean_T:n {smop_two} |
| 5461 |
\MH_let:NwN \MT_smop_final_arg_D: \MT_smop_arg_E: |
| 5462 |
\MH_let:NwN \MT_smop_final_arg_E: \MT_smop_arg_F: |
| 5463 |
\MH_fi: |
| 5464 |
\MH_fi: |
| 5465 |
\MH_else: |
| 5466 |
% \end{macrocode} |
| 5467 |
% No \cs{limits} was found, so we already have the right input. Just |
| 5468 |
% forget about the last two arguments. |
| 5469 |
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} |
| 5470 |
% \begin{macrocode} |
| 5471 |
\def\MT_smop_final_arg_A:{#1}% |
| 5472 |
\MH_if_meaning:NN \MT_smop_arg_C: \@nnil |
| 5473 |
\MH_else: |
| 5474 |
\MH_set_boolean_T:n {smop_one} |
| 5475 |
\MH_let:NwN \MT_smop_final_arg_B: \MT_smop_arg_B: |
| 5476 |
\MH_let:NwN \MT_smop_final_arg_C: \MT_smop_arg_C: |
| 5477 |
\MH_if_meaning:NN \MT_smop_arg_D: \@nnil |
| 5478 |
\MH_else: |
| 5479 |
\MH_set_boolean_T:n {smop_two} |
| 5480 |
\MH_let:NwN \MT_smop_final_arg_D: \MT_smop_arg_D: |
| 5481 |
\MH_let:NwN \MT_smop_final_arg_E: \MT_smop_arg_E: |
| 5482 |
\MH_fi: |
| 5483 |
\MH_fi: |
| 5484 |
\MH_fi: |
| 5485 |
\MH_fi: |
| 5486 |
% \end{macrocode} |
| 5487 |
% No reason to measure if there's no sub or sup. |
| 5488 |
% \begin{macrocode} |
| 5489 |
\MH_if_boolean:nT {smop_one}{ |
| 5490 |
\MT_smop_measure:NNNNN |
| 5491 |
\MT_smop_final_arg_A: \MT_smop_final_arg_B: \MT_smop_final_arg_C: |
| 5492 |
\MT_smop_final_arg_D: \MT_smop_final_arg_E: |
| 5493 |
} |
| 5494 |
\MT_smop_use:NNNNN |
| 5495 |
\MT_smop_final_arg_A: \MT_smop_final_arg_B: \MT_smop_final_arg_C: |
| 5496 |
\MT_smop_final_arg_D: \MT_smop_final_arg_E: |
| 5497 |
\endgroup |
| 5498 |
} |
| 5499 |
% \end{macrocode} |
| 5500 |
% \end{macro} |
| 5501 |
% Typeset what is necessary and ignore width of sub and sup: |
| 5502 |
% \begin{macrocode} |
| 5503 |
\def\MT_smop_needed_args:NNNNN #1#2#3#4#5{% |
| 5504 |
\displaystyle #1 |
| 5505 |
\MH_if_boolean:nT {smop_one}{ |
| 5506 |
% \end{macrocode} |
| 5507 |
% Let's use the internal versions of \cs{crampedclap} now that we now |
| 5508 |
% it is set in \cs{scriptstyle}. |
| 5509 |
% \begin{macrocode} |
| 5510 |
\limits#2{\MT_cramped_clap_internal:Nn \scriptstyle{#3}} |
| 5511 |
\MH_if_boolean:nT {smop_two}{ |
| 5512 |
#4{\MT_cramped_clap_internal:Nn \scriptstyle{#5}} |
| 5513 |
} |
| 5514 |
} |
| 5515 |
} |
| 5516 |
% \end{macrocode} |
| 5517 |
% Measure the natural width. \cs{@tempdima} holds the dimen we need to |
| 5518 |
% adjust it all with. |
| 5519 |
% \begin{macrocode} |
| 5520 |
\def\MT_smop_measure:NNNNN #1#2#3#4#5{% |
| 5521 |
\MH_let:NwN \MT_saved_mathclap:Nn \MT_cramped_clap_internal:Nn |
| 5522 |
\MH_let:NwN \MT_cramped_clap_internal:Nn \@secondoftwo |
| 5523 |
\sbox\z@{$\m@th\MT_smop_needed_args:NNNNN #1#2#3#4#5$} |
| 5524 |
\MH_let:NwN \MT_cramped_clap_internal:Nn \MT_saved_mathclap:Nn |
| 5525 |
\sbox\tw@{$\m@th\displaystyle#1$} |
| 5526 |
\@tempdima=.5\wd0 |
| 5527 |
\advance\@tempdima-.5\wd2 |
| 5528 |
} |
| 5529 |
% \end{macrocode} |
| 5530 |
% The `l' variant |
| 5531 |
% \begin{macrocode} |
| 5532 |
\def\MT_smop_smash_l:NNNNN #1#2#3#4#5{ |
| 5533 |
\MT_smop_needed_args:NNNNN #1#2#3#4#5\kern\@tempdima |
| 5534 |
} |
| 5535 |
% \end{macrocode} |
| 5536 |
% The `r' variant |
| 5537 |
% \begin{macrocode} |
| 5538 |
\def\MT_smop_smash_r:NNNNN #1#2#3#4#5{ |
| 5539 |
\kern\@tempdima\MT_smop_needed_args:NNNNN #1#2#3#4#5 |
| 5540 |
} |
| 5541 |
% \end{macrocode} |
| 5542 |
% The `lr' variant |
| 5543 |
% \changes{v1.25}{2021/03/04}{add `rl' as an alias for `lr'} |
| 5544 |
% \begin{macrocode} |
| 5545 |
\def\MT_smop_smash_lr:NNNNN #1#2#3#4#5{ |
| 5546 |
\MT_smop_needed_args:NNNNN #1#2#3#4#5 |
| 5547 |
} |
| 5548 |
% \end{macrocode} |
| 5549 |
% Add `rl' as an alias for `lr' |
| 5550 |
% \begin{macrocode} |
| 5551 |
\MH_let:NwN \MT_smop_smash_rl:NNNNN \MT_smop_smash_lr:NNNNN |
| 5552 |
% \end{macrocode} |
| 5553 |
% |
| 5554 |
% |
| 5555 |
% \subsection{Adjusting limits} |
| 5556 |
% |
| 5557 |
% |
| 5558 |
% \begin{macro}{\MT_vphantom:Nn} |
| 5559 |
% \begin{macro}{\MT_hphantom:Nn} |
| 5560 |
% \begin{macro}{\MT_phantom:Nn} |
| 5561 |
% \begin{macro}{\MT_internal_phantom:N} |
| 5562 |
% The main advantage of \cs{phantom} et al., is the ability to |
| 5563 |
% choose the right size automatically, but it requires the input to |
| 5564 |
% be typeset four times. Since we will need to have a \cs{cramped} |
| 5565 |
% inside a \cs{vphantom} it is much, much faster to choose the style |
| 5566 |
% ourselves (we already know it). These macros make it possible. |
| 5567 |
% \begin{macrocode} |
| 5568 |
\def\MT_vphantom:Nn {\v@true\h@false\MT_internal_phantom:N} |
| 5569 |
\def\MT_hphantom:Nn {\v@false\h@true\MT_internal_phantom:N} |
| 5570 |
\def\MT_phantom:Nn {\v@true\h@true\MT_internal_phantom:N} |
| 5571 |
\def\MT_internal_phantom:N #1{ |
| 5572 |
\ifmmode |
| 5573 |
\expandafter\mathph@nt\expandafter#1 |
| 5574 |
\else |
| 5575 |
\expandafter\makeph@nt |
| 5576 |
\fi |
| 5577 |
} |
| 5578 |
% \end{macrocode} |
| 5579 |
% \end{macro} |
| 5580 |
% \end{macro} |
| 5581 |
% \end{macro} |
| 5582 |
% \end{macro} |
| 5583 |
% |
| 5584 |
% \begin{macro}{\adjustlimits} |
| 5585 |
% This is for making sure limits line up on two consecutive |
| 5586 |
% operators. |
| 5587 |
% \begin{macrocode} |
| 5588 |
\newcommand*\adjustlimits[6]{ |
| 5589 |
% \end{macrocode} |
| 5590 |
% We measure the two operators and save the difference of their |
| 5591 |
% depths. |
| 5592 |
% \begin{macrocode} |
| 5593 |
\sbox\z@{$\m@th \displaystyle #1$} |
| 5594 |
\sbox\tw@{$\m@th \displaystyle #4$} |
| 5595 |
\@tempdima=\dp\z@ \advance\@tempdima-\dp\tw@ |
| 5596 |
% \end{macrocode} |
| 5597 |
% We force \cs{displaystyle} for the operator and \cs{scripstyle} |
| 5598 |
% for the limit. If we make use of the regular \cs{smash}, |
| 5599 |
% \cs{vphantom}, and \cs{cramped} macros, and let \TeX{} choose the |
| 5600 |
% right style for each one of them, we get a lot of redundant code |
| 5601 |
% as we have no need for the combination |
| 5602 |
% $(\cs{displaystyle},\cs{textstyle})$ etc. Only |
| 5603 |
% $(\cs{scriptstyle},\cs{scriptstyle})$ is useful. |
| 5604 |
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} |
| 5605 |
% \begin{macrocode} |
| 5606 |
\MH_if_dim:w \@tempdima>\z@ |
| 5607 |
\mathop{#1}\limits#2{#3} |
| 5608 |
\MH_else: |
| 5609 |
\mathop{#1\MT_vphantom:Nn \displaystyle{#4}}\limits |
| 5610 |
#2{ |
| 5611 |
\def\finsm@sh{\ht\z@\z@ \box\z@} |
| 5612 |
\mathsm@sh\scriptstyle{\MT_cramped_internal:Nn \scriptstyle{#3}} |
| 5613 |
\MT_vphantom:Nn \scriptstyle |
| 5614 |
{\MT_cramped_internal:Nn \scriptstyle{#6}} |
| 5615 |
} |
| 5616 |
\MH_fi: |
| 5617 |
\MH_if_dim:w \@tempdima>\z@ |
| 5618 |
\mathop{#4\MT_vphantom:Nn \displaystyle{#1}}\limits |
| 5619 |
#5 |
| 5620 |
{ |
| 5621 |
\MT_vphantom:Nn \scriptstyle |
| 5622 |
{\MT_cramped_internal:Nn \scriptstyle{#3}} |
| 5623 |
\def\finsm@sh{\ht\z@\z@ \box\z@} |
| 5624 |
\mathsm@sh\scriptstyle{\MT_cramped_internal:Nn \scriptstyle{#6}} |
| 5625 |
} |
| 5626 |
\MH_else: |
| 5627 |
\mathop{#4}\limits#5{#6} |
| 5628 |
\MH_fi: |
| 5629 |
} |
| 5630 |
% \end{macrocode} |
| 5631 |
% \end{macro} |
| 5632 |
% |
| 5633 |
% \subsection{Swapping above display skip} |
| 5634 |
% |
| 5635 |
% \begin{macro}{\SwapAboveDisplaySkip} |
| 5636 |
% This macro is intended to be used at the start of \AmS\ |
| 5637 |
% environments, in order to force it to use |
| 5638 |
% \cs{abovedisplayshortskip} instead of \cs{abovedisplayskip} above |
| 5639 |
% the displayed math. Because of the use of \cs{noalign} it will not |
| 5640 |
% work inside \env{equation} or \env{multline}. |
| 5641 |
% \begin{macrocode} |
| 5642 |
\newcommand\SwapAboveDisplaySkip{% |
| 5643 |
\noalign{\vskip-\abovedisplayskip\vskip\abovedisplayshortskip} |
| 5644 |
} |
| 5645 |
|
| 5646 |
% \end{macrocode} |
| 5647 |
% |
| 5648 |
% \end{macro} |
| 5649 |
% |
| 5650 |
% \subsection{An aid to alignment} |
| 5651 |
% |
| 5652 |
% \begin{macro}{\MoveEqLeft} |
| 5653 |
% \changes{v1.05}{2008/06/05}{Added \cs{MoveEqLeft} (daleif)} |
| 5654 |
% \changes{v1.05b}{2008/06/18}{We don't need \cs{setlength} here |
| 5655 |
% (daleif), after discussion about \cs{global} and \cs{setlength} |
| 5656 |
% on ctt} |
| 5657 |
% \changes{v1.12}{2011/06/12}{We don't even need lengths. GL |
| 5658 |
% suggested on ctt to just apply them directly.} |
| 5659 |
% This is a very simple macro, we `move' a line in an |
| 5660 |
% alignment backwards in order to simulate that all subsequent lines |
| 5661 |
% have been indented. Note that simply using \verb+\kern-2m+ after |
| 5662 |
% the \verb+&+ is not enough, then the alignemnt environment never |
| 5663 |
% detects that there is anything (though simulated) in the cell |
| 5664 |
% before the \verb+&+. |
| 5665 |
% \begin{macrocode} |
| 5666 |
\newcommand\MoveEqLeft[1][2]{\kern #1em & \kern -#1em} |
| 5667 |
% \end{macrocode} |
| 5668 |
% \end{macro} |
| 5669 |
% |
| 5670 |
% \begin{macro}{\Aboxed} |
| 5671 |
% \changes{v1.08}{2010/06/29}{Added \cs{Aboxed}} |
| 5672 |
% The idea from \cs{MoveEqLeft} can be used for other things. Here we |
| 5673 |
% create a macro that will allow a user to box an equation inside an |
| 5674 |
% alignment. |
| 5675 |
% \changes{v1.12}{2011/08/17}{\cs{Aboxed} reimplemented, cudos to GL} |
| 5676 |
% \begin{macrocode} |
| 5677 |
\newcommand\Aboxed[1]{\let\bgroup{\romannumeral-`}\@Aboxed#1&&\ENDDNE} |
| 5678 |
% \end{macrocode} |
| 5679 |
% \sloppy |
| 5680 |
% The macro has been reimplemented courtesy of Florent Chervet out of |
| 5681 |
% a posting on ctt, \url{https://groups.google.com/group/comp.text.tex/browse_thread/thread/5d66395f2a1b5134/93fd9661484bd8d8?#93fd9661484bd8d8} |
| 5682 |
% \begin{macrocode} |
| 5683 |
\def\@Aboxed#1\ENDDNE{% |
| 5684 |
\ifnum0=`{}\fi \setbox \z@ |
| 5685 |
\hbox{$\displaystyle#1{}\m@th$\kern\fboxsep \kern\fboxrule }% |
| 5686 |
\edef\@tempa {\kern \wd\z@ &\kern -\the\wd\z@ |
| 5687 |
% \end{macrocode} |
| 5688 |
% The \verb|\fboxsep\the\fboxsep...| line ensures that you can use |
| 5689 |
% \verb|\fboxsep=10pt\Aboxed{...}| in a pinch. |
| 5690 |
% \begin{macrocode} |
| 5691 |
\fboxsep\the\fboxsep \fboxrule \the\fboxrule }\@tempa \boxed {#1#2}% |
| 5692 |
} |
| 5693 |
% \end{macrocode} |
| 5694 |
% \end{macro} |
| 5695 |
% |
| 5696 |
% \begin{macro}{\MakeAboxedCommand} |
| 5697 |
% \changes{1.28}{2022/01/01}{Added} |
| 5698 |
% At times users want macros equivalent to \cs{Aboxed} but with a |
| 5699 |
% different box as the base. So we provide one |
| 5700 |
% \begin{macrocode} |
| 5701 |
\newcommand\MakeAboxedCommand[2]{ |
| 5702 |
% #1: command to create |
| 5703 |
% #2: box command to use |
| 5704 |
\newcommand#1[1]{\let\bgroup{\romannumeral-`}% |
| 5705 |
\@nameuse{@@\MH_cs_to_str:N #1}##1&&\ENDDNE} |
| 5706 |
\@namedef{@@\MH_cs_to_str:N #1}##1&##2&##3\ENDDNE{% |
| 5707 |
% \end{macrocode} |
| 5708 |
% Instead of hardcoding the kerning of box rule and box sep, we record |
| 5709 |
% the width of an empty box and kern half of it. |
| 5710 |
% \begin{macrocode} |
| 5711 |
\settowidth\@tempdimc{#2{}}% |
| 5712 |
\ifnum0=`{}\fi \setbox \z@ |
| 5713 |
\hbox{$\displaystyle##1{}\m@th$\kern0.5\@tempdimc}% |
| 5714 |
% \end{macrocode} |
| 5715 |
% The \verb|\fboxsep\the\fboxsep...| line enables |
| 5716 |
% \verb|\fboxsep=10\Command{...&...}|. Of course only works for boxed |
| 5717 |
% that uses \cs{fboxsep} and \cs{fboxrule}. |
| 5718 |
% \begin{macrocode} |
| 5719 |
\edef\@tempa{\kern\wd\z@&\kern-\the\wd\z@% |
| 5720 |
\fboxsep\the\fboxsep \fboxrule \the\fboxrule}% |
| 5721 |
\@tempa% |
| 5722 |
% \end{macrocode} |
| 5723 |
% Instead of using \cs{boxed} directly, we mimick the definition of |
| 5724 |
% \cs{boxed} and should thus be able to use any box. |
| 5725 |
% \begin{macrocode} |
| 5726 |
#2{\m@th$\displaystyle ##1##2$}% |
| 5727 |
} |
| 5728 |
} |
| 5729 |
|
| 5730 |
% \end{macrocode} |
| 5731 |
% |
| 5732 |
% \end{macro} |
| 5733 |
% |
| 5734 |
% |
| 5735 |
% \begin{macro}{\ArrowBetweenLines} |
| 5736 |
% \changes{v1.05}{2008/06/05}{Added \cs{ArrowBetweenLines} as it |
| 5737 |
% belongs here and not just in my \LaTeX book (daleif)} |
| 5738 |
% ????Implementation notes are needed???? |
| 5739 |
% \begin{macrocode} |
| 5740 |
\MHInternalSyntaxOff |
| 5741 |
\def\ArrowBetweenLines{\relax |
| 5742 |
\iffalse{\fi\ifnum0=`}\fi |
| 5743 |
\@ifstar{\ArrowBetweenLines@auxI{00}}{\ArrowBetweenLines@auxI{01}}} |
| 5744 |
\def\ArrowBetweenLines@auxI#1{% |
| 5745 |
\@ifnextchar[% |
| 5746 |
{\ArrowBetweenLines@auxII{#1}}% |
| 5747 |
{\ArrowBetweenLines@auxII{#1}[\Updownarrow]}} |
| 5748 |
\def\ArrowBetweenLines@auxII#1[#2]{% |
| 5749 |
\ifnum0=`{\fi \iffalse}\fi |
| 5750 |
% \end{macrocode} |
| 5751 |
% It turns out that for some reason the \cs{crcr} (next) removes the |
| 5752 |
% automatic equation number replacement. The replacement hack seems to |
| 5753 |
% the trick, though I have no idea why \cs{crcr} broke things (/daleif). |
| 5754 |
% \changes{v1.08}{2010/06/15}{fixed eq num replacement bug} |
| 5755 |
% \begin{macrocode} |
| 5756 |
% \crcr |
| 5757 |
\expandafter\in@\expandafter{\@currenvir}% |
| 5758 |
{alignedat,aligned,gathered}% |
| 5759 |
\ifin@ \else |
| 5760 |
\notag |
| 5761 |
\fi% |
| 5762 |
\\ |
| 5763 |
\noalign{\nobreak\vskip-\baselineskip\vskip-\lineskip}% |
| 5764 |
\noalign{\expandafter\in@\expandafter{\@currenvir}% |
| 5765 |
{alignedat,aligned,gathered}% |
| 5766 |
\ifin@ \else\notag\fi% |
| 5767 |
}% |
| 5768 |
\if#1 &&\quad #2\else #2\quad\fi |
| 5769 |
\\\noalign{\nobreak\vskip-\lineskip}} |
| 5770 |
|
| 5771 |
\MHInternalSyntaxOn |
| 5772 |
% \end{macrocode} |
| 5773 |
% \end{macro} |
| 5774 |
% |
| 5775 |
% |
| 5776 |
% \subsection{Centered vertical dots} |
| 5777 |
% |
| 5778 |
% Doing a \verb?\vdots? centered within a different sized box, is |
| 5779 |
% rather easy with the tools available. Note that it does \emph{not} |
| 5780 |
% check for the style we are running in, thus do not expect this to |
| 5781 |
% work well within \verb?\scriptstyle? and smaller. Basically we |
| 5782 |
% create a box of a width corresponding to \verb?{}#1{}? and center |
| 5783 |
% the \verb?\vdots? within it. |
| 5784 |
% \begin{macrocode} |
| 5785 |
\newcommand\vdotswithin[1]{% |
| 5786 |
{\mathmakebox[\widthof{\ensuremath{{}#1{}}}][c]{{\vdots}}}} |
| 5787 |
% \end{macrocode} |
| 5788 |
% Next we are inspired by \verb?\ArrowBetweenLines? and provide a |
| 5789 |
% costruction to be used within alignments with much less vertical |
| 5790 |
% space above and below. |
| 5791 |
% |
| 5792 |
% First in order to support \env{spreadlines} we need to store the |
| 5793 |
% original value of \verb?\jot? (and hope the user does not mess with it). |
| 5794 |
% \begin{macrocode} |
| 5795 |
\newlength\origjot |
| 5796 |
\setlength\origjot{\jot} |
| 5797 |
% \end{macrocode} |
| 5798 |
% Next define how much we spacing we flush out, and make this user adjustable. |
| 5799 |
% \begin{macrocode} |
| 5800 |
\newdimen\l_MT_shortvdotswithinadjustabove_dim |
| 5801 |
\newdimen\l_MT_shortvdotswithinadjustbelow_dim |
| 5802 |
\define@key{\MT_options_name:} |
| 5803 |
{shortvdotsadjustabove}{\setlength\l_MT_shortvdotswithinadjustabove_dim{#1}} |
| 5804 |
\define@key{\MT_options_name:} |
| 5805 |
{shortvdotsadjustbelow}{\setlength\l_MT_shortvdotswithinadjustbelow_dim{#1}} |
| 5806 |
% \end{macrocode} |
| 5807 |
% The actual defaults we found by trail and error. |
| 5808 |
% \begin{macrocode} |
| 5809 |
\setkeys{\MT_options_name:}{ |
| 5810 |
shortvdotsadjustabove=2.15\origjot, |
| 5811 |
shortvdotsadjustbelow=\origjot |
| 5812 |
} |
| 5813 |
% \end{macrocode} |
| 5814 |
% The user macro comes in two versions, starred version corresponding |
| 5815 |
% to alignment \emph{before} and \verb?&? and a non-starred version |
| 5816 |
% with alignment \emph{after} \verb?&?. |
| 5817 |
% \begin{macrocode} |
| 5818 |
\def\shortvdotswithin{\relax |
| 5819 |
\@ifstar{\MT_svwi_aux:nn{00}}{\MT_svwi_aux:nn{01}}} |
| 5820 |
\def\MT_svwi_aux:nn #1#2{ |
| 5821 |
\MTFlushSpaceAbove |
| 5822 |
\if#1 \vdotswithin{#2}& \else &\vdotswithin{#2} \fi |
| 5823 |
\MTFlushSpaceBelow |
| 5824 |
} |
| 5825 |
% \end{macrocode} |
| 5826 |
% We will need a way to remove any tags (eq. numbers) on the |
| 5827 |
% \verb?\vdots? line. We cannot use the method used by |
| 5828 |
% \verb?\ArrowBetweenLines? so we use inspiration from |
| 5829 |
% \texttt{etoolbox}. |
| 5830 |
% \begin{macrocode} |
| 5831 |
\def\MT_remove_tag_unless_inner:n #1{% |
| 5832 |
\begingroup |
| 5833 |
\def\etb@tempa##1|#1|##2\MT@END{\endgroup |
| 5834 |
\ifx\@empty##2\@empty\notag\fi}% |
| 5835 |
\expandafter\etb@tempa\expandafter|alignedat|aligned|split|#1|\MT@END} |
| 5836 |
%| emacs |
| 5837 |
% \end{macrocode} |
| 5838 |
% These macros take care of removing the space above or below. Since |
| 5839 |
% these may be useful for the user in very special cases, we provide |
| 5840 |
% them as separate macros. |
| 5841 |
% \begin{macrocode} |
| 5842 |
\newcommand\MTFlushSpaceAbove{ |
| 5843 |
\expandafter\MT_remove_tag_unless_inner:n\expandafter{\@currenvir} |
| 5844 |
\\ |
| 5845 |
\noalign{% |
| 5846 |
\nobreak\vskip-\baselineskip\vskip-\lineskip% |
| 5847 |
\vskip-\l_MT_shortvdotswithinadjustabove_dim |
| 5848 |
\vskip-\origjot |
| 5849 |
\vskip\jot |
| 5850 |
}% |
| 5851 |
\noalign{ |
| 5852 |
\expandafter\MT_remove_tag_unless_inner:n\expandafter{\@currenvir} |
| 5853 |
} |
| 5854 |
} |
| 5855 |
\newcommand\MTFlushSpaceBelow{ |
| 5856 |
\\\noalign{% |
| 5857 |
\nobreak\vskip-\lineskip |
| 5858 |
\vskip-\l_MT_shortvdotswithinadjustbelow_dim |
| 5859 |
\vskip-\origjot |
| 5860 |
\vskip\jot |
| 5861 |
} |
| 5862 |
} |
| 5863 |
|
| 5864 |
% \end{macrocode} |
| 5865 |
% |
| 5866 |
% |
| 5867 |
% \section{A few extra symbols} |
| 5868 |
% |
| 5869 |
% Most math font sets are missing three symbols: \cs{nuparrow}, |
| 5870 |
% \cs{ndownarrow} and \cs{bigtimes}. We provide \emph{simulated} |
| 5871 |
% versions of these symbols in case they are missing. |
| 5872 |
% |
| 5873 |
% \subsection{Negated up- and down arrows} |
| 5874 |
% |
| 5875 |
% Note that the \cs{nuparrow} and the \cs{ndownarrow} are made from |
| 5876 |
% \cs{nrightarrow} and \cs{nleftarrow}, so these have to be |
| 5877 |
% present. If they are not, we throw an error at use. The |
| 5878 |
% implementation details are due to Enrico Gregorio |
| 5879 |
% (\url{http://groups.google.com/group/comp.text.tex/msg/689cc8bd604fdb51}), |
| 5880 |
% the basic idea is to reflect and rotate existing negated |
| 5881 |
% arrows. Note that the reflection and rotation will not show up i |
| 5882 |
% most DVI previewers. |
| 5883 |
% \begin{macro}{\MH_nrotarrow:NN} |
| 5884 |
% \changes{v1.07}{2008/08/11}{Added support for \cs{nuparrow} and \cs{ndownaddow}} |
| 5885 |
% First a common construction macro. |
| 5886 |
% \begin{macrocode} |
| 5887 |
\def\MH_nrotarrow:NN #1#2{% |
| 5888 |
\setbox0=\hbox{$\m@th#1\uparrow$}\dimen0=\dp0 |
| 5889 |
\setbox0=\hbox{% |
| 5890 |
\reflectbox{\rotatebox[origin=c]{90}{$\m@th#1\mkern2.22mu #2$}}}% |
| 5891 |
\dp0=\dimen0 \box0 \mkern2.3965mu |
| 5892 |
} |
| 5893 |
% \end{macrocode} |
| 5894 |
% \end{macro} |
| 5895 |
% The negated arrows are then made using this macro on respectively |
| 5896 |
% \cs{nrightarrow} and \cs{nleftarrow} |
| 5897 |
% \begin{macro}{\MH_nuparrow:} |
| 5898 |
% \begin{macro}{\MH_ndownarrow:} |
| 5899 |
% \begin{macrocode} |
| 5900 |
\def\MH_nuparrow: {% |
| 5901 |
\mathrel{\mathpalette\MH_nrotarrow:NN\nrightarrow} } |
| 5902 |
\def\MH_ndownarrow: {% |
| 5903 |
\mathrel{\mathpalette\MH_nrotarrow:NN\nleftarrow} } |
| 5904 |
% \end{macrocode} |
| 5905 |
% \end{macro} |
| 5906 |
% \end{macro} |
| 5907 |
% \begin{macro}{\nuparrow} |
| 5908 |
% \begin{macro}{\ndownarrow} |
| 5909 |
% Next we provide \cs{nuparrow} and \cs{ndownarrow} at begin |
| 5910 |
% document. Since they depend on \cs{nrightarrow} and |
| 5911 |
% \cs{nleftarrow} we test for these and let the macros throw an |
| 5912 |
% error if they are missing. |
| 5913 |
% \changes{v1.08b}{2010/07/21}{Moved graphicx loading down here such |
| 5914 |
% that we do not get into option clash problems} |
| 5915 |
% \begin{macrocode} |
| 5916 |
\AtBeginDocument{% |
| 5917 |
\RequirePackage{graphicx}% |
| 5918 |
\@ifundefined{nrightarrow}{% |
| 5919 |
\providecommand\nuparrow{% |
| 5920 |
\PackageError{mathtools}{\string\nuparrow\space~ is~ |
| 5921 |
constructed~ from~ \string\nrightarrow,~ which~ is~ not~ |
| 5922 |
provided.~ Please~ load~ the~ amssymb~ package~ or~ similar}{} |
| 5923 |
}}{ \providecommand\nuparrow{\MH_nuparrow:}} |
| 5924 |
\@ifundefined{nleftarrow}{% |
| 5925 |
\providecommand\ndownarrow{% |
| 5926 |
\PackageError{mathtools}{\string\ndownarrow\space~ is~ |
| 5927 |
constructed~ from~ \string\nleftarrow,~ which~ is~ not~ |
| 5928 |
provided.~ Please~ load~ the~ amssymb~ package~ or~ similar}{} |
| 5929 |
}}{ \providecommand\ndownarrow{\MH_ndownarrow:}} } |
| 5930 |
% \end{macrocode} |
| 5931 |
% \end{macro} |
| 5932 |
% \end{macro} |
| 5933 |
% |
| 5934 |
% |
| 5935 |
% \subsection{Providing bigtimes} |
| 5936 |
% |
| 5937 |
% The idea is to use the original \cs{times} and then scale it |
| 5938 |
% accordingly. Again the implementation details have been improved by |
| 5939 |
% Enrico Gregorio |
| 5940 |
% (\url{http://groups.google.com/group/comp.text.tex/msg/9685c9405df2ff94}). |
| 5941 |
% |
| 5942 |
% \begin{macro}{\MH_bigtimes_scaler:N} |
| 5943 |
% \begin{macro}{\MH_bigtimes_inner:} |
| 5944 |
% \begin{macro}{\MH_csym_bigtimes:} |
| 5945 |
% \changes{v1.07}{2008/08/11}{Added support for \cs{bigtimes}} |
| 5946 |
% \begin{macrocode} |
| 5947 |
\def\MH_bigtimes_scaler:N #1{% |
| 5948 |
\vcenter{\hbox{#1$\m@th\mkern-2mu\times\mkern-2mu$}}} |
| 5949 |
% \end{macrocode} |
| 5950 |
% This is then combined with \cs{mathchoice} to form the inner parts |
| 5951 |
% of the macro |
| 5952 |
% \begin{macrocode} |
| 5953 |
\def\MH_bigtimes_inner: { |
| 5954 |
\mathchoice{\MH_bigtimes_scaler:N \huge} % display style |
| 5955 |
{\MH_bigtimes_scaler:N \LARGE} % text style |
| 5956 |
{\MH_bigtimes_scaler:N {}} % script style |
| 5957 |
{\MH_bigtimes_scaler:N \footnotesize} % script script style |
| 5958 |
} |
| 5959 |
% \end{macrocode} |
| 5960 |
% And thus the internal prepresentaion of the \cs{bigtimes} macro. |
| 5961 |
% \begin{macrocode} |
| 5962 |
\def\MH_csym_bigtimes: {\mathop{\MH_bigtimes_inner:}\displaylimits} |
| 5963 |
% \end{macrocode} |
| 5964 |
% \end{macro} |
| 5965 |
% \end{macro} |
| 5966 |
% \end{macro} |
| 5967 |
% \begin{macro}{\bigtimes} |
| 5968 |
% In the end we provide \cs{bigtimes} if otherwise not defined. |
| 5969 |
% \begin{macrocode} |
| 5970 |
\AtBeginDocument{ |
| 5971 |
\providecommand\bigtimes{\MH_csym_bigtimes:} |
| 5972 |
} |
| 5973 |
% \end{macrocode} |
| 5974 |
% \end{macro} |
| 5975 |
% |
| 5976 |
% \section{Macros by other people} |
| 5977 |
% |
| 5978 |
% \subsection{Intertext and short intertext} |
| 5979 |
% |
| 5980 |
% It turns out that \cs{intertext} use a bit too much |
| 5981 |
% space. Especially noticable if combined with the \env{spreadlines} |
| 5982 |
% environment, the extra space is also applied above and below |
| 5983 |
% \cs{intertext}, which ends up looking unproffesional. Chung-chieh |
| 5984 |
% Shan |
| 5985 |
% (\url{http://conway.rutgers.edu/~ccshan/wiki/blog/posts/Beyond_amsmath/}) |
| 5986 |
% via Tobias Weh suggested a fix. We apply it here, but also keep the |
| 5987 |
% original \cs{intertext} in case a user would rather want it. |
| 5988 |
% \begin{macro}{\MT_orig_intertext:} |
| 5989 |
% \begin{macro}{\MT_intertext:} |
| 5990 |
% \changes{v1.13}{2012/08/19}{\cs{l_MT_X_intertext_dim} renamed to |
| 5991 |
% \cs{l_MT_X_intertext_sep}} |
| 5992 |
% \begin{macro}{\l_MT_above_intertext_sep} |
| 5993 |
% \begin{macro}{\l_MT_below_intertext_sep} |
| 5994 |
% First store the originam Ams version. |
| 5995 |
% \begin{macrocode} |
| 5996 |
\MH_let:NwN \MT_orig_intertext: \intertext@ |
| 5997 |
% \end{macrocode} |
| 5998 |
% And then for some reconfiguration. First a few lengths |
| 5999 |
% \changes{v1.13}{2012/08/19}{Fixed typos and changed the names} |
| 6000 |
% \begin{macrocode} |
| 6001 |
\newdimen\l_MT_above_intertext_sep |
| 6002 |
\newdimen\l_MT_below_intertext_sep |
| 6003 |
\define@key{\MT_options_name:} |
| 6004 |
{aboveintertextdim}{\setlength\l_MT_above_intertext_sep{#1}} |
| 6005 |
\define@key{\MT_options_name:} |
| 6006 |
{belowintertextdim}{\setlength\l_MT_below_intertext_sep{#1}} |
| 6007 |
\define@key{\MT_options_name:} |
| 6008 |
{above-intertext-dim}{\setlength\l_MT_above_intertext_sep{#1}} |
| 6009 |
\define@key{\MT_options_name:} |
| 6010 |
{below-intertext-dim}{\setlength\l_MT_below_intertext_sep{#1}} |
| 6011 |
\define@key{\MT_options_name:} |
| 6012 |
{above-intertext-sep}{\setlength\l_MT_above_intertext_sep{#1}} |
| 6013 |
\define@key{\MT_options_name:} |
| 6014 |
{below-intertext-sep}{\setlength\l_MT_below_intertext_sep{#1}} |
| 6015 |
% \end{macrocode} |
| 6016 |
% Their default values are zero. Now for our extended version of |
| 6017 |
% CCShan's solution. |
| 6018 |
% \begin{macrocode} |
| 6019 |
\def\MT_intertext: {% |
| 6020 |
\def\intertext##1{% |
| 6021 |
\ifvmode\else\\\@empty\fi |
| 6022 |
\noalign{% |
| 6023 |
\penalty\postdisplaypenalty\vskip\belowdisplayskip |
| 6024 |
\vskip-\lineskiplimit % CCS |
| 6025 |
\vskip\normallineskiplimit % CCS |
| 6026 |
\vskip\l_MT_above_intertext_sep |
| 6027 |
\vbox{\normalbaselines |
| 6028 |
% \end{macrocode} |
| 6029 |
% \changes{v1.17}{2015/06/17}{Added extra `in list' check} |
| 6030 |
% Johannes Böttcher has reported a problem in \cs{intertext} in |
| 6031 |
% relation to usage within lists or constructs that locally changes |
| 6032 |
% the margin (often implemented as a list). Markus Kohm suggested to |
| 6033 |
% test not only \cs{linewidth} against \cs{columnwidth} but also if |
| 6034 |
% \cs{@totalleftmargin} is not zero. The implementation used is due to |
| 6035 |
% David Carlisle. |
| 6036 |
% \changes{v1.19}{2016/05/26}{Added \cs{ignorespaces} after |
| 6037 |
% \cs{noindent}, bug inherited from \pkg{amsmath}} |
| 6038 |
% \begin{macrocode} |
| 6039 |
\ifdim |
| 6040 |
\ifdim\@totalleftmargin=\z@ |
| 6041 |
\linewidth |
| 6042 |
\else |
| 6043 |
-\maxdimen |
| 6044 |
\fi |
| 6045 |
=\columnwidth |
| 6046 |
\else \parshape\@ne \@totalleftmargin \linewidth |
| 6047 |
\fi |
| 6048 |
\noindent\ignorespaces##1\par}% |
| 6049 |
\penalty\predisplaypenalty\vskip\abovedisplayskip% |
| 6050 |
\vskip-\lineskiplimit % CCS |
| 6051 |
\vskip\normallineskiplimit % CCS |
| 6052 |
% \end{macrocode} |
| 6053 |
% \changes{v1.21}{2018/01/08}{Typo, it should use \texttt{\_below\_} |
| 6054 |
% not \texttt{\_above\_}} |
| 6055 |
% \begin{macrocode} |
| 6056 |
\vskip\l_MT_below_intertext_sep |
| 6057 |
}% |
| 6058 |
}% |
| 6059 |
% \end{macrocode} |
| 6060 |
% We might as well hook on to this and only activate |
| 6061 |
% \cs{shortintertext} whenever \cs{intertext} is active. This allows |
| 6062 |
% us to get the same error messages as \cs{intertext}. |
| 6063 |
% \changes{v1.19}{2017/03/31}{Added} |
| 6064 |
% \begin{macrocode} |
| 6065 |
% also activate \shortintertext, such that is is only available when |
| 6066 |
% \intertext is |
| 6067 |
\MH_let:NwN \shortintertext \shortintertext@ |
| 6068 |
} |
| 6069 |
% \end{macrocode} |
| 6070 |
% And provide a key to switch |
| 6071 |
% \changes{v1.19}{2017/03/31}{Changed \cs{MT_orig_intertext_true:}} |
| 6072 |
% Changed \cs{MT_orig_intertext_true:} to also activate |
| 6073 |
% \cs{shortintertext}, because when this is active, our change to |
| 6074 |
% \cs{intertext@} is not active. |
| 6075 |
% \begin{macrocode} |
| 6076 |
\def\MT_orig_intertext_true: { |
| 6077 |
\MH_let:NwN \intertext@ \MT_orig_intertext: |
| 6078 |
\MH_let:NwN \shortintertext \shortintertext@ |
| 6079 |
} |
| 6080 |
\def\MT_orig_intertext_false: { \MH_let:NwN \intertext@ \MT_intertext: } |
| 6081 |
\define@key{\MT_options_name:}{original-intertext}[true]{ |
| 6082 |
\@nameuse{MT_orig_intertext_#1:} |
| 6083 |
} |
| 6084 |
% \end{macrocode} |
| 6085 |
% And use the new version as default. |
| 6086 |
% \begin{macrocode} |
| 6087 |
\setkeys{\MT_options_name:}{ |
| 6088 |
original-intertext=false |
| 6089 |
} |
| 6090 |
% \end{macrocode} |
| 6091 |
% |
| 6092 |
% \end{macro} |
| 6093 |
% \end{macro} |
| 6094 |
% \end{macro} |
| 6095 |
% \end{macro} |
| 6096 |
% |
| 6097 |
% Gabriel Zachmann, Donald Arseneau on comp.text.tex 2000/05/12-13 |
| 6098 |
% \begin{macro}{\shortintertext} |
| 6099 |
% \begin{macro}{\MT_orig_shortintertext} |
| 6100 |
% \begin{macro}{\MT_shortintertext} |
| 6101 |
% \begin{macro}{\l_above_shortintertext_sep} |
| 6102 |
% \begin{macro}{\l_below_shortintertext_sep} |
| 6103 |
% This is like \cs{intertext} but uses shorter skips between the |
| 6104 |
% math. Again this turned out to have the same problem as |
| 6105 |
% \cs{intertext}, so we provide two versions. |
| 6106 |
% \begin{macrocode} |
| 6107 |
\def\MT_orig_shortintertext:n #1{% |
| 6108 |
\ifvmode\else\\\@empty\fi |
| 6109 |
\noalign{% |
| 6110 |
\penalty\postdisplaypenalty\vskip\abovedisplayshortskip |
| 6111 |
\vbox{\normalbaselines |
| 6112 |
% \end{macrocode} |
| 6113 |
% \changes{v1.17}{2015/06/17}{Added extra `in list' check} |
| 6114 |
% Same comment as for \cs{intertext} above. |
| 6115 |
% \changes{v1.19}{2016/05/26}{Added \cs{ignorespaces} after |
| 6116 |
% \cs{noindent}, bug inherited from \pkg{amsmath}} |
| 6117 |
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} |
| 6118 |
% \begin{macrocode} |
| 6119 |
\MH_if_dim:w |
| 6120 |
\MH_if_dim:w \@totalleftmargin=\z@ |
| 6121 |
\linewidth |
| 6122 |
\MH_else: |
| 6123 |
-\maxdimen |
| 6124 |
\MH_fi: |
| 6125 |
=\columnwidth |
| 6126 |
\MH_else: |
| 6127 |
\parshape\@ne \@totalleftmargin \linewidth |
| 6128 |
\MH_fi: |
| 6129 |
\noindent\ignorespaces#1\par}% |
| 6130 |
\penalty\predisplaypenalty\vskip\abovedisplayshortskip% |
| 6131 |
}% |
| 6132 |
} |
| 6133 |
% \end{macrocode} |
| 6134 |
% Lengths like above |
| 6135 |
% \changes{v1.13}{2012/08/19}{The option was named differently in the |
| 6136 |
% manual. Also renamed to use the postfix \emph{sep} instead. Though |
| 6137 |
% the old names remain for compatibility.} |
| 6138 |
% \changes{v1.14}{2014/01/20}{Apparently did not check it good enough, |
| 6139 |
% the option should have shortintertext not short-intertext} |
| 6140 |
% \begin{macrocode} |
| 6141 |
\newdimen\l_MT_above_shortintertext_sep |
| 6142 |
\newdimen\l_MT_below_shortintertext_sep |
| 6143 |
\define@key{\MT_options_name:} |
| 6144 |
{aboveshortintertextdim}{\setlength \l_MT_above_shortintertext_sep{#1}} |
| 6145 |
\define@key{\MT_options_name:} |
| 6146 |
{belowshortintertextdim}{\setlength \l_MT_below_shortintertext_sep{#1}} |
| 6147 |
\define@key{\MT_options_name:} |
| 6148 |
{above-short-intertext-dim}{\setlength \l_MT_above_shortintertext_sep{#1}} |
| 6149 |
% old typo in manual |
| 6150 |
\define@key{\MT_options_name:} |
| 6151 |
{below-short-intertext-dim}{\setlength \l_MT_below_shortintertext_sep{#1}} |
| 6152 |
\define@key{\MT_options_name:} |
| 6153 |
{above-short-intertext-sep}{\setlength \l_MT_above_shortintertext_sep{#1}} |
| 6154 |
% old typo in manual |
| 6155 |
\define@key{\MT_options_name:} |
| 6156 |
{below-short-intertext-sep}{\setlength \l_MT_below_shortintertext_sep{#1}} |
| 6157 |
\define@key{\MT_options_name:} |
| 6158 |
{above-shortintertext-sep}{\setlength \l_MT_above_shortintertext_sep{#1}} |
| 6159 |
\define@key{\MT_options_name:} |
| 6160 |
{below-shortintertext-sep}{\setlength \l_MT_below_shortintertext_sep{#1}} |
| 6161 |
% \end{macrocode} |
| 6162 |
% Looks best with the `old' values of the original \cs{jot} |
| 6163 |
% setting. So we set them to 3pt each. |
| 6164 |
% \begin{macrocode} |
| 6165 |
\setkeys{\MT_options_name:}{ |
| 6166 |
aboveshortintertextdim=3pt, |
| 6167 |
belowshortintertextdim=3pt |
| 6168 |
} |
| 6169 |
% \end{macrocode} |
| 6170 |
% Next, just add the same as we did for \cs{intertext} |
| 6171 |
% \begin{macrocode} |
| 6172 |
\def\MT_shortintertext:n #1{% |
| 6173 |
\ifvmode\else\\\@empty\fi |
| 6174 |
\noalign{% |
| 6175 |
\penalty\postdisplaypenalty\vskip\abovedisplayshortskip |
| 6176 |
\vskip-\lineskiplimit |
| 6177 |
\vskip\normallineskiplimit |
| 6178 |
\vskip\l_MT_above_shortintertext_sep |
| 6179 |
\vbox{\normalbaselines |
| 6180 |
% \end{macrocode} |
| 6181 |
% \changes{v1.17}{2015/06/17}{Added extra `in list' check} |
| 6182 |
% Same comment as for \cs{intertext} above. |
| 6183 |
% \changes{v1.19}{2016/05/26}{Added \cs{ignorespaces} after |
| 6184 |
% \cs{noindent}, bug inherited from \pkg{amsmath}} |
| 6185 |
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} |
| 6186 |
% \begin{macrocode} |
| 6187 |
\MH_if_dim:w |
| 6188 |
\MH_if_dim:w \@totalleftmargin=\z@ |
| 6189 |
\linewidth |
| 6190 |
\MH_else: |
| 6191 |
-\maxdimen |
| 6192 |
\MH_fi: |
| 6193 |
=\columnwidth |
| 6194 |
\MH_else: |
| 6195 |
\parshape\@ne \@totalleftmargin \linewidth |
| 6196 |
\MH_fi: |
| 6197 |
\noindent\ignorespaces#1\par}% |
| 6198 |
\penalty\predisplaypenalty\vskip\abovedisplayshortskip% |
| 6199 |
\vskip-\lineskiplimit |
| 6200 |
\vskip\normallineskiplimit |
| 6201 |
\vskip\l_MT_below_shortintertext_sep |
| 6202 |
}% |
| 6203 |
} |
| 6204 |
% \end{macrocode} |
| 6205 |
% Next we need to be able to switch. |
| 6206 |
% \changes{v1.19}{2017/03/31}{Changed \cs{shortintertext} to be |
| 6207 |
% internal here.} |
| 6208 |
% \begin{macrocode} |
| 6209 |
\def\MT_orig_shortintertext_true: { \MH_let:NwN \shortintertext@ \MT_orig_shortintertext:n } |
| 6210 |
\def\MT_orig_shortintertext_false: { \MH_let:NwN \shortintertext@ \MT_shortintertext:n } |
| 6211 |
% \end{macrocode} |
| 6212 |
% Next make \cs{shortintertext} a no-go everywhere. Thus \cs{shortintertext} is only |
| 6213 |
% available when \cs{intertext} is, or when |
| 6214 |
% \verb+original-intertext=true+ is used. |
| 6215 |
% \changes{v1.19}{2017/03/31}{Added} |
| 6216 |
% \begin{macrocode} |
| 6217 |
\newcommand{\shortintertext}{\@amsmath@err{\Invalid@@\shortintertext}\@eha} |
| 6218 |
% \end{macrocode} |
| 6219 |
% \begin{macrocode} |
| 6220 |
\define@key{\MT_options_name:}{original-shortintertext}[true]{ |
| 6221 |
\@nameuse{MT_orig_shortintertext_#1:} |
| 6222 |
} |
| 6223 |
% \end{macrocode} |
| 6224 |
% With the updated one as the default. |
| 6225 |
% \begin{macrocode} |
| 6226 |
\setkeys{\MT_options_name:}{ |
| 6227 |
original-shortintertext=false |
| 6228 |
} |
| 6229 |
% \end{macrocode} |
| 6230 |
% \end{macro} |
| 6231 |
% \end{macro} |
| 6232 |
% \end{macro} |
| 6233 |
% \end{macro} |
| 6234 |
% \end{macro} |
| 6235 |
% |
| 6236 |
% \subsection{Fine-tuning mathematical layout} |
| 6237 |
% |
| 6238 |
% \subsubsection{A complement to \texttt{\textbackslash smash}, |
| 6239 |
% \texttt{\textbackslash llap}, and \texttt{\textbackslash rlap}} |
| 6240 |
% \begin{macro}{\clap} |
| 6241 |
% \begin{macro}{\mathllap} |
| 6242 |
% \begin{macro}{\mathrlap} |
| 6243 |
% \begin{macro}{\mathclap} |
| 6244 |
% \begin{macro}{\MT_mathllap:Nn} |
| 6245 |
% \begin{macro}{\MT_mathrlap:Nn} |
| 6246 |
% \begin{macro}{\MT_mathclap:Nn} |
| 6247 |
% First we'll \cs{provide} those macros (they are so simple that I |
| 6248 |
% think other packages might define them as well). |
| 6249 |
% \changes{v1.15}{2021/03/04}{Add \cs{relax} before the \cs{ifx}'s to |
| 6250 |
% prevent corner case premature expansions} |
| 6251 |
% \begin{macrocode} |
| 6252 |
\providecommand*\clap[1]{\hb@xt@\z@{\hss#1\hss}} |
| 6253 |
\providecommand*\mathllap[1][\@empty]{ |
| 6254 |
\relax\ifx\@empty#1\@empty |
| 6255 |
\expandafter \mathpalette \expandafter \MT_mathllap:Nn |
| 6256 |
\else |
| 6257 |
\expandafter \MT_mathllap:Nn \expandafter #1 |
| 6258 |
\fi |
| 6259 |
} |
| 6260 |
\providecommand*\mathrlap[1][\@empty]{ |
| 6261 |
\relax\ifx\@empty#1\@empty |
| 6262 |
\expandafter \mathpalette \expandafter \MT_mathrlap:Nn |
| 6263 |
\else |
| 6264 |
\expandafter \MT_mathrlap:Nn \expandafter #1 |
| 6265 |
\fi |
| 6266 |
} |
| 6267 |
\providecommand*\mathclap[1][\@empty]{ |
| 6268 |
\relax\ifx\@empty#1\@empty |
| 6269 |
\expandafter \mathpalette \expandafter \MT_mathclap:Nn |
| 6270 |
\else |
| 6271 |
\expandafter \MT_mathclap:Nn \expandafter #1 |
| 6272 |
\fi |
| 6273 |
} |
| 6274 |
% \end{macrocode} |
| 6275 |
% We have to insert |{}| because we otherwise risk triggering a |
| 6276 |
% ``feature'' in \TeX. |
| 6277 |
% \begin{macrocode} |
| 6278 |
\def\MT_mathllap:Nn #1#2{{}\llap{$\m@th#1{#2}$}} |
| 6279 |
\def\MT_mathrlap:Nn #1#2{{}\rlap{$\m@th#1{#2}$}} |
| 6280 |
\def\MT_mathclap:Nn #1#2{{}\clap{$\m@th#1{#2}$}} |
| 6281 |
% \end{macrocode} |
| 6282 |
% \end{macro} |
| 6283 |
% \end{macro} |
| 6284 |
% \end{macro} |
| 6285 |
% \end{macro} |
| 6286 |
% \end{macro} |
| 6287 |
% \end{macro} |
| 6288 |
% \end{macro} |
| 6289 |
% \begin{macro}{\mathmbox} |
| 6290 |
% \begin{macro}{\MT_mathmbox:nn} |
| 6291 |
% \begin{macro}{\mathmakebox} |
| 6292 |
% \begin{macro}{\MT_mathmakebox_I:w} |
| 6293 |
% \begin{macro}{\MT_mathmakebox_II:w} |
| 6294 |
% \begin{macro}{\MT_mathmakebox_III:w} |
| 6295 |
% Then the \cs{mathmbox}\marg{arg} and |
| 6296 |
% \cs{mathmakebox}\oarg{width}\oarg{pos}\marg{arg} macros which are |
| 6297 |
% very similar to \cs{mbox} and \cs{makebox}. The differences are: |
| 6298 |
% \begin{itemize} |
| 6299 |
% \item \meta{arg} is set in math mode of course. |
| 6300 |
% \item No need for \cs{leavevmode} as we're in math mode. |
| 6301 |
% \item No need to make them \cs{long} (we're still in math mode). |
| 6302 |
% \item No need to support a picture version. |
| 6303 |
% \end{itemize} |
| 6304 |
% The first is easy. |
| 6305 |
% \begin{macrocode} |
| 6306 |
\providecommand*\mathmbox{\mathpalette\MT_mathmbox:nn} |
| 6307 |
\def\MT_mathmbox:nn #1#2{\mbox{$\m@th#1#2$}} |
| 6308 |
% \end{macrocode} |
| 6309 |
% We scan for the optional arguments first. |
| 6310 |
% \begin{macrocode} |
| 6311 |
\providecommand*\mathmakebox{ |
| 6312 |
\@ifnextchar[ \MT_mathmakebox_I:w |
| 6313 |
\mathmbox} |
| 6314 |
\def\MT_mathmakebox_I:w[#1]{% |
| 6315 |
\@ifnextchar[ {\MT_mathmakebox_II:w[#1]} |
| 6316 |
{\MT_mathmakebox_II:w[#1][c]}} |
| 6317 |
% \end{macrocode} |
| 6318 |
% We had to get the optional arguments out of the way before calling |
| 6319 |
% upon the powers of \cs{mathpalette}. |
| 6320 |
% \begin{macrocode} |
| 6321 |
\def\MT_mathmakebox_II:w[#1][#2]{ |
| 6322 |
\mathpalette{\MT_mathmakebox_III:w[#1][#2]}} |
| 6323 |
\def\MT_mathmakebox_III:w[#1][#2]#3#4{% |
| 6324 |
\@begin@tempboxa\hbox{$\m@th#3#4$}% |
| 6325 |
\setlength\@tempdima{#1}% |
| 6326 |
\hbox{\hb@xt@\@tempdima{\csname bm@#2\endcsname}}% |
| 6327 |
\@end@tempboxa} |
| 6328 |
% \end{macrocode} |
| 6329 |
% \end{macro} |
| 6330 |
% \end{macro} |
| 6331 |
% \end{macro} |
| 6332 |
% \end{macro} |
| 6333 |
% \end{macro} |
| 6334 |
% \end{macro} |
| 6335 |
% \begin{macro}{\mathsm@sh} |
| 6336 |
% Fix \cs{smash}. |
| 6337 |
% \begin{macrocode} |
| 6338 |
\def\mathsm@sh#1#2{% |
| 6339 |
\setbox\z@\hbox{$\m@th#1{#2}$}{}\finsm@sh} |
| 6340 |
% \end{macrocode} |
| 6341 |
% \end{macro} |
| 6342 |
% |
| 6343 |
% |
| 6344 |
% \subsubsection{A cramped style} |
| 6345 |
% |
| 6346 |
% comp.text.tex on 1992/07/21 by Michael Herschorn. |
| 6347 |
% With speed-ups by the Grand Wizard himself as shown on |
| 6348 |
% \begin{quote}\rightskip-\leftmargini |
| 6349 |
% \url{http://mirrors.ctan.org/info/digests/tex-implementors/042} |
| 6350 |
% \end{quote} |
| 6351 |
% The (better) user interface by the author. |
| 6352 |
% |
| 6353 |
% \begin{macro}{\cramped} |
| 6354 |
% Make sure the expansion is timed correctly. |
| 6355 |
% \changes{v1.15}{2021/03/04}{Add \cs{relax} before the \cs{ifx}'s to |
| 6356 |
% prevent corner case premature expansions} |
| 6357 |
% \begin{macrocode} |
| 6358 |
\providecommand*\cramped[1][\@empty]{ |
| 6359 |
\relax\ifx\@empty#1\@empty |
| 6360 |
\expandafter \mathpalette \expandafter \MT_cramped_internal:Nn |
| 6361 |
\else |
| 6362 |
\expandafter \MT_cramped_internal:Nn \expandafter #1 |
| 6363 |
\fi |
| 6364 |
} |
| 6365 |
% \end{macrocode} |
| 6366 |
% \end{macro} |
| 6367 |
% \begin{macro}{\MT_cramped_internal:Nn} |
| 6368 |
% The internal command. |
| 6369 |
% \begin{macrocode} |
| 6370 |
\def\MT_cramped_internal:Nn #1#2{ |
| 6371 |
% \end{macrocode} |
| 6372 |
% Create a box containing the math and force a cramped style by |
| 6373 |
% issuing a non-existing radical. |
| 6374 |
% \changes{v1.25}{2020/12/16}{Don't set \cs{nulldelimiterspace} to |
| 6375 |
% zero, back kern intead, solves issue \#18} |
| 6376 |
% \changes{v1.25}{2021/03/18}{placed \cs{sbox}\cs{z@} by |
| 6377 |
% \cs{setbox}\cs{z@}\cs{hbox} to better handle expansion in |
| 6378 |
% \env{crampedsubarray}, see issue \#17} |
| 6379 |
% \begin{macrocode} |
| 6380 |
%% \sbox\z@{$\m@th#1\kern-\nulldelimiterspace\radical\z@{#2}$} |
| 6381 |
\setbox\z@\hbox{$\m@th#1\kern-\nulldelimiterspace\radical\z@{#2}$} |
| 6382 |
% \end{macrocode} |
| 6383 |
% Then make sure the height is correct. |
| 6384 |
% \begin{macrocode} |
| 6385 |
\ifx#1\displaystyle |
| 6386 |
\dimen@=\fontdimen8\textfont3 |
| 6387 |
\advance\dimen@ .25\fontdimen5\textfont2 |
| 6388 |
\else |
| 6389 |
\dimen@=1.25\fontdimen8 |
| 6390 |
\ifx#1\textstyle\textfont |
| 6391 |
\else |
| 6392 |
\ifx#1\scriptstyle |
| 6393 |
\scriptfont |
| 6394 |
\else |
| 6395 |
\scriptscriptfont |
| 6396 |
\fi |
| 6397 |
\fi |
| 6398 |
3 |
| 6399 |
\fi |
| 6400 |
\advance\dimen@-\ht\z@ \ht\z@=-\dimen@ |
| 6401 |
% \end{macrocode} |
| 6402 |
% Leave vertical mode before typesetting the box and add a |
| 6403 |
% \texttt{\{\}} in front to gard against unnecessary reboxing |
| 6404 |
% \changes{v1.25}{2021/03/04}{Added vmode protection and reboxing |
| 6405 |
% gard, see issue \#19} |
| 6406 |
% \begin{macrocode} |
| 6407 |
\ifvmode\leavevmode\fi |
| 6408 |
{}\box\z@ |
| 6409 |
} |
| 6410 |
% \end{macrocode} |
| 6411 |
% For LuaLaTeX we can use much less code as they have |
| 6412 |
% their own direct \cs{cramped...} macros. Directly listed |
| 6413 |
% from \verb|lualatex-math.sty| v1.9 2020/09/25 by Philipp Stephani. Quote: ``Here the |
| 6414 |
% additional set of braces is absolutely necessary, otherwise the changed |
| 6415 |
% mathematical style would be applied to the material after the |
| 6416 |
% \cs{mathchoice} construct. As the original (mathtools) command works in both text and |
| 6417 |
% math mode, we use \cs{ensuremath} here.'' |
| 6418 |
% \begin{macrocode} |
| 6419 |
\ifx\directlua\@undefined\else |
| 6420 |
\def\MT_cramped_internal:Nn #1#2{ |
| 6421 |
{ |
| 6422 |
\ensuremath { |
| 6423 |
\use:c { cramped \cs_to_str:N #1 } #2 |
| 6424 |
} |
| 6425 |
} |
| 6426 |
} |
| 6427 |
\fi |
| 6428 |
|
| 6429 |
% \end{macrocode} |
| 6430 |
% \end{macro} |
| 6431 |
% |
| 6432 |
% \subsubsection{Cramped versions of \texttt{\textbackslash |
| 6433 |
% mathllap}, \texttt{\textbackslash mathclap}, and |
| 6434 |
% \texttt{\textbackslash mathrlap}} |
| 6435 |
% \begin{macro}{\crampedllap} |
| 6436 |
% \begin{macro}{\MT_cramped_llap_internal:Nn} |
| 6437 |
% \begin{macro}{\crampedclap} |
| 6438 |
% \begin{macro}{\MT_cramped_clap_internal:Nn} |
| 6439 |
% \begin{macro}{\crampedrlap} |
| 6440 |
% \begin{macro}{\MT_cramped_rlap_internal:Nn} |
| 6441 |
% Cramped versions of \cs{mathXlap} (for speed). Made by the author. |
| 6442 |
% \changes{v1.15}{2021/03/04}{Add \cs{relax} before the \cs{ifx}'s to |
| 6443 |
% prevent corner case premature expansions} |
| 6444 |
% \begin{macrocode} |
| 6445 |
\providecommand*\crampedllap[1][\@empty]{ |
| 6446 |
\relax\ifx\@empty#1\@empty |
| 6447 |
\expandafter \mathpalette \expandafter \MT_cramped_llap_internal:Nn |
| 6448 |
\else |
| 6449 |
\expandafter \MT_cramped_llap_internal:Nn \expandafter #1 |
| 6450 |
\fi |
| 6451 |
} |
| 6452 |
\def\MT_cramped_llap_internal:Nn #1#2{ |
| 6453 |
{}\llap{\MT_cramped_internal:Nn #1{#2}} |
| 6454 |
} |
| 6455 |
\providecommand*\crampedclap[1][\@empty]{ |
| 6456 |
\relax\ifx\@empty#1\@empty |
| 6457 |
\expandafter \mathpalette \expandafter \MT_cramped_clap_internal:Nn |
| 6458 |
\else |
| 6459 |
\expandafter \MT_cramped_clap_internal:Nn \expandafter #1 |
| 6460 |
\fi |
| 6461 |
} |
| 6462 |
\def\MT_cramped_clap_internal:Nn #1#2{ |
| 6463 |
{}\clap{\MT_cramped_internal:Nn #1{#2}} |
| 6464 |
} |
| 6465 |
\providecommand*\crampedrlap[1][\@empty]{ |
| 6466 |
\relax\ifx\@empty#1\@empty |
| 6467 |
\expandafter \mathpalette \expandafter \MT_cramped_rlap_internal:Nn |
| 6468 |
\else |
| 6469 |
\expandafter \MT_cramped_rlap_internal:Nn \expandafter #1 |
| 6470 |
\fi |
| 6471 |
} |
| 6472 |
\def\MT_cramped_rlap_internal:Nn #1#2{ |
| 6473 |
{}\rlap{\MT_cramped_internal:Nn #1{#2}} |
| 6474 |
} |
| 6475 |
% \end{macrocode} |
| 6476 |
% \end{macro} |
| 6477 |
% \end{macro} |
| 6478 |
% \end{macro} |
| 6479 |
% \end{macro} |
| 6480 |
% \end{macro} |
| 6481 |
% \end{macro} |
| 6482 |
% |
| 6483 |
% |
| 6484 |
% |
| 6485 |
% \subsubsection{Cramped versions of subarray and \cs{substack}} |
| 6486 |
% |
| 6487 |
% |
| 6488 |
% \changes{v1.22}{2019/07/22}{Added cramped versions of subarray and |
| 6489 |
% \cs{substack}} This was suggested by Henri Menke in |
| 6490 |
% \url{https://github.com/latex3/latex2e/issues/149} and |
| 6491 |
% \url{https://chat.stackexchange.com/transcript/message/50943985#50943985}. |
| 6492 |
% As we are slowly moving away from the expl3 like syntax, we'll |
| 6493 |
% implement this |
| 6494 |
% with an adjusted copy of \env{subarray} from \pkg{amsmath}. |
| 6495 |
% \changes{v1.26}{2021/03/27}{Fresh copy of subarray from \pkg{amsmath} |
| 6496 |
% including the lualatex branch} |
| 6497 |
% \begin{environment}{crampedsubarray} |
| 6498 |
% \begin{macrocode} |
| 6499 |
\ifx\directlua\@undefined |
| 6500 |
\newenvironment{crampedsubarray}[1]{% |
| 6501 |
\vcenter\bgroup |
| 6502 |
\Let@ \restore@math@cr \default@tag |
| 6503 |
\baselineskip\fontdimen10 \scriptfont\tw@ |
| 6504 |
\advance\baselineskip\fontdimen12 \scriptfont\tw@ |
| 6505 |
\lineskip\thr@@\fontdimen8 \scriptfont\thr@@ |
| 6506 |
\lineskiplimit\lineskip |
| 6507 |
\ialign\bgroup\ifx c#1\hfil\fi |
| 6508 |
% \end{macrocode} |
| 6509 |
% Though here we ought to use the proper cramped internal macro, as |
| 6510 |
% otherwise there will be a slight difference in vertical spacing |
| 6511 |
% \changes{v1.25}{2021/03/18}{Added \cs{MT_cramped_internal:Nn}, see |
| 6512 |
% issue \#17} |
| 6513 |
% \begin{macrocode} |
| 6514 |
%%$\m@th\scriptstyle\kern-\nulldelimiterspace\radical\z@{##}$% <-- changed line |
| 6515 |
\span\MT_cramped_internal:Nn \scriptstyle {##}% |
| 6516 |
\hfil\crcr |
| 6517 |
}{% |
| 6518 |
\crcr\egroup\egroup |
| 6519 |
} |
| 6520 |
\else |
| 6521 |
\newenvironment{crampedsubarray}[1]{% |
| 6522 |
\vcenter\bgroup |
| 6523 |
\Let@ \restore@math@cr \default@tag |
| 6524 |
\baselineskip \Umathstacknumup \scriptstyle |
| 6525 |
\advance\baselineskip \Umathstackdenomdown \scriptstyle |
| 6526 |
\lineskip \Umathstackvgap \scriptstyle |
| 6527 |
\lineskiplimit \lineskip |
| 6528 |
\ialign\bgroup\ifx c#1\hfil\fi |
| 6529 |
\Ustartmath |
| 6530 |
% \end{macrocode} |
| 6531 |
% Here we simply use the build in cramped command from LuaLaTeX |
| 6532 |
% \begin{macrocode} |
| 6533 |
\crampedscriptstyle{##} |
| 6534 |
\Ustopmath |
| 6535 |
\hfil\crcr |
| 6536 |
}{% |
| 6537 |
\crcr\egroup\egroup |
| 6538 |
} |
| 6539 |
\fi |
| 6540 |
% \end{macrocode} |
| 6541 |
% \end{environment} |
| 6542 |
% \begin{macro}{\crampedsubstack} |
| 6543 |
% And the identical implementation for \cs{crampedsubstack}: |
| 6544 |
% \begin{macrocode} |
| 6545 |
\newcommand{\crampedsubstack}[1]{\crampedsubarray{c}#1\endcrampedsubarray} |
| 6546 |
% \end{macrocode} |
| 6547 |
% \end{macro} |
| 6548 |
% |
| 6549 |
% |
| 6550 |
% |
| 6551 |
% \section{Macros by Michael J.~Downes} |
| 6552 |
% |
| 6553 |
% The macros in this section are all by Michael J.~Downes. Either |
| 6554 |
% they are straight copies of his original macros or inspired and |
| 6555 |
% extended here. |
| 6556 |
% |
| 6557 |
% |
| 6558 |
% \subsection{Prescript} |
| 6559 |
% \begin{macro}{\prescript} |
| 6560 |
% This command is taken from a posting to comp.text.tex on |
| 6561 |
% December~20th 2000 by Michael J.~Downes. The comments are his. I |
| 6562 |
% have added some formatting options to the arguments so that a user |
| 6563 |
% can emulate the \pkg{isotope} package. |
| 6564 |
% |
| 6565 |
% \changes{v.1.12}{2012/04/19}{Extended \cs{prescript} to change style |
| 6566 |
% if used in say S context. Requestd by Oliver Buerschaper.} |
| 6567 |
% Update 2012: One drawback from MJD's original implementation, is |
| 6568 |
% that the math style is hardwired, such that if used in say |
| 6569 |
% \cs{scriptstyle} context, then the style/size of the prescript |
| 6570 |
% remain the same size. A slightly expensive fix, is to use the |
| 6571 |
% \cs{mathchoice} construction. First exdent MJD's code a little |
| 6572 |
% (keeping his comments) |
| 6573 |
% \begin{macro}{\MT_prescript_inner:} |
| 6574 |
% We make the style an extra forth argument |
| 6575 |
% \begin{macrocode} |
| 6576 |
\newcommand{\MT_prescript_inner:}[4]{ |
| 6577 |
% \end{macrocode} |
| 6578 |
% Put the sup in box 0 and the sub in box 2. |
| 6579 |
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} |
| 6580 |
% \begin{macrocode} |
| 6581 |
\@mathmeasure\z@#4{\MT_prescript_sup:{#1}} |
| 6582 |
\@mathmeasure\tw@#4{\MT_prescript_sub:{#2}} |
| 6583 |
\MH_if_dim:w \wd\tw@>\wd\z@ |
| 6584 |
\setbox\z@\hbox to\wd\tw@{\hfil\unhbox\z@} |
| 6585 |
\MH_else: |
| 6586 |
\setbox\tw@\hbox to\wd\z@{\hfil\unhbox\tw@} |
| 6587 |
\MH_fi: |
| 6588 |
% \end{macrocode} |
| 6589 |
% Do not let a preceding mathord symbol approach without any |
| 6590 |
% intervening space. |
| 6591 |
% \begin{macrocode} |
| 6592 |
\mathop{} |
| 6593 |
% \end{macrocode} |
| 6594 |
% Use \cs{mathopen} to suppress space between the prescripts and the |
| 6595 |
% base object even when the latter is not of type ord. |
| 6596 |
% \begin{macrocode} |
| 6597 |
\mathopen{\vphantom{\MT_prescript_arg:{#3}}}^{\box\z@}\sb{\box\tw@} |
| 6598 |
\MT_prescript_arg:{#3} |
| 6599 |
} |
| 6600 |
% \end{macrocode} |
| 6601 |
% \end{macro} |
| 6602 |
% Next create \cs{prescript} using \cs{mathchoice} |
| 6603 |
% \begin{macrocode} |
| 6604 |
\DeclareRobustCommand{\prescript}[3]{ |
| 6605 |
\mathchoice |
| 6606 |
% \end{macrocode} |
| 6607 |
% In D and T style, we use MJD's default: |
| 6608 |
% \begin{macrocode} |
| 6609 |
{\MT_prescript_inner:{#1}{#2}{#3}{\scriptstyle}} |
| 6610 |
{\MT_prescript_inner:{#1}{#2}{#3}{\scriptstyle}} |
| 6611 |
% \end{macrocode} |
| 6612 |
% In the others we step one style down. Of couse in SS style, using |
| 6613 |
% \cs{scriptscript} may seem wrong, but there is no lower style. |
| 6614 |
% \begin{macrocode} |
| 6615 |
{\MT_prescript_inner:{#1}{#2}{#3}{\scriptscriptstyle}} |
| 6616 |
{\MT_prescript_inner:{#1}{#2}{#3}{\scriptscriptstyle}} |
| 6617 |
} |
| 6618 |
% \end{macrocode} |
| 6619 |
% \end{macro} |
| 6620 |
% Then the named arguments. Can you see I'm preparing for templates? |
| 6621 |
% \begin{macrocode} |
| 6622 |
\define@key{\MT_options_name:} |
| 6623 |
{prescript-sup-format}{\def\MT_prescript_sup:{#1}} |
| 6624 |
\define@key{\MT_options_name:} |
| 6625 |
{prescript-sub-format}{\def\MT_prescript_sub:{#1}} |
| 6626 |
\define@key{\MT_options_name:} |
| 6627 |
{prescript-arg-format}{\def\MT_prescript_arg:{#1}} |
| 6628 |
\setkeys{\MT_options_name:}{ |
| 6629 |
prescript-sup-format={}, |
| 6630 |
prescript-sub-format={}, |
| 6631 |
prescript-arg-format={}, |
| 6632 |
} |
| 6633 |
% \end{macrocode} |
| 6634 |
% |
| 6635 |
% \subsection{Math sizes} |
| 6636 |
% \begin{macro}{\@DeclareMathSizes} |
| 6637 |
% This command is taken from a posting to comp.text.tex on |
| 6638 |
% October~17th 2002 by Michael J.~Downes. The purpose is to be able |
| 6639 |
% to put dimensions on the last three arguments of |
| 6640 |
% \cs{DeclareMathSizes}. |
| 6641 |
% |
| 6642 |
% As of 2015, this fix has made it into the \LaTeX{} kernel. Thus we |
| 6643 |
% only provide the fix for older kernels. |
| 6644 |
% \changes{v1.18}{2015/11/12}{This was now moved into the kernel, thus |
| 6645 |
% we only provide it for older kernels} |
| 6646 |
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} |
| 6647 |
% \begin{macrocode} |
| 6648 |
\ifx\e@alloc\@undefined% kernel thus older than 2015 |
| 6649 |
\def\@DeclareMathSizes #1#2#3#4#5{% |
| 6650 |
\@defaultunits\dimen@ #2pt\relax\@nnil |
| 6651 |
\MH_if:w $#3$% |
| 6652 |
\MH_let:cN {S@\strip@pt\dimen@}\math@fontsfalse |
| 6653 |
\MH_else: |
| 6654 |
\@defaultunits\dimen@ii #3pt\relax\@nnil |
| 6655 |
\@defaultunits\@tempdima #4pt\relax\@nnil |
| 6656 |
\@defaultunits\@tempdimb #5pt\relax\@nnil |
| 6657 |
\toks@{#1}% |
| 6658 |
\expandafter\xdef\csname S@\strip@pt\dimen@\endcsname{% |
| 6659 |
\gdef\noexpand\tf@size{\strip@pt\dimen@ii}% |
| 6660 |
\gdef\noexpand\sf@size{\strip@pt\@tempdima}% |
| 6661 |
\gdef\noexpand\ssf@size{\strip@pt\@tempdimb}% |
| 6662 |
\the\toks@ |
| 6663 |
}% |
| 6664 |
\MH_fi: |
| 6665 |
} |
| 6666 |
\fi |
| 6667 |
% \end{macrocode} |
| 6668 |
% \end{macro} |
| 6669 |
% |
| 6670 |
% \subsection{Mathematics within italic text} |
| 6671 |
% mathic: Michael J.~Downes on comp.text.tex, 1998/05/14. |
| 6672 |
% \begin{macro}{\MT_mathic_true:} |
| 6673 |
% \begin{macro}{\MT_mathic_false:} |
| 6674 |
% Renew \cs{(} so that it detects the slant of the font and inserts |
| 6675 |
% an italic correction. In January 2013 Andrew Swann suggested that |
| 6676 |
% this should be made robust. It is a little tricky, but seems to |
| 6677 |
% work. |
| 6678 |
% \changes{v1.13}{2013/02/11}{Added robustness code} |
| 6679 |
% \begin{macrocode} |
| 6680 |
\def\MT_mathic_true: { |
| 6681 |
\MH_if_boolean:nF {math_italic_corr}{ |
| 6682 |
\MH_set_boolean_T:n {math_italic_corr} |
| 6683 |
% \end{macrocode} |
| 6684 |
% Save the original meaning if you need to go back (note that this |
| 6685 |
% does not save the robust part of the macro, we fix this later on by |
| 6686 |
% rerobustifying). |
| 6687 |
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} |
| 6688 |
% \begin{macrocode} |
| 6689 |
\MH_if_boolean:nTF {robustify}{ |
| 6690 |
\MH_let:NwN \MT_mathic_redeffer: \DeclareRobustCommand |
| 6691 |
}{ |
| 6692 |
\MH_let:NwN \MT_mathic_redeffer: \renewcommand |
| 6693 |
} |
| 6694 |
\MH_let:NwN \MT_begin_inlinemath: \( |
| 6695 |
%\renewcommand*\({ |
| 6696 |
\MT_mathic_redeffer:*\({ |
| 6697 |
\relax\ifmmode\@badmath\else |
| 6698 |
\ifhmode |
| 6699 |
\MH_if_dim:w \fontdimen\@ne\font>\z@ |
| 6700 |
% \end{macrocode} |
| 6701 |
% We have a small problem here, if the user use >>\verb|text~\(|<< then |
| 6702 |
% the italic correction is lost due to the penalty (see \cite{TBT}, |
| 6703 |
% section 4.3.3). However, we \emph{know} what \verb|~| does, a |
| 6704 |
% (positive) penalty and a skip. |
| 6705 |
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} |
| 6706 |
% \begin{macrocode} |
| 6707 |
\MH_if_dim:w \lastskip>\z@ |
| 6708 |
\skip@\lastskip\unskip |
| 6709 |
% \end{macrocode} |
| 6710 |
% \changes{v1.15}{2014/07/16}{Added penalty workaround} |
| 6711 |
% Here is the fix. |
| 6712 |
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} |
| 6713 |
% The code we inserted here in 2014, had a bug in it. The intent was |
| 6714 |
% to move the penalty on to the other side of the italic correction. |
| 6715 |
% But when we reinsert the penalty we only test if the scratch |
| 6716 |
% counter is non-zero, so it may insert random penalties depending |
| 6717 |
% on the non-zero value of \cs{count@}. Simple fix: initialise \cs{count@}. |
| 6718 |
% \changes{v1.31}{2024/10/03}{Added missing counter initialisation, fixing issue \#62} |
| 6719 |
% In chat David C. mentioned that \verb|\ifnum\lastnodetype=13| is a better |
| 6720 |
% test than \verb|\ifnum\lastpenalty>\z@|. Just leaving this here for when we do the |
| 6721 |
% Expl3 conversion. |
| 6722 |
% \begin{macrocode} |
| 6723 |
\MH_if_num:w \lastpenalty>\z@ |
| 6724 |
\count@\lastpenalty\unpenalty |
| 6725 |
\MH_else: |
| 6726 |
\count@\z@ |
| 6727 |
\MH_fi: |
| 6728 |
\@@italiccorr |
| 6729 |
% \end{macrocode} |
| 6730 |
% \changes{v1.15}{2014/07/16}{Added penalty workaround} |
| 6731 |
% And here it is inserted again. |
| 6732 |
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} |
| 6733 |
% \begin{macrocode} |
| 6734 |
\MH_if_num:w \count@>\z@ |
| 6735 |
\penalty\count@ |
| 6736 |
\MH_fi: |
| 6737 |
\hskip\skip@ |
| 6738 |
\MH_else: |
| 6739 |
\@@italiccorr |
| 6740 |
\MH_fi: |
| 6741 |
\MH_fi: |
| 6742 |
% \end{macrocode} |
| 6743 |
% |
| 6744 |
% \changes{v1.31}{2024/10/03}{Also fixed typo here, the last two \cs{fi} comes from non-MH syntax} |
| 6745 |
% \begin{macrocode} |
| 6746 |
\fi |
| 6747 |
$\fi |
| 6748 |
} |
| 6749 |
} |
| 6750 |
} |
| 6751 |
%$ for emacs coloring ;-) |
| 6752 |
% \end{macrocode} |
| 6753 |
% Just for restoring the old behavior. |
| 6754 |
% \begin{macrocode} |
| 6755 |
\def\MT_mathic_false: { |
| 6756 |
\MH_if_boolean:nT {math_italic_corr}{ |
| 6757 |
\MH_set_boolean_F:n {math_italic_corr} |
| 6758 |
% \end{macrocode} |
| 6759 |
% When \cs{(} is robust, we cannot simply relet it to the old value, |
| 6760 |
% as all the robust macro is not saved. Instead we redefined partly |
| 6761 |
% and force robustness. |
| 6762 |
% \begin{macrocode} |
| 6763 |
\MH_if_boolean:nTF {robustify}{ |
| 6764 |
\edef\({\MT_begin_inlinemath:}% |
| 6765 |
\forced_EQ_MakeRobust\(% |
| 6766 |
}{ |
| 6767 |
\MH_let:NwN \( \MT_begin_inlinemath: |
| 6768 |
} |
| 6769 |
} |
| 6770 |
} |
| 6771 |
\MH_new_boolean:n {math_italic_corr} |
| 6772 |
\define@key{\MT_options_name:}{mathic}[true]{ |
| 6773 |
\@ifundefined{MT_mathic_#1:} |
| 6774 |
{ \MT_true_false_error: |
| 6775 |
\@nameuse{MT_mathic_false:} |
| 6776 |
} |
| 6777 |
{ \@nameuse{MT_mathic_#1:} } |
| 6778 |
} |
| 6779 |
% \end{macrocode} |
| 6780 |
% \end{macro} |
| 6781 |
% \end{macro} |
| 6782 |
% |
| 6783 |
% \subsection{Spreading equations} |
| 6784 |
% |
| 6785 |
% Michael J.~Downes on comp.text.tex 1999/08/25 |
| 6786 |
% \begin{environment}{spreadlines} |
| 6787 |
% This is meant to be used outside math, just like |
| 6788 |
% \env{subequations}. |
| 6789 |
% \begin{macrocode} |
| 6790 |
\newenvironment{spreadlines}[1]{ |
| 6791 |
\setlength{\jot}{#1} |
| 6792 |
\ignorespaces |
| 6793 |
}{ \ignorespacesafterend } |
| 6794 |
% \end{macrocode} |
| 6795 |
% \end{environment} |
| 6796 |
% |
| 6797 |
% \subsection{Gathered} |
| 6798 |
% |
| 6799 |
% Inspired by Michael J.~Downes on comp.text.tex 2002/01/17. |
| 6800 |
% \begin{environment}{MT_gathered_env} |
| 6801 |
% Just like the normal \env{gathered}, only here we're allowed to |
| 6802 |
% specify actions before and after each line. |
| 6803 |
% \changes{2017/10/30}{v1.20}{added \cs{alignedspace@left} instead of |
| 6804 |
% \cs{null}\cs{,} as in the other amsmath adjustments} |
| 6805 |
% \begin{macrocode} |
| 6806 |
\MaybeMHPrecedingSpacesOff |
| 6807 |
\newenvironment{MT_gathered_env}[1][c]{% |
| 6808 |
\RIfM@\else |
| 6809 |
\nonmatherr@{\begin{\@currenvir}}% |
| 6810 |
\fi |
| 6811 |
%\null\,% |
| 6812 |
\alignedspace@left% |
| 6813 |
\if #1t\vtop \else \if#1b\vbox \else \vcenter \fi\fi \bgroup |
| 6814 |
\Let@ \chardef\dspbrk@context\@ne \restore@math@cr |
| 6815 |
\spread@equation |
| 6816 |
\ialign\bgroup |
| 6817 |
\MT_gathered_pre: |
| 6818 |
\strut@$\m@th\displaystyle##$ |
| 6819 |
\MT_gathered_post: |
| 6820 |
\crcr |
| 6821 |
}{% |
| 6822 |
\endaligned |
| 6823 |
\MT_gathered_env_end: |
| 6824 |
} |
| 6825 |
\MHPrecedingSpacesOn |
| 6826 |
% \end{macrocode} |
| 6827 |
% \end{environment} |
| 6828 |
% \begin{macro}{\newgathered} |
| 6829 |
% \begin{macro}{\renewgathered} |
| 6830 |
% \begin{environment}{lgathered} |
| 6831 |
% \begin{environment}{rgathered} |
| 6832 |
% \begin{environment}{gathered} |
| 6833 |
% An easier interface. |
| 6834 |
% \begin{macrocode} |
| 6835 |
\newcommand*\newgathered[4]{ |
| 6836 |
\newenvironment{#1} |
| 6837 |
{ \def\MT_gathered_pre:{#2} |
| 6838 |
\def\MT_gathered_post:{#3} |
| 6839 |
\def\MT_gathered_env_end:{#4} |
| 6840 |
\MT_gathered_env |
| 6841 |
}{\endMT_gathered_env} |
| 6842 |
} |
| 6843 |
\newcommand*\renewgathered[4]{ |
| 6844 |
\renewenvironment{#1} |
| 6845 |
{ \def\MT_gathered_pre:{#2} |
| 6846 |
\def\MT_gathered_post:{#3} |
| 6847 |
\def\MT_gathered_env_end:{#4} |
| 6848 |
\MT_gathered_env |
| 6849 |
}{\endMT_gathered_env} |
| 6850 |
} |
| 6851 |
\newgathered{lgathered}{}{\hfil}{} |
| 6852 |
\newgathered{rgathered}{\hfil}{}{} |
| 6853 |
\renewgathered{gathered}{\hfil}{\hfil}{} |
| 6854 |
% \end{macrocode} |
| 6855 |
% \end{environment} |
| 6856 |
% \end{environment} |
| 6857 |
% \end{environment} |
| 6858 |
% \end{macro} |
| 6859 |
% \end{macro} |
| 6860 |
% |
| 6861 |
% \subsection{Split fractions} |
| 6862 |
% |
| 6863 |
% Michael J.~Downes on comp.text.tex 2001/12/06. |
| 6864 |
% \begin{macro}{\splitfrac} |
| 6865 |
% \begin{macro}{\splitdfrac} |
| 6866 |
% These commands use \cs{genfrac} to typeset a split fraction. The |
| 6867 |
% thickness of the fraction rule is simply set to zero. |
| 6868 |
% \begin{macrocode} |
| 6869 |
\newcommand*\splitfrac[2]{% |
| 6870 |
\genfrac{}{}{0pt}{1}% |
| 6871 |
{\textstyle#1\quad\hfill}% |
| 6872 |
{\textstyle\hfill\quad\mathstrut#2}% |
| 6873 |
} |
| 6874 |
\newcommand*\splitdfrac[2]{% |
| 6875 |
\genfrac{}{}{0pt}{0}{#1\quad\hfill}{\hfill\quad\mathstrut #2}% |
| 6876 |
} |
| 6877 |
% \end{macrocode} |
| 6878 |
% \end{macro} |
| 6879 |
% \end{macro} |
| 6880 |
% |
| 6881 |
% |
| 6882 |
% \section{Bug fixes for \pkg{amsmath}} |
| 6883 |
% The following fixes some bugs in \pkg{amsmath}, but only if the |
| 6884 |
% switch is true. |
| 6885 |
% \begin{macrocode} |
| 6886 |
\MH_if_boolean:nT {fixamsmath}{ |
| 6887 |
% \end{macrocode} |
| 6888 |
% \begin{macro}{\place@tag} |
| 6889 |
% This corrects a bug in \pkg{amsmath} affecting tag placement in |
| 6890 |
% \env{flalign}.\footnote{See |
| 6891 |
% \url{http://www.latex-project.org/cgi-bin/ltxbugs2html?pr=amslatex/3591}} |
| 6892 |
% \begin{macrocode} |
| 6893 |
\def\place@tag{% |
| 6894 |
\iftagsleft@ |
| 6895 |
\kern-\tagshift@ |
| 6896 |
% \end{macrocode} |
| 6897 |
% The addition. If we're in \env{flalign} (meaning |
| 6898 |
% $\cs{xatlevel@}=\cs{tw@}$) we skip back by an amount of |
| 6899 |
% \cs{@mathmargin}. This test is also true for the \env{xxalignat} |
| 6900 |
% environment, but it doesn't matter because a)~it's not |
| 6901 |
% supported/described in the documentation anymore so new users |
| 6902 |
% won't know about it and b)~it forbids the use of \cs{tag} |
| 6903 |
% anyway. |
| 6904 |
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} |
| 6905 |
% \begin{macrocode} |
| 6906 |
\if@fleqn |
| 6907 |
\MH_if_num:w \xatlevel@=\tw@ |
| 6908 |
\kern-\@mathmargin |
| 6909 |
\MH_fi: |
| 6910 |
\MH_fi: |
| 6911 |
% \end{macrocode} |
| 6912 |
% End of additions. |
| 6913 |
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} |
| 6914 |
% \begin{macrocode} |
| 6915 |
\MH_if:w 1\shift@tag\row@\relax |
| 6916 |
\rlap{\vbox{% |
| 6917 |
\normalbaselines |
| 6918 |
\boxz@ |
| 6919 |
\vbox to\lineht@{}% |
| 6920 |
\raise@tag |
| 6921 |
}}% |
| 6922 |
\MH_else: |
| 6923 |
\rlap{\boxz@}% |
| 6924 |
\MH_fi: |
| 6925 |
\kern\displaywidth@ |
| 6926 |
\MH_else: |
| 6927 |
\kern-\tagshift@ |
| 6928 |
\MH_if:w 1\shift@tag\row@\relax |
| 6929 |
\llap{\vtop{% |
| 6930 |
\raise@tag |
| 6931 |
\normalbaselines |
| 6932 |
\setbox\@ne\null |
| 6933 |
\dp\@ne\lineht@ |
| 6934 |
\box\@ne |
| 6935 |
\boxz@ |
| 6936 |
}}% |
| 6937 |
\MH_else: |
| 6938 |
\llap{\boxz@}% |
| 6939 |
\MH_fi: |
| 6940 |
\MH_fi: |
| 6941 |
} |
| 6942 |
% \end{macrocode} |
| 6943 |
% \end{macro} |
| 6944 |
% |
| 6945 |
% \begin{macro}{\x@calc@shift@lf} |
| 6946 |
% This corrects a bug\footnote{See |
| 6947 |
% \url{http://www.latex-project.org/cgi-bin/ltxbugs2html?pr=amslatex/3614}} |
| 6948 |
% in \pkg{amsmath} that could cause a non-positive value of the dimension |
| 6949 |
% \cs{@mathmargin} to cause an |
| 6950 |
% \begin{verbatim} |
| 6951 |
% ! Arithmetic overflow. |
| 6952 |
% <recently read> \@tempcntb |
| 6953 |
% \end{verbatim} |
| 6954 |
% when in \mode{fleqn,leqno} mode. Not very comprehensible for the user. |
| 6955 |
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} |
| 6956 |
% \begin{macrocode} |
| 6957 |
\def\x@calc@shift@lf{% |
| 6958 |
\MH_if_dim:w \eqnshift@=\z@ |
| 6959 |
\global\eqnshift@\@mathmargin\relax |
| 6960 |
\alignsep@\displaywidth |
| 6961 |
\advance\alignsep@-\totwidth@ |
| 6962 |
% \end{macrocode} |
| 6963 |
% The addition: If \cs{@tempcntb} is zero we avoid division. |
| 6964 |
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} |
| 6965 |
% \begin{macrocode} |
| 6966 |
\MH_if_num:w \@tempcntb=0 |
| 6967 |
\MH_else: |
| 6968 |
\global\divide\alignsep@\@tempcntb % original line |
| 6969 |
\MH_fi: |
| 6970 |
% \end{macrocode} |
| 6971 |
% Addition end. |
| 6972 |
% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} |
| 6973 |
% \begin{macrocode} |
| 6974 |
\MH_if_dim:w \alignsep@<\minalignsep\relax |
| 6975 |
\global\alignsep@\minalignsep\relax |
| 6976 |
\MH_fi: |
| 6977 |
\MH_fi: |
| 6978 |
\MH_if_dim:w \tag@width\row@>\@tempdima |
| 6979 |
\saveshift@1% |
| 6980 |
\MH_else: |
| 6981 |
\saveshift@0% |
| 6982 |
\MH_fi:}% |
| 6983 |
% \end{macrocode} |
| 6984 |
% \end{macro} |
| 6985 |
% \begin{macrocode} |
| 6986 |
} |
| 6987 |
% \end{macrocode} |
| 6988 |
% End of bug fixing. |
| 6989 |
% |
| 6990 |
% \subsection{Making environments safer} |
| 6991 |
% |
| 6992 |
% \begin{macro}{\aligned@a} |
| 6993 |
% Here we make the \pkg{amsmath} inner environments disallow spaces |
| 6994 |
% before their optional positioning specifier. |
| 6995 |
% \begin{macrocode} |
| 6996 |
\MaybeMHPrecedingSpacesOff |
| 6997 |
\renewcommand\aligned@a[1][c]{\start@aligned{#1}\m@ne} |
| 6998 |
\MHPrecedingSpacesOn |
| 6999 |
% \end{macrocode} |
| 7000 |
% \end{macro} |
| 7001 |
% |
| 7002 |
% \section{Additional features 2020–} |
| 7003 |
% |
| 7004 |
% The selection below is meant for additions addeed 2020 onwards that |
| 7005 |
% are not integrated into existing macros. |
| 7006 |
% |
| 7007 |
% \subsection{\cs{xmathstrut}} |
| 7008 |
% |
| 7009 |
% \begin{macro}{\xmathstrut@box} |
| 7010 |
% \begin{macro}{\xmathstrut@dim} |
| 7011 |
% \begin{macro}{\xmathstrut} |
| 7012 |
% \begin{macro}{\xmathstrut@} |
| 7013 |
% \begin{macro}{\xmathstrut@do} |
| 7014 |
% Suggested and implemented by Frank Mittelbach. The basic idea is to |
| 7015 |
% add (or subtract) a fraction of the total height of the normal math |
| 7016 |
% strut to both the height and depth of the new strut. The input from |
| 7017 |
% the user is suppose to be a decimal number. The value zero results |
| 7018 |
% in no change compared to the normal math strut. |
| 7019 |
% \changes{v1.24}{2020/03/06}{Added \cs{xmathstrut}} |
| 7020 |
% \begin{macrocode} |
| 7021 |
\newbox\xmathstrut@box |
| 7022 |
\newdimen\xmathstrut@dim |
| 7023 |
\def\xmathstrut{\@dblarg\xmathstrut@} |
| 7024 |
\def\xmathstrut@[#1]#2{% |
| 7025 |
\def\xmathstrut@dp{#1}% |
| 7026 |
\vphantom{\mathpalette\xmathstrut@do{#2}}% |
| 7027 |
} |
| 7028 |
% \end{macrocode} |
| 7029 |
% The algorithm is simple. Start by recording the size (a box) of \verb|$($| |
| 7030 |
% in the current style (via \verb|\mathpalette|) |
| 7031 |
% \begin{macrocode} |
| 7032 |
\def\xmathstrut@do#1#2{% |
| 7033 |
\setbox\xmathstrut@box\hbox{$#1($}%)%emacs |
| 7034 |
\xmathstrut@dim\dimexpr\ht\xmathstrut@box+\dp\xmathstrut@box\relax |
| 7035 |
% \end{macrocode} |
| 7036 |
% Then manipulate the size of the box by adding the user input times |
| 7037 |
% the total height of the original box to the height and depth |
| 7038 |
% respectfully. |
| 7039 |
% \begin{macrocode} |
| 7040 |
\ht\xmathstrut@box\dimexpr\ht\xmathstrut@box |
| 7041 |
+#2\xmathstrut@dim |
| 7042 |
\relax |
| 7043 |
\dp\xmathstrut@box\dimexpr\dp\xmathstrut@box |
| 7044 |
+\xmathstrut@dp\xmathstrut@dim |
| 7045 |
\relax |
| 7046 |
% \end{macrocode} |
| 7047 |
% In the end ship the modified box (it is typeset inside a \verb|\vphantom|). |
| 7048 |
% \begin{macrocode} |
| 7049 |
\box\xmathstrut@box} |
| 7050 |
|
| 7051 |
% \end{macrocode} |
| 7052 |
% Do note that this means that for \verb|\xmathstrut{0.1}| 10\% is |
| 7053 |
% added twice. But it make explaining \verb|\xmathstrut[0.2]{0.1}| a |
| 7054 |
% lot easier as it is just 10\% added to the height and 20\% added to |
| 7055 |
% the depth. |
| 7056 |
% \end{macro} |
| 7057 |
% \end{macro} |
| 7058 |
% \end{macro} |
| 7059 |
% \end{macro} |
| 7060 |
% \end{macro} |
| 7061 |
% |
| 7062 |
% This is the end of the \pkg{mathtools} package. |
| 7063 |
% \begin{macrocode} |
| 7064 |
%</package> |
| 7065 |
% \end{macrocode} |
| 7066 |
% |
| 7067 |
% \Finale |
| 7068 |
\endinput |