| 1 |
%%% perfectcut.sty documentation |
| 2 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3 |
%%% |
| 4 |
%%% Author: Guillaume Munch-Maccagnoni |
| 5 |
%%% https://gitlab.com/gadmm/perfectcut |
| 6 |
%%% |
| 7 |
%%% This work may be distributed and/or modified under the conditions of |
| 8 |
%%% the LaTeX Project Public License, either version 1.3 of this license |
| 9 |
%%% or (at your option) any later version. Refer to the README file. |
| 10 |
%%% |
| 11 |
\documentclass[12pt,a4paper,british]{scrartcl} |
| 12 |
\usepackage[T1]{fontenc} |
| 13 |
\usepackage[latin9]{inputenc} |
| 14 |
\setcounter{secnumdepth}{1} |
| 15 |
\setcounter{tocdepth}{1} |
| 16 |
\usepackage{babel} |
| 17 |
\usepackage{array} |
| 18 |
\usepackage{booktabs} |
| 19 |
\usepackage{calc} |
| 20 |
\usepackage{amsmath} |
| 21 |
\usepackage[unicode=true]{hyperref} |
| 22 |
\usepackage{perfectcut} |
| 23 |
\usepackage{stix} |
| 24 |
\renewcommand*\ttdefault{txtt} |
| 25 |
\usepackage[oldstyle,lining,scale=0.97]{sourcesanspro} |
| 26 |
\usepackage[protrusion=true,expansion=true,tracking=false,kerning=true,spacing=true]{microtype} |
| 27 |
|
| 28 |
\begin{document} |
| 29 |
\global\long\def\cut#1#2{\perfectcut{#1}{#2}} |
| 30 |
|
| 31 |
\global\long\def\mt{\bar{\mu}} |
| 32 |
|
| 33 |
|
| 34 |
\title{\texttt{perfectcut.sty} documentation} |
| 35 |
|
| 36 |
\author{\noindent {\large{}Guillaume Munch-Maccagnoni}\thanks{\protect\href{https://gitlab.com/gadmm/perfectcut}{https://gitlab.com/gadmm/perfectcut}}} |
| 37 |
|
| 38 |
\date{3rd September 2017} |
| 39 |
|
| 40 |
\maketitle |
| 41 |
|
| 42 |
\tableofcontents{} |
| 43 |
|
| 44 |
\section{Use} |
| 45 |
|
| 46 |
\paragraph{Original use} |
| 47 |
|
| 48 |
This package supplies the following commands: |
| 49 |
|
| 50 |
\begin{center} |
| 51 |
\begin{tabular}{ll} |
| 52 |
\toprule |
| 53 |
Command & Produces\tabularnewline |
| 54 |
\midrule |
| 55 |
\texttt{\textbackslash perfectcut\{\#1\}\{\#2\}} & $\perfectcut{\#1}{\#2}$\tabularnewline |
| 56 |
\texttt{\textbackslash perfectbra\{\#1\}} & $\perfectbra{\#1}$\tabularnewline |
| 57 |
\texttt{\textbackslash perfectket\{\#1\}} & $\perfectket{\#1}$\tabularnewline |
| 58 |
\bottomrule |
| 59 |
\end{tabular}\quad{}% |
| 60 |
\begin{tabular}{ll} |
| 61 |
\toprule |
| 62 |
Command & Produces\tabularnewline |
| 63 |
\midrule |
| 64 |
\texttt{\textbackslash perfectcase\{\#1\}} & $\perfectcase{\#1}{\#2}$\tabularnewline |
| 65 |
\texttt{\textbackslash perfectbrackets\{\#1\}} & $\perfectbrackets{\#1}$\tabularnewline |
| 66 |
\texttt{\textbackslash perfectparens\{\#1\}} & $\perfectparens{\#1}$\tabularnewline |
| 67 |
\bottomrule |
| 68 |
\end{tabular} |
| 69 |
\par\end{center} |
| 70 |
|
| 71 |
The effect of these commands is to let the delimiters grow according |
| 72 |
to the number of nested \texttt{\textbackslash perfect}\texttt{\emph{command}}s |
| 73 |
(regardless of the size of contents). The package is originally intended |
| 74 |
for solving a notational issue regarding the representation of abstract-machine-like |
| 75 |
calculi in proof theory and computer science. |
| 76 |
|
| 77 |
\paragraph{General use} |
| 78 |
|
| 79 |
The package also defines \texttt{\textbackslash perfectunary} and |
| 80 |
\texttt{\textbackslash perfectbinary} for defining custom delimiters |
| 81 |
that behave similarly to the above ones. These commands should be |
| 82 |
considered when facing the need of nested delimiters that consistently |
| 83 |
grow regardless of the contents. (See ``Advanced Use''.) |
| 84 |
|
| 85 |
\section{Example} |
| 86 |
|
| 87 |
|
| 88 |
\subsection{Using \texttt{perfectcut.sty}} |
| 89 |
|
| 90 |
\global\long\def\cut#1#2{\cutprimitive{#1}{#2}} |
| 91 |
|
| 92 |
\noindent \texttt{\footnotesize{}\textbackslash usepackage\{perfectcut\}}~\\ |
| 93 |
\texttt{\footnotesize{}\textbackslash let\textbackslash cut\textbackslash perfectcut} |
| 94 |
|
| 95 |
\begin{center} |
| 96 |
\fbox{\begin{minipage}[t]{0.8\columnwidth}% |
| 97 |
The following states the idempotency of an adjunction: |
| 98 |
\[ |
| 99 |
\cut t{\mt x.\cut{\mu\alpha.\cut ue}{e'}}=\cut{\mu\alpha.\cut t{\mt x.\cut ue}}{e'} |
| 100 |
\] |
| 101 |
|
| 102 |
The following states the commutativity of a strong monad: |
| 103 |
\[ |
| 104 |
\cut t{\mt x.\cut u{\mt y.\cut ve}}=\cut u{\mt y.\cut t{\mt x.\cut ve}} |
| 105 |
\] |
| 106 |
Using \texttt{\textbackslash underline} to mark redexes: |
| 107 |
\begin{align*} |
| 108 |
& \delta(V,x.y,x.y)\\ |
| 109 |
& =\mu{\star}.\cut V{\perfectcase{\mt x.\underline{\cut y{\star}}}{\mt x.\underline{\cut y{\star}}}}\\ |
| 110 |
& =\mu{\star}.\cut V{\underline{\perfectcase{\mt x.\cut{\iota_{1}(x)}{\mt z.\cut y{\star}}}{\mt x.\cut{\iota_{2}(x)}{\mt z.\cut y{\star}}}}}\\ |
| 111 |
& =\mu{\star}.\cut V{\underline{\mt z.}\cut y{\star}}\\ |
| 112 |
& =\mu{\star}.\cut y{\star}=y |
| 113 |
\end{align*} |
| 114 |
% |
| 115 |
\end{minipage}} |
| 116 |
\par\end{center} |
| 117 |
|
| 118 |
\subsection{Using \texttt{\textbackslash left}, \texttt{\textbackslash middle} |
| 119 |
and \texttt{\textbackslash right} instead} |
| 120 |
|
| 121 |
\global\long\def\fakecut#1#2{\left\langle #1\middle|\mkern-2mu \middle|#2\right\rangle } |
| 122 |
|
| 123 |
\noindent \texttt{\footnotesize{}\textbackslash renewcommand\{\textbackslash cut\}{[}2{]}\{\textbackslash left\textbackslash langle |
| 124 |
\#1\textbackslash middle|\textbackslash mkern-2mu\textbackslash middle|\#2\textbackslash right\textbackslash rangle\}} |
| 125 |
|
| 126 |
\begin{center} |
| 127 |
\fbox{\parbox[t]{0.8\columnwidth}{% |
| 128 |
The following states the idempotency of an adjunction: |
| 129 |
\[ |
| 130 |
\fakecut t{\mt x.\fakecut{\mu\alpha.\fakecut ue}{e'}}=\fakecut{\mu\alpha.\fakecut t{\mt x.\fakecut ue}}{e'} |
| 131 |
\] |
| 132 |
|
| 133 |
The following states the commutativity of a strong monad: |
| 134 |
\[ |
| 135 |
\fakecut t{\mt x.\fakecut u{\mt y.\fakecut ve}}=\fakecut u{\mt y.\fakecut t{\mt x.\fakecut ve}} |
| 136 |
\] |
| 137 |
|
| 138 |
Using \texttt{\textbackslash underline} to mark redexes: |
| 139 |
\begin{align*} |
| 140 |
& \delta(V,x.y,x.y)\\ |
| 141 |
& =\mu{\star}.\fakecut V{\left[\mt x.\underline{\fakecut y{\star}}\middle|\mt x.\underline{\fakecut y{\star}}\right]}\\ |
| 142 |
& =\mu{\star}.\fakecut V{\underline{\left[\mt x.\fakecut{\iota_{1}(x)}{\mt z.\fakecut y{\star}}\middle|\mt x.\fakecut{\iota_{2}(x)}{\mt z.\fakecut y{\star}}\right]}}\\ |
| 143 |
& =\mu{\star}.\fakecut V{\underline{\mt z.}\fakecut y{\star}}\\ |
| 144 |
& =\mu{\star}.\fakecut y{\star}=y |
| 145 |
\end{align*} |
| 146 |
% |
| 147 |
}} |
| 148 |
\par\end{center} |
| 149 |
|
| 150 |
As we can see, the legibility of the above rendering is hampered by |
| 151 |
multiple issues: the delimiters grow inconsistently, vertical bars |
| 152 |
have the wrong size, accents or underlines uselessly make the delimiters |
| 153 |
grow, and the spacing could be improved. The package is designed to |
| 154 |
fix these issues. |
| 155 |
|
| 156 |
\section{Advanced use} |
| 157 |
|
| 158 |
The package lets you define your own growing delimiters. Let us first |
| 159 |
stress that the size of these delimiters is entirely determined by |
| 160 |
the number of nestings and is insensitive to the size of the contents. |
| 161 |
If you need the size of the contents to be taken into account then |
| 162 |
it is probably sufficient to use \texttt{\textbackslash left} and |
| 163 |
\texttt{\textbackslash right} while tweaking \texttt{\textbackslash delimitershortfall} |
| 164 |
and \texttt{\textbackslash delimiterfactor}. |
| 165 |
|
| 166 |
\subsection{Example} |
| 167 |
|
| 168 |
The following displays a set $\{\#1\mid\#2\}$ with delimiters appropriately |
| 169 |
sized if there are other \texttt{\textbackslash perfectcommands} |
| 170 |
inside \texttt{\#1} and \texttt{\#2}.\medskip{} |
| 171 |
|
| 172 |
\texttt{\footnotesize{}\textbackslash def\textbackslash Set\#1\#2\{\textbackslash perfectbinary\{IncreaseHeight\}\textbackslash\{|\textbackslash\}\{\#1\textbackslash mathrel\{\}\}\{\textbackslash mathrel\{\}\#2\}\}}{\footnotesize\par} |
| 173 |
|
| 174 |
\texttt{\footnotesize{}\textbackslash{[}\textbackslash Set\{\textbackslash perfectparens\{a\}\}\{\textbackslash perfectparens\{b\}\}\textbackslash{]}}{\footnotesize\par} |
| 175 |
|
| 176 |
\def\Set#1#2{\perfectbinary{IncreaseHeight}\{|\}{#1\mathrel{}}{\mathrel{}#2}} |
| 177 |
|
| 178 |
\[ |
| 179 |
\fbox{\ensuremath{\Set{\perfectparens{a}}{\perfectparens{b}}}} |
| 180 |
\] |
| 181 |
|
| 182 |
|
| 183 |
\subsection{Custom delimiters} |
| 184 |
\begin{description} |
| 185 |
\item [{\texttt{\textbackslash perfectunary\#1\#2\#3\#4}}] Displays \texttt{\#2} |
| 186 |
\texttt{\#4} \texttt{\#3} where \texttt{\#2} and \texttt{\#3} are |
| 187 |
delimiters. The delimiters grow according to \texttt{\#1} which must |
| 188 |
be one of \texttt{IncreaseHeight}, \texttt{CurrentHeight}, or \texttt{CurrentHeightPlusOne}. |
| 189 |
\item [{\texttt{\textbackslash perfectbinary\#1\#2\#3\#4\#5\#6}}] Displays |
| 190 |
\texttt{\#2} \texttt{\#5} \texttt{\#3} \texttt{\#6} \texttt{\#4} where |
| 191 |
\texttt{\#2}, \texttt{\#3} and \texttt{\#4} are delimiters. The delimiters |
| 192 |
grow according to \texttt{\#1} which must be one of \texttt{IncreaseHeight}, |
| 193 |
\texttt{CurrentHeight}, or \texttt{CurrentHeightPlusOne}. |
| 194 |
\end{description} |
| 195 |
|
| 196 |
\subsection{Stock delimiters} |
| 197 |
|
| 198 |
The stock commands behave as follow: |
| 199 |
|
| 200 |
\begin{center} |
| 201 |
\begin{tabular}{>{\raggedright}p{11em}lll} |
| 202 |
\toprule |
| 203 |
Command & Produces & Growth & Inserts skips\tabularnewline |
| 204 |
\midrule |
| 205 |
\texttt{\textbackslash perfectcut\{\#1\}\{\#2\}} & $\perfectcut{\#1}{\#2}$ & \texttt{IncreaseHeight} & Yes\tabularnewline |
| 206 |
\texttt{\textbackslash perfectbra\{\#1\}} & $\perfectbra{\#1}$ & \texttt{IncreaseHeight} & Yes\tabularnewline |
| 207 |
\texttt{\textbackslash perfectket\{\#1\}} & $\perfectket{\#1}$ & \texttt{IncreaseHeight} & Yes\tabularnewline |
| 208 |
\texttt{\textbackslash perfectcase\{\#1\}} & $\perfectcase{\#1}{\#2}$ & \texttt{CurrentHeightPlusOne} & Yes\tabularnewline |
| 209 |
\texttt{\textbackslash perfectbrackets\{\#1\}} & $\perfectbrackets{\#1}$ & \texttt{CurrentHeightPlusOne} & Only inside\tabularnewline |
| 210 |
\texttt{\textbackslash perfectparens\{\#1\}} & $\perfectparens{\#1}$ & \texttt{CurrentHeight} & Only inside\tabularnewline |
| 211 |
\texttt{\textbackslash perfectunary\{\#1\}}~\\ |
| 212 |
\texttt{~\{\#2\}\{\#3\}\{\#4\}} & $\#2\,\#4\,\#3$ & \#1 & No\tabularnewline |
| 213 |
\texttt{\textbackslash perfectbinary\{\#1\}}~\\ |
| 214 |
\texttt{~\{\#2\}\{\#3\}\{\#4\}\{\#5\}\{\#6\}} & $\#2\,\#5\,\#3\,\#6\,\#4$ & \#1 & No\tabularnewline |
| 215 |
\bottomrule |
| 216 |
\end{tabular} |
| 217 |
\par\end{center} |
| 218 |
|
| 219 |
\section{Options} |
| 220 |
|
| 221 |
\subsection{Option \texttt{mathstyle}} |
| 222 |
|
| 223 |
With this option, the command \texttt{\textbackslash currentmathstyle} |
| 224 |
from the package \texttt{mathstyle} is used instead of the command |
| 225 |
\texttt{\textbackslash ThisStyle} from the \texttt{scalerel} package. |
| 226 |
The latter (default) uses \texttt{\textbackslash mathchoice}, and |
| 227 |
in order to avoid an exponential time complexity in the number of |
| 228 |
nestings, it is only called for the outermost command. Concretely, |
| 229 |
with \texttt{mathstyle}, math style changes are taken into account |
| 230 |
both inside and outside of \texttt{\textbackslash perfectcommands}, |
| 231 |
whereas without it, changes in math style are not obeyed inside a |
| 232 |
command. Moreover, using the \texttt{mathstyle} option speeds up compilation. |
| 233 |
The downside of using \texttt{mathstyle} is that it redefines many |
| 234 |
standard math commands, and is therefore a source of incompatibilities, |
| 235 |
notably with \texttt{xypic}. |
| 236 |
|
| 237 |
\subsection{Option \texttt{realVert}} |
| 238 |
|
| 239 |
With the option \texttt{realVert}, the double bars are obtained with |
| 240 |
the \texttt{\textbackslash Vert} command. But without it, two \texttt{\textbackslash vert} |
| 241 |
symbols are used and their spacing is controlled with \texttt{\textbackslash cutinterbarskip}. |
| 242 |
Also, if \texttt{realVert} is not activated, then a penalty (\texttt{binoppenalty}) |
| 243 |
is added, such that $\cut{\mu\alpha.\cut ab}{\mt x.\cut cd}$ splits |
| 244 |
across lines. |
| 245 |
|
| 246 |
\subsection{Option \texttt{fixxits}} |
| 247 |
|
| 248 |
For some reason that the author was unable to identify, the vertical |
| 249 |
alignment is wrong with the Opentype XITS math font with XeTeX. The |
| 250 |
option \texttt{fixxits} fixes this behaviour. |
| 251 |
|
| 252 |
\subsection{Customisation} |
| 253 |
|
| 254 |
The following mu-skips can be redefined in your preamble: |
| 255 |
|
| 256 |
\begin{center} |
| 257 |
\begin{tabular}{ll} |
| 258 |
\toprule |
| 259 |
Command & Defines the spacing...\tabularnewline |
| 260 |
\midrule |
| 261 |
\texttt{\textbackslash cutbarskip=5.0mu plus 8mu minus 2.0mu} & around bars\tabularnewline |
| 262 |
\texttt{\textbackslash cutangleskip=0.0mu plus 8mu minus 1.0mu} & around delimiters (inside)\tabularnewline |
| 263 |
\texttt{\textbackslash cutangleouterskip=0.0mu plus 8mu minus 0mu} & around delimiters (outside)\tabularnewline |
| 264 |
\texttt{\textbackslash cutinterbarskip=0.8mu plus 0mu minus 0mu} & between bars (excl. \texttt{realVert})\tabularnewline |
| 265 |
\bottomrule |
| 266 |
\end{tabular} |
| 267 |
\par\end{center} |
| 268 |
|
| 269 |
\noindent (1 mu equals $1/18$ of an em in the current math font.) |
| 270 |
|
| 271 |
\section{Reimplementation of fixed-size delimiters} |
| 272 |
|
| 273 |
In addition, I provide the following corrections and generalisations |
| 274 |
of \texttt{\textbackslash big},\texttt{\textbackslash bigg}, etc. |
| 275 |
Why not using the latter? Because both the plain \TeX{} and the \texttt{amsmath} |
| 276 |
versions can be incorrect when changing the math font, the font size, |
| 277 |
the math style or \texttt{\textbackslash delimitershortfall}. Moreover, |
| 278 |
Opentype math fonts sometimes offer more than five sizes. For this |
| 279 |
package we need a robust solution. |
| 280 |
|
| 281 |
\begin{center} |
| 282 |
\begin{tabular}{lll} |
| 283 |
\toprule |
| 284 |
Command & Example & \tabularnewline |
| 285 |
\midrule |
| 286 |
\multicolumn{3}{l}{\emph{\#1-th size of delimiter \#2}}\tabularnewline |
| 287 |
\texttt{\textbackslash nthleft\{\#1\}\{\#2\} } & \texttt{\textbackslash nthleft\{2\}(} & $\nthleft{2}($\tabularnewline\addlinespace[0.1em] |
| 288 |
\texttt{\textbackslash nthmiddle\{\#1\}\{\#2\}} & \texttt{\textbackslash nthmiddle\{2\}\textbackslash Vert} & $\nthmiddle{2}\Vert$\tabularnewline\addlinespace[0.1em] |
| 289 |
\texttt{\textbackslash nthright\{\#1\}\{\#2\}} & \texttt{\textbackslash nthright\{2\})} & $\nthright{2})$\tabularnewline\addlinespace[0.1em] |
| 290 |
\multicolumn{1}{l}{\emph{delimiter \#2 of height at least \#1}} & & \tabularnewline\addlinespace[0.1em] |
| 291 |
\texttt{\textbackslash lenleft\{\#1\}\{\#2\}} & \texttt{\textbackslash lenleft\{3.2mm\}{[}} & $\lenleft{3mm}[$\tabularnewline\addlinespace[0.1em] |
| 292 |
\texttt{\textbackslash lenmiddle\{\#1\}\{\#2\}} & \texttt{\textbackslash lenmiddle\{3.2mm\}|} & $\lenmiddle{3mm}|$\tabularnewline\addlinespace[0.1em] |
| 293 |
\texttt{\textbackslash lenright\{\#1\}\{\#2\}} & \texttt{\textbackslash lenright\{3.2mm\}{]}} & $\lenright{3mm}]$\tabularnewline\addlinespace[0.1em] |
| 294 |
\multicolumn{3}{l}{\emph{delimiter \#2 of height exactly \#1 obtained by scaling the |
| 295 |
above one}}\tabularnewline\addlinespace[0.1em] |
| 296 |
\texttt{\textbackslash reallenleft\{\#1\}\{\#2\}} & \texttt{\textbackslash reallenleft\{3.2mm\}{[}} & $\reallenleft{3mm}[$\tabularnewline\addlinespace[0.1em] |
| 297 |
\texttt{\textbackslash reallenmiddle\{\#1\}\{\#2\}} & \texttt{\textbackslash reallenmiddle\{3.2mm\}|} & $\reallenmiddle{3mm}|$\tabularnewline\addlinespace[0.1em] |
| 298 |
\texttt{\textbackslash reallenright\{\#1\}\{\#2\}} & \texttt{\textbackslash reallenright\{3.2mm\}{]}} & $\reallenright{3mm}]$\tabularnewline |
| 299 |
\bottomrule |
| 300 |
\end{tabular} |
| 301 |
\par\end{center} |
| 302 |
|
| 303 |
\subsection{Example with \texttt{\textbackslash nthleft}} |
| 304 |
|
| 305 |
\texttt{\footnotesize{}\textbackslash nrthleft0(\textbackslash nthleft1(\textbackslash nthleft2(\textbackslash nthleft3(\textbackslash nthleft4(\textbackslash nthleft5(\textbackslash nthleft6(}{\footnotesize\par} |
| 306 |
|
| 307 |
\[ |
| 308 |
\nthleft0(\nthleft1(\nthleft2(\nthleft3(\nthleft4(\nthleft5(\nthleft6( |
| 309 |
\] |
| 310 |
|
| 311 |
|
| 312 |
\subsection{Example with \texttt{\textbackslash big},\texttt{\textbackslash Big},\texttt{\textbackslash bigg},\texttt{\textbackslash Bigg}} |
| 313 |
|
| 314 |
\texttt{\footnotesize{}(\textbackslash big(\textbackslash Big(\textbackslash bigg(\textbackslash Bigg(}{\footnotesize\par} |
| 315 |
|
| 316 |
\[ |
| 317 |
(\big(\Big(\bigg(\Bigg( |
| 318 |
\] |
| 319 |
The above uses the \texttt{\textbackslash big} commands from the |
| 320 |
\texttt{amsmath} package. The \texttt{amsmath} package corrects issues |
| 321 |
with the original \TeX{} commands, but I could still notice inconsistencies, |
| 322 |
such as \texttt{\textbackslash big} starting at size 2, under some |
| 323 |
font combinations. \texttt{\textbackslash nthleft}, \texttt{\textbackslash nthright} |
| 324 |
and \texttt{\textbackslash nthmiddle} are implemented in a more robust |
| 325 |
way. |
| 326 |
|
| 327 |
\section{License} |
| 328 |
|
| 329 |
This work may be distributed and/or modified under the conditions |
| 330 |
of the \LaTeX{} Project Public License, either version 1.3 of this |
| 331 |
license or (at your option) any later version. Refer to the \texttt{README} |
| 332 |
file. |
| 333 |
\end{document} |