summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/perfectcut/perfectcut.tex
blob: 64b2421f9c26f4ae583095411b115cdf7f403ad9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
%%% perfectcut.sty  documentation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%
%%% Author: Guillaume Munch-Maccagnoni
%%% http://www.pps.univ-paris-diderot.fr/~munch/
%%%
%%% This work may be distributed and/or modified under the conditions of
%%% the LaTeX Project Public License, either version 1.3 of this license
%%% or (at your option) any later version. Refer to the README file.
%%%
\documentclass[12pt,a4paper,british]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\setcounter{secnumdepth}{1}
\setcounter{tocdepth}{1}
\usepackage{babel}
\usepackage{array}
\usepackage{booktabs}
\usepackage{calc}
\usepackage{amsmath}
\usepackage[unicode=true]{hyperref}
\usepackage{perfectcut}
\usepackage{stix}
\renewcommand*\ttdefault{txtt}
\usepackage[oldstyle,lining,scale=0.97]{sourcesanspro}
\usepackage[protrusion=true,expansion=true,tracking=false,kerning=true,spacing=true]{microtype}

\begin{document}
\global\long\def\cut#1#2{\perfectcut{#1}{#2}}
\global\long\def\mt{\bar{\mu}}


\title{\texttt{perfectcut.sty} documentation}


\author{\noindent {\large{}Guillaume Munch-Maccagnoni}%
\thanks{\protect\href{http://www.pps.univ-paris-diderot.fr/~munch/}{http://www.pps.univ-paris-diderot.fr/$\sim$munch/}%
}}


\date{2nd November 2014}

\maketitle


\tableofcontents{}


\section{Use}


\paragraph{Original use}

This package supplies the following commands:

\begin{center}
\begin{tabular}{ll}
\toprule 
Command & Produces\tabularnewline
\midrule
\texttt{\textbackslash{}perfectcut\{\#1\}\{\#2\}} & $\perfectcut{\#1}{\#2}$\tabularnewline
\texttt{\textbackslash{}perfectbra\{\#1\}} & $\perfectbra{\#1}$\tabularnewline
\texttt{\textbackslash{}perfectket\{\#1\}} & $\perfectket{\#1}$\tabularnewline
\bottomrule
\end{tabular}\quad{}%
\begin{tabular}{ll}
\toprule 
Command & Produces\tabularnewline
\midrule
\texttt{\textbackslash{}perfectcase\{\#1\}} & $\perfectcase{\#1}{\#2}$\tabularnewline
\texttt{\textbackslash{}perfectbrackets\{\#1\}} & $\perfectbrackets{\#1}$\tabularnewline
\texttt{\textbackslash{}perfectparens\{\#1\}} & $\perfectparens{\#1}$\tabularnewline
\bottomrule
\end{tabular}
\par\end{center}

The effect of these commands is to let the delimiters grow according
to the number of nested \texttt{\textbackslash{}perfect}\texttt{\emph{command}}s
(regardless of the size of contents). The package is originally intended
for solving a notational issue regarding the representation of abstract-machine-like
calculi in proof theory and computer science.


\paragraph{General use}

The package also defines \texttt{\textbackslash{}perfectunary} and
\texttt{\textbackslash{}perfectbinary} for defining custom delimiters
that behave similarly to the above ones. These commands should be considered when
facing the need of nested delimiters that consistently grow regardless
of the contents. (See ``Advanced Use''.)\medskip{}


If the package causes incompatibility errors, refer to the option
\texttt{nomathstyle} below.


\section{Example}




\subsection{Using \texttt{perfectcut.sty}}

\global\long\def\cut#1#2{\cutprimitive{#1}{#2}}


\noindent \texttt{\footnotesize{}\textbackslash{}usepackage\{perfectcut\}}~\\
\texttt{\footnotesize{}\textbackslash{}let\textbackslash{}cut\textbackslash{}perfectcut}{\footnotesize \par}

\begin{center}
\fbox{\begin{minipage}[t]{0.8\columnwidth}%
The following states the idempotency of an adjunction: 
\[
\cut t{\mt x.\cut{\mu\alpha.\cut ue}{e'}}=\cut{\mu\alpha.\cut t{\mt x.\cut ue}}{e'}
\]


The following states the commutativity of a strong monad:
\[
\cut t{\mt x.\cut u{\mt y.\cut ve}}=\cut u{\mt y.\cut t{\mt x.\cut ve}}
\]
Using \texttt{\textbackslash{}underline} to mark redexes:
\begin{align*}
 & \delta(V,x.y,x.y)\\
 & =\mu{\star}.\cut V{\perfectcase{\mt x.\underline{\cut y{\star}}}{\mt x.\underline{\cut y{\star}}}}\\
 & =\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}}}}}\\
 & =\mu{\star}.\cut V{\underline{\mt z.}\cut y{\star}}\\
 & =\mu{\star}.\cut y{\star}=y
\end{align*}
 %
\end{minipage}}
\par\end{center}


\subsection{Using \texttt{\textbackslash{}left}, \texttt{\textbackslash{}middle}
and \texttt{\textbackslash{}right} instead}

\global\long\def\fakecut#1#2{\left\langle #1\middle|\mkern-2mu\middle|#2\right\rangle }


\noindent \texttt{\footnotesize{}\textbackslash{}renewcommand\{\textbackslash{}cut\}{[}2{]}\{\textbackslash{}left\textbackslash{}langle
\#1\textbackslash{}middle|\textbackslash{}mkern-2mu\textbackslash{}middle|\#2\textbackslash{}right\textbackslash{}rangle\}}{\footnotesize \par}

\begin{center}
\fbox{\parbox[t]{0.8\columnwidth}{%
The following states the idempotency of an adjunction: 
\[
\fakecut t{\mt x.\fakecut{\mu\alpha.\fakecut ue}{e'}}=\fakecut{\mu\alpha.\fakecut t{\mt x.\fakecut ue}}{e'}
\]


The following states the commutativity of a strong monad:
\[
\fakecut t{\mt x.\fakecut u{\mt y.\fakecut ve}}=\fakecut u{\mt y.\fakecut t{\mt x.\fakecut ve}}
\]


Using \texttt{\textbackslash{}underline} to mark redexes:
\begin{align*}
 & \delta(V,x.y,x.y)\\
 & =\mu{\star}.\fakecut V{\left[\mt x.\underline{\fakecut y{\star}}\middle|\mt x.\underline{\fakecut y{\star}}\right]}\\
 & =\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]}}\\
 & =\mu{\star}.\fakecut V{\underline{\mt z.}\fakecut y{\star}}\\
 & =\mu{\star}.\fakecut y{\star}=y
\end{align*}
%
}}
\par\end{center}

As we can see, the legibility of the above rendering is hampered by
multiple issues: the delimiters grow inconsistently, vertical bars
have the wrong size, accents or underlines uselessly make the delimiters
grow, and the spacing could be improved. The package is designed to
fix these issues.


\section{Advanced use}

The package lets you define your own growing delimiters. Let us first
stress that the size of these delimiters is entirely determined by
the number of nestings and is insensitive to the size of the contents.
If you need the size of the contents to be taken into account then
it is probably sufficient to use \texttt{\textbackslash{}left} and
\texttt{\textbackslash{}right} while tweaking \texttt{\textbackslash{}delimitershortfall}
and \texttt{\textbackslash{}delimiterfactor}.


\subsection{Example}

The following displays a set $\{\#1\mid\#2\}$ with delimiters appropriately
sized if there are other \texttt{\textbackslash{}perfectcommands}
inside \texttt{\#1} and \texttt{\#2}.\medskip{}


\texttt{\footnotesize{}\textbackslash{}def\textbackslash{}Set\#1\#2\{\textbackslash{}perfectbinary\{IncreaseHeight\}\textbackslash{}\{|\textbackslash{}\}\{\#1\textbackslash{}mathrel\{\}\}\{\textbackslash{}mathrel\{\}\#2\}\}}{\footnotesize \par}

\texttt{\footnotesize{}\textbackslash{}{[}\textbackslash{}Set\{\textbackslash{}perfectparens\{a\}\}\{\textbackslash{}perfectparens\{b\}\}\textbackslash{}{]}}{\footnotesize \par}

\def\Set#1#2{\perfectbinary{IncreaseHeight}\{|\}{#1\mathrel{}}{\mathrel{}#2}}

\[
\fbox{\ensuremath{\Set{\perfectparens{a}}{\perfectparens{b}}}}
\]



\subsection{Custom delimiters}
\begin{description}
\item [{\texttt{\textbackslash{}perfectunary\#1\#2\#3\#4}}] Displays \texttt{\#2}
\texttt{\#4} \texttt{\#3} where \texttt{\#2} and \texttt{\#3} are
delimiters. The delimiters grow according to \texttt{\#1} which must
be one of \texttt{IncreaseHeight}, \texttt{CurrentHeight}, or \texttt{CurrentHeightPlusOne}.
\item [{\texttt{\textbackslash{}perfectbinary\#1\#2\#3\#4\#5\#6}}] Displays
\texttt{\#2} \texttt{\#5} \texttt{\#3} \texttt{\#6} \texttt{\#4} where
\texttt{\#2}, \texttt{\#3} and \texttt{\#4} are delimiters. The delimiters
grow according to \texttt{\#1} which must be one of \texttt{IncreaseHeight},
\texttt{CurrentHeight}, or \texttt{CurrentHeightPlusOne}.
\end{description}

\subsection{Stock delimiters}

The stock commands behave as follow:

\begin{center}
\begin{tabular}{>{\raggedright}p{11em}lll}
\toprule 
Command & Produces & Growth & Inserts skips\tabularnewline
\midrule
\texttt{\textbackslash{}perfectcut\{\#1\}\{\#2\}} & $\perfectcut{\#1}{\#2}$ & \texttt{IncreaseHeight} & Yes\tabularnewline
\texttt{\textbackslash{}perfectbra\{\#1\}} & $\perfectbra{\#1}$ & \texttt{IncreaseHeight} & Yes\tabularnewline
\texttt{\textbackslash{}perfectket\{\#1\}} & $\perfectket{\#1}$ & \texttt{IncreaseHeight} & Yes\tabularnewline
\texttt{\textbackslash{}perfectcase\{\#1\}} & $\perfectcase{\#1}{\#2}$ & \texttt{CurrentHeightPlusOne} & Yes\tabularnewline
\texttt{\textbackslash{}perfectbrackets\{\#1\}} & $\perfectbrackets{\#1}$ & \texttt{CurrentHeightPlusOne} & Only inside\tabularnewline
\texttt{\textbackslash{}perfectparens\{\#1\}} & $\perfectparens{\#1}$ & \texttt{CurrentHeight} & Only inside\tabularnewline
\texttt{\textbackslash{}perfectunary\{\#1\}}~\\
\texttt{~\{\#2\}\{\#3\}\{\#4\}} & $\#2\,\#4\,\#3$ & \#1 & No\tabularnewline
\texttt{\textbackslash{}perfectbinary\{\#1\}}~\\
\texttt{~\{\#2\}\{\#3\}\{\#4\}\{\#5\}\{\#6\}} & $\#2\,\#5\,\#3\,\#6\,\#4$ & \#1 & No\tabularnewline
\bottomrule
\end{tabular}
\par\end{center}


\section{Options}


\subsection{Option \texttt{nomathstyle}}

The use of \texttt{\textbackslash{}currentmathstyle} from the package
\texttt{mathstyle} prevents the exponential blowup in recursions that
would occur if we used \texttt{\textbackslash{}mathpalette} instead.
To record the \texttt{\textbackslash{}currentmath\-style}, \texttt{mathstyle}
redefines many  primitives and is therefore a source of incompatibilities.
If you run into such issues, please refer to the \texttt{mathstyle}
manual.

If you want to  disable the loading of \texttt{mathstyle}, use the
\texttt{nomathstyle} option.  With the \texttt{nomathstyle} option,
the style is set to \texttt{\textbackslash{}cutstyle}, which you must
 define by hand to be \texttt{\textbackslash{}displaystyle}, \texttt{\textbackslash{}textstyle
}(default), \texttt{\textbackslash{}scriptstyle},  \texttt{\textbackslash{}scriptscriptstyle}.
This means that cuts in subscripts and superscripts do  not have the
proper size unless \texttt{\textbackslash{}cutstyle }is redefined.


\subsection{Option \texttt{realVert}}

With the option \texttt{realVert}, the double bars are obtained with
the \texttt{\textbackslash{}Vert} command. Without it, two \texttt{\textbackslash{}vert}
symbols are used and their spacing is controlled with  \texttt{\textbackslash{}cutinterbarskip}.
But, if \texttt{realVert} is not activated, then a penalty (\texttt{binoppenalty})
is added, such that $\cut{\mu\alpha.\cut ab}{\mt x.\cut cd}$ splits
across lines.


\subsection{Option \texttt{fixxits}}

For some reason that the author was unable to identify, the vertical
alignment is wrong with the Opentype XITS math font with XeTeX. The
option \texttt{fixxits} fixes this behaviour.


\subsection{Customisation}

The following mu-skips can be redefined in your preamble:

\begin{center}
\begin{tabular}{ll}
\toprule 
Command & Defines the spacing...\tabularnewline
\midrule
\texttt{\textbackslash{}cutbarskip=5.0mu plus 8mu minus 2.0mu} & around bars\tabularnewline
\texttt{\textbackslash{}cutangleskip=0.0mu plus 8mu minus 1.0mu} & around delimiters (inside)\tabularnewline
\texttt{\textbackslash{}cutangleouterskip=0.0mu plus 8mu minus 0mu} & around delimiters (outside)\tabularnewline
\texttt{\textbackslash{}cutinterbarskip=0.8mu plus 0mu minus 0mu} & between bars (excl. \texttt{realVert})\tabularnewline
\bottomrule
\end{tabular}
\par\end{center}

\noindent (1 mu equals $1/18$ of an em in the current math font.)


\section{Reimplementation of fixed-size delimiters}

In addition, I provide the following corrections and generalisations
of  \texttt{\textbackslash{}big},\texttt{\textbackslash{}bigg}, etc.
Why not using the latter? Because both the plain \TeX{} and the \texttt{amsmath}
versions can be incorrect when changing the math font, the font size,
the math style or \texttt{\textbackslash{}delimitershortfall}. Moreover,
Opentype math fonts sometimes offer more than five sizes. For this
package we need a robust solution.

\begin{center}
\begin{tabular}{lll}
\toprule 
Command & Example & \tabularnewline
\midrule 
\multicolumn{3}{l}{\emph{\#1-th size of delimiter \#2}}\tabularnewline
\texttt{\textbackslash{}nthleft\{\#1\}\{\#2\} } & \texttt{\textbackslash{}nthleft\{2\}(} & $\nthleft{2}($\tabularnewline\addlinespace[0.1em]
\texttt{\textbackslash{}nthmiddle\{\#1\}\{\#2\}} & \texttt{\textbackslash{}nthmiddle\{2\}\textbackslash{}Vert} & $\nthmiddle{2}\Vert$\tabularnewline\addlinespace[0.1em]
\texttt{\textbackslash{}nthright\{\#1\}\{\#2\}} & \texttt{\textbackslash{}nthright\{2\})} & $\nthright{2})$\tabularnewline\addlinespace[0.1em]
\multicolumn{1}{l}{\emph{delimiter \#2 of height at least \#1}} &  & \tabularnewline\addlinespace[0.1em]
\texttt{\textbackslash{}lenleft\{\#1\}\{\#2\}}  & \texttt{\textbackslash{}lenleft\{3.2mm\}{[}} & $\lenleft{3mm}[$\tabularnewline\addlinespace[0.1em]
\texttt{\textbackslash{}lenmiddle\{\#1\}\{\#2\}} & \texttt{\textbackslash{}lenmiddle\{3.2mm\}|} & $\lenmiddle{3mm}|$\tabularnewline\addlinespace[0.1em]
\texttt{\textbackslash{}lenright\{\#1\}\{\#2\}} & \texttt{\textbackslash{}lenright\{3.2mm\}{]}} & $\lenright{3mm}]$\tabularnewline\addlinespace[0.1em]
\multicolumn{3}{l}{\emph{delimiter \#2 of height exactly \#1 obtained by scaling the
above one}}\tabularnewline\addlinespace[0.1em]
\texttt{\textbackslash{}reallenleft\{\#1\}\{\#2\}}  & \texttt{\textbackslash{}reallenleft\{3.2mm\}{[}} & $\reallenleft{3mm}[$\tabularnewline\addlinespace[0.1em]
\texttt{\textbackslash{}reallenmiddle\{\#1\}\{\#2\}} & \texttt{\textbackslash{}reallenmiddle\{3.2mm\}|} & $\reallenmiddle{3mm}|$\tabularnewline\addlinespace[0.1em]
\texttt{\textbackslash{}reallenright\{\#1\}\{\#2\}} & \texttt{\textbackslash{}reallenright\{3.2mm\}{]}} & $\reallenright{3mm}]$\tabularnewline
\bottomrule
\end{tabular}  
\par\end{center}


\subsection{Example with \texttt{\textbackslash{}nthleft}}

\texttt{\footnotesize{}\textbackslash{}nrthleft0{[}\textbackslash{}nthleft1{[}\textbackslash{}nthleft2{[}\textbackslash{}nthleft3{[}\textbackslash{}nthleft4{[}\textbackslash{}nthleft5{[}\textbackslash{}nthleft6{[}}{\footnotesize \par}

\[
\nthleft0(\nthleft1(\nthleft2(\nthleft3(\nthleft4(\nthleft5(\nthleft6(
\]



\subsection{Example with \texttt{\textbackslash{}big},\texttt{\textbackslash{}Big},\texttt{\textbackslash{}bigg},\texttt{\textbackslash{}Bigg}}

\texttt{\footnotesize{}{[}\textbackslash{}big{[}\textbackslash{}Big{[}\textbackslash{}bigg{[}\textbackslash{}Bigg{[}}{\footnotesize \par}

\[
(\big(\Big(\bigg(\Bigg(
\]
The above uses the \texttt{\textbackslash{}big} commands from the
\texttt{amsmath} package. The \texttt{amsmath} package corrects issues
with the original \TeX{} commands, but I could still notice inconsistencies,
such as \texttt{\textbackslash{}big} starting at size 2, under some
font combinations. \texttt{\textbackslash{}nthleft}, \texttt{\textbackslash{}nthright}
and \texttt{\textbackslash{}nthmiddle} are implemented in a more robust
way.


\section{License}

This work may be distributed and/or modified under the conditions
of the \LaTeX{} Project Public License, either version 1.3 of this
license or (at your option) any later version. Refer to the \texttt{README}
file.
\end{document}