summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2014-11-03 21:51:47 +0000
committerKarl Berry <karl@freefriends.org>2014-11-03 21:51:47 +0000
commit7e74ffe0a9d51ecf26ee0aeb73493379770d5193 (patch)
tree9c66331d0b77d73c13cef9777e868be5f5c0a241 /Master
parent1eb688970a12dae5a86ed7968609be77d742488a (diff)
perfectcut (3nov14)
git-svn-id: svn://tug.org/texlive/trunk@35501 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r--Master/texmf-dist/doc/latex/perfectcut/README47
-rw-r--r--Master/texmf-dist/doc/latex/perfectcut/perfectcut.pdfbin97135 -> 163054 bytes
-rw-r--r--Master/texmf-dist/doc/latex/perfectcut/perfectcut.tex297
-rw-r--r--Master/texmf-dist/tex/latex/perfectcut/perfectcut.sty615
4 files changed, 579 insertions, 380 deletions
diff --git a/Master/texmf-dist/doc/latex/perfectcut/README b/Master/texmf-dist/doc/latex/perfectcut/README
index 26e1f502afd..0c504fcacdb 100644
--- a/Master/texmf-dist/doc/latex/perfectcut/README
+++ b/Master/texmf-dist/doc/latex/perfectcut/README
@@ -1,29 +1,44 @@
-perfectcut.sty
+perfectcut.sty --- Nested delimiters that consistently grow regardless
+of the contents.
This package defines the command \perfectcut#1#2 which displays a
-bracket <#1||#2>. Its effect is to determine the size of the bracket
-depending on the number of nested \perfectcut (regardless of the
-contents). It is intended for use:
-- In proof theory, for term notations of sequent calculus,
-- In computer science, for the modeling of abstract machines.
+bracket <#1||#2>. Various delimiters are similarly defined. The effect
+of these commands is to let the delimiters grow according to the number
+of nested \perfectcommands (regardless of the size of the contents).
-This package also offers a reimplementation of \big, \bigg, etc. into
-arbitrary-size variants.
+The package is originally intended for solving a notational issue
+regarding the representation of abstract-machine-like calculi in proof
+theory and computer science. For general use, the package also defines
+commands for defining custom delimiters that behave in the same way.
+
+This package also offers a sound reimplementation of \big, \bigg, etc.
Release notes:
+ 2.0 11/14: * The package now offers general-purpose commands for
+ defining arbitrary nested delimiters that consistently
+ grow regardless of the contents (\perfectunary and
+ \perfectbinary)
+ * Added the behaviours CurrentHeight and
+ CurrentHeightPlusOne alongside the existing behaviour
+ IncreaseHeight.
+ * Added the stock commands \perfectcase, \perfectparens,
+ and \perfectbrackets intended for use in the context
+ of abstract-machine-like calculi.
+ 1.9b 05/14: added the option fixxits to fix vertical alignment with the
+ XITS math font.
1.9 02/14: added \perfectcut,\perfectbra,\perfectket; fixed bug with graphicx
- not being included; publication on CTAN
- 1.8 01/14: added documentation (no new feature)
- 1.7 11/13: added \cutangleouterskip
- 1.6 10/13: new commands \cutbraprimitive and \cutketprimitive
+ not being included; publication on CTAN.
+ 1.8 01/14: added documentation (no new feature).
+ 1.7 11/13: added \cutangleouterskip.
+ 1.6 10/13: new commands \cutbraprimitive and \cutketprimitive.
1.5 09/13: possible to disable mathstyle (option nomathstyle, see
- the warning below)
+ the warning below).
1.4 08/13: possible to choose between \vert\vert and \Vert (option realVert)
- (\cutinterbarskip is used only with the former)
- 1.3 08/13: fixes the alignment of angles with the math axis
- 1.2 06/13: first public release
+ (\cutinterbarskip is used only with the former).
+ 1.3 08/13: fixes the alignment of angles with the math axis.
+ 1.2 06/13: first public release.
Author: Guillaume Munch-Maccagnoni
diff --git a/Master/texmf-dist/doc/latex/perfectcut/perfectcut.pdf b/Master/texmf-dist/doc/latex/perfectcut/perfectcut.pdf
index ce9750140b9..21ae2e2bb73 100644
--- a/Master/texmf-dist/doc/latex/perfectcut/perfectcut.pdf
+++ b/Master/texmf-dist/doc/latex/perfectcut/perfectcut.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/perfectcut/perfectcut.tex b/Master/texmf-dist/doc/latex/perfectcut/perfectcut.tex
index 7744bd007ed..64b2421f9c2 100644
--- a/Master/texmf-dist/doc/latex/perfectcut/perfectcut.tex
+++ b/Master/texmf-dist/doc/latex/perfectcut/perfectcut.tex
@@ -3,7 +3,7 @@
%%%
%%% 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.
@@ -12,40 +12,45 @@
\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}
-
-\makeatletter
-
\usepackage{perfectcut}
-%% NewTXtext with a bugfix
-\let\orig@makefnmark=\@makefnmark
-\usepackage{newtxtext}
-\let\@makefnmark=\orig@makefnmark
-%%End of bugfix
-
-\usepackage[T1]{fontenc}
-\usepackage{newtxmath}
+\usepackage{stix}
\renewcommand*\ttdefault{txtt}
\usepackage[oldstyle,lining,scale=0.97]{sourcesanspro}
\usepackage[protrusion=true,expansion=true,tracking=false,kerning=true,spacing=true]{microtype}
-\makeatother
-
\begin{document}
+\global\long\def\cut#1#2{\perfectcut{#1}{#2}}
+\global\long\def\mt{\bar{\mu}}
+
\title{\texttt{perfectcut.sty} documentation}
-\author{Guillaume Munch-Maccagnoni%
+
+
+\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{January 31st 2014}
+
+
+\date{2nd November 2014}
+
\maketitle
+
+\tableofcontents{}
+
+
\section{Use}
+
+\paragraph{Original use}
+
This package supplies the following commands:
\begin{center}
@@ -57,87 +62,183 @@ Command & Produces\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}
-\end{center}
+\par\end{center}
-The effect of the commands is to determine the size of the brackets
-depending on the number of nested \texttt{\textbackslash{}perfectcut}
-(regardless of the contents). It is intended for use:
-\begin{itemize}
-\item In proof theory, for term notations of sequent calculus,
-\item In computer science, for the modeling of abstract machines.
-\end{itemize}
-It could also be adapted for any visually similar effects as an alternative
-to \texttt{\textbackslash{}left}, \texttt{\textbackslash{}right} and
-\texttt{\textbackslash{}middle}. (You can contact the author.)
+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.
-If the package causes errors see the option \texttt{nomathstyle} below.
+\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}
-\def\mt{\tilde{\mu}}
+\section{Example}
-\noindent \texttt{\footnotesize{The following states the commutativity
-of a strong monad:}}~\\
-\texttt{\footnotesize{\textbackslash{}def\textbackslash{}mt\{\textbackslash{}tilde\{\textbackslash{}mu\}\}}}~\\
-\texttt{\footnotesize{\textbackslash{}{[}}}~\\
-\texttt{\footnotesize{\textbackslash{}cut t\{\textbackslash{}mt x.\textbackslash{}cut
-u\{\textbackslash{}mt y.\textbackslash{}cut ve\}\}}}~\\
-\texttt{\footnotesize{=\textbackslash{}cut u\{\textbackslash{}mt y.\textbackslash{}cut
-t\{\textbackslash{}mt x.\textbackslash{}cut ve\}\}}}~\\
-\texttt{\footnotesize{\textbackslash{}{]}}}~\\
-\texttt{\footnotesize{The following states the idempotency of an adjunction: }}~\\
-\texttt{\footnotesize{\textbackslash{}{[}}}~\\
-\texttt{\footnotesize{\textbackslash{}cut t\{\textbackslash{}mt x.\textbackslash{}cut\{\textbackslash{}mu\textbackslash{}alpha.\textbackslash{}cut
-ue\}\{e'\}\}}}~\\
-\texttt{\footnotesize{=\textbackslash{}cut\{\textbackslash{}mu\textbackslash{}alpha.\textbackslash{}cut
-t\{\textbackslash{}mt x.\textbackslash{}cut ue\}\}\{e'\}}}~\\
-\texttt{\footnotesize{\textbackslash{}{]}}}{\footnotesize \par}
\subsection{Using \texttt{perfectcut.sty}}
-\noindent \texttt{\footnotesize{\textbackslash{}usepackage\{perfectcut\}}}~\\
-\texttt{\footnotesize{\textbackslash{}let\textbackslash{}cut\textbackslash{}perfectcut}}{\footnotesize \par}
+\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}
-\framebox{\begin{minipage}[t]{0.8\columnwidth}%
-\let\cut\perfectcut
-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}}
-\]
+\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}}
-\end{center}
+\par\end{center}
\subsection{Using \texttt{\textbackslash{}left}, \texttt{\textbackslash{}middle}
and \texttt{\textbackslash{}right} instead}
-\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}
+\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}
-\framebox{\begin{minipage}[t]{0.8\columnwidth}%
-\newcommand{\cut}[2]{\left\langle #1\middle|\mkern-2mu\middle|#2\right\rangle}
-The following states the commutativity of a strong monad:
+\fbox{\parbox[t]{0.8\columnwidth}{%
+The following states the idempotency of an adjunction:
\[
-\cut t{\mt x.\cut u{\mt y.\cut ve}}=\cut u{\mt y.\cut t{\mt x.\cut ve}}
+\fakecut t{\mt x.\fakecut{\mu\alpha.\fakecut ue}{e'}}=\fakecut{\mu\alpha.\fakecut t{\mt x.\fakecut ue}}{e'}
\]
-The following states the idempotency of an adjunction:
+
+
+The following states the commutativity of a strong monad:
\[
-\cut t{\mt x.\cut{\mu\alpha.\cut ue}{e'}}=\cut{\mu\alpha.\cut t{\mt x.\cut ue}}{e'}
+\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*}
%
-\end{minipage}}
-\end{center}
+}}
+\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}
@@ -146,8 +247,8 @@ The following states the idempotency of an adjunction:
\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.
+\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}
@@ -167,8 +268,16 @@ proper size unless \texttt{\textbackslash{}cutstyle }is redefined.
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}.
-In addition, without \texttt{realVert}, a penalty is added for better
-line breaks.
+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}
@@ -178,29 +287,28 @@ The following mu-skips can be redefined in your preamble:
\begin{center}
\begin{tabular}{ll}
\toprule
-Command & Defines\tabularnewline
+Command & Defines the spacing...\tabularnewline
\midrule
-\texttt{\textbackslash{}cutbarskip=5.0mu plus 8mu minus 2.0mu} & spacing around bars\tabularnewline
-\texttt{\textbackslash{}cutangleskip=0.0mu plus 8mu minus 1.0mu} & spacing around angles (inside)\tabularnewline
-\texttt{\textbackslash{}cutangleouterskip=0.0mu plus 8mu minus 0mu} & spacing around angles (outside)\tabularnewline
-\texttt{\textbackslash{}cutinterbarskip=0.8mu plus 0mu minus 0mu} & spacing between bars\tabularnewline
+\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}
-\end{center}
+\par\end{center}
-\noindent (1 mu equals $\tfrac{1}{18}$-th of an em in the current
-math font.)
+\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 are incorrect when changing math
-font, font size, math style or \texttt{\textbackslash{}delimitershortfall}.
-Moreover, Opentype math fonts in particular offer more sizes. We
-want a robust solution.
+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}
@@ -211,39 +319,44 @@ Command & Example & \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 length at least \#1}} & & \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 length exactly \#1 obtained by scaling the
+\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}
-\end{center}
+\par\end{center}
-\subsection{Exemple with \texttt{\textbackslash{}nthleft}}
+\subsection{Example with \texttt{\textbackslash{}nthleft}}
-\texttt{\footnotesize{\textbackslash{}nthleft0(\textbackslash{}nthleft1(\textbackslash{}nthleft2(\textbackslash{}nthleft3(\textbackslash{}nthleft4(\textbackslash{}nthleft5(}}{\footnotesize \par}
+\texttt{\footnotesize{}\textbackslash{}nrthleft0{[}\textbackslash{}nthleft1{[}\textbackslash{}nthleft2{[}\textbackslash{}nthleft3{[}\textbackslash{}nthleft4{[}\textbackslash{}nthleft5{[}\textbackslash{}nthleft6{[}}{\footnotesize \par}
\[
-\nthleft0(\nthleft1(\nthleft2(\nthleft3(\nthleft4(\nthleft5(
+\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}
+\texttt{\footnotesize{}{[}\textbackslash{}big{[}\textbackslash{}Big{[}\textbackslash{}bigg{[}\textbackslash{}Bigg{[}}{\footnotesize \par}
\[
(\big(\Big(\bigg(\Bigg(
\]
-Note: \texttt{\textbackslash{}big}\texttt{\footnotesize{ }}starts
-at at size 2 in some fonts.
+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}
diff --git a/Master/texmf-dist/tex/latex/perfectcut/perfectcut.sty b/Master/texmf-dist/tex/latex/perfectcut/perfectcut.sty
index 036750b09fd..87baaff7904 100644
--- a/Master/texmf-dist/tex/latex/perfectcut/perfectcut.sty
+++ b/Master/texmf-dist/tex/latex/perfectcut/perfectcut.sty
@@ -9,18 +9,20 @@
%%% or (at your option) any later version. Refer to the README file.
%%%
%%%
-\ProvidesPackage{perfectcut}[02/02/2014 Perfect Cut v1.9]
+\ProvidesPackage{perfectcut}[03/11/2014 Perfect Cut v2.0]
%%% Option processing
\newif\ifcut@mathstyle@
\cut@mathstyle@true
\newif\ifcut@realVert@
\cut@realVert@false
+\newif\ifcut@fixxits@
+\cut@fixxits@false
\DeclareOption{nomathstyle}{\cut@mathstyle@false}
\let\cutstyle\textstyle
\DeclareOption{realVert}{\cut@realVert@true}
+\DeclareOption{fixxits}{\cut@fixxits@true}
\ProcessOptions*
%%% End option processing
-\RequirePackage{amsmath}
\RequirePackage{graphicx}
\RequirePackage{calc}
\newmuskip\cutangleskip
@@ -28,40 +30,57 @@
\newmuskip\cutinterbarskip
\newmuskip\cutangleouterskip
\newif\ifcutdebug
-%%%
-\newcommand{\cutprimitive}[2]{\cut@{#1}{#2}}
-\newcommand{\cutbraprimitive}[1]{\cut@bra{#1}}
-\newcommand{\cutketprimitive}[1]{\cut@ket{#1}}
-\let\perfectcut\cutprimitive
-\let\perfectbra\cutbraprimitive
-\let\perfectket\cutketprimitive
-%%% The following variables can be redefined in your preamble
+%%% Exported commands
+%%See end of file for a more detailed description of the commands
+\newcommand{\perfectcut}[2]{\cut@{#1}{#2}}%% displays <#1||#2>
+\newcommand{\perfectbra}[1]{\cut@bra{#1}}%% displays <#1|
+\newcommand{\perfectket}[1]{\cut@ket{#1}}%% displays |#2>
+\let\cutprimitive\perfectcut%backward compat
+\let\cutbraprimitive\perfectbra%backward compat
+\let\cutketprimitive\perfectket%backward compat
+\newcommand{\perfectcase}[2]{\cut@case{#1}{#2}}%% displays [#1|#2]
+\newcommand{\perfectbrackets}[1]{\cut@brackets{#1}}%% displays [#1]
+\newcommand{\perfectparens}[1]{\cut@parens{#1}}%% displays (#1)
+\newcommand{\perfectunary}[4]{\cut@customUnary{#1}{#2}{#3}{#4}}%% displays
+ %% #2#3#4 where #2 and #4 are delimiters. The size of the delimiters is
+ %% computed according to #1 which must be one of IncreaseHeight,
+ %% CurrentHeight, or CurrentHeightPlusOne.
+\newcommand{\perfectbinary}[6]{\cut@customBinary{#1}{#2}{#3}{#4}{#5}{#6}}%%
+ %% displays #2#3#4#5#6 where #2, #4 and #6 are delimiters. The size of the
+ %% delimiters is computed according to #1 which must be one of IncreaseHeight,
+ %% CurrentHeight, or CurrentHeightPlusOne.
+%% The following variables can be redefined in your preamble
\cutbarskip=5.0mu plus 8.0mu minus 2.0mu
\cutangleskip=0.0mu plus 8mu minus 1.0mu
\cutangleouterskip=0.0mu plus 8mu minus 0.0mu
-\cutinterbarskip=0.8mu plus 0mu minus 0mu
-\cutdebugfalse%print the size after each \rangle?
-%%%
-%%%\nthleft{4}\langle ==> fourth size of \langle; begins at 0
+\cutinterbarskip=1.4mu plus 0mu minus 0mu
+\cutdebugfalse%% print the size after each \rangle?
+%%% Various reimplementations of \left, \right and \middle.
+%% \nthleft{4}\langle ==> fourth size of \langle; begins at 0
\newcommand{\nthleft}[2]{\cut@nthldelim{#1}{#2}}
-%%%same for right and middle
\newcommand{\nthright}[2]{\cut@nthrdelim{#1}{#2}}
\newcommand{\nthmiddle}[2]{\cut@nthmdelim{#1}{#2}}
-%%%\lenleft{3mm}\langle ===> \langle of size at least 3mm
-%%%in math mode it is preferable to use math units such as 10mu,...
-%%%however only regular units are implemented now.
+%% \matchleft{\big\langle}| ===> | of the same size as \big\langle obtained
+%% by resizing the closest glyph
+\newcommand{\matchleft}[2]{\cut@matchingldelim{#1}{#2}}
+\newcommand{\matchright}[2]{\cut@matchingrdelim{#1}{#2}}
+\newcommand{\matchmiddle}[2]{\cut@matchingmdelim{#1}{#2}}
+%% \lenleft{3mm}\langle ===> \langle of size at least 3mm
+%% (in math mode it is preferable to use math units such as 10mu,...
+%% however only regular units are implemented now.)
\newcommand{\lenleft}[2]{\cut@lengthldelim{#1}#2}
-%%%same for right and middle
\newcommand{\lenright}[2]{\cut@lengthrdelim{#1}#2}
\newcommand{\lenmiddle}[2]{\cut@lengthmdelim{#1}#2}
-%%%\reallenleft{3mm}\langle ===> \langle of size 3mm by resizing the
-%%%closest glyph
+%% \reallenleft{3mm}\langle ===> \langle of size 3mm by resizing the
+%% closest glyph
\newcommand{\reallenleft}[2]{\cut@reallengthldelim{#1}{#2}}
-%%%same for right and middle
\newcommand{\reallenright}[2]{\cut@reallengthrdelim{#1}{#2}}
\newcommand{\reallenmiddle}[2]{\cut@reallengthmdelim{#1}{#2}}
-% setting up mathstyle
+
+%%% Preliminary commands
+
+%% setting up mathstyle
\ifcut@mathstyle@
\RequirePackage{mathstyle}
\def\currentcutstyle{\currentmathstyle}
@@ -69,13 +88,7 @@
\def\currentcutstyle{\cutstyle}
\fi
-%setting up realVert
-\ifcut@realVert@
- \def\cut@bar{\cut@Vert}
-\else
- \def\cut@bar{\cut@vert}
-\fi
-
+%% sets the behaviour of delimiters to always grow while evaluating #1
\newcommand{\cut@setshortfall}[1]{%
\skip0=\delimitershortfall%
\global\delimitershortfall=-0.1pt%that's the trick to get perfect growth
@@ -86,186 +99,89 @@
\global\delimiterfactor=\count0%
}
-\newcommand{\cut@nextrdelim}[2]{%
- \left.\hspace{-\nulldelimiterspace}\vphantom{#2}\right#1%
-}
-\newcommand{\cut@nextldelim}[2]{%
- \left#1\vphantom{#2}\hspace{-\nulldelimiterspace}\right.%
-}
-\newcommand{\cut@nextmdelim}[2]{%
- \left.\hspace{-\nulldelimiterspace}\middle#1\vphantom{#2}\hspace{-\nulldelimiterspace}\right.%
-}
-
-\newcommand{\cut@lengthldelim}[2]{\cut@setshortfall{\cut@nextldelim#2{\rule[-0.101pt]{0pt}{#1}}}}
-\newcommand{\cut@lengthrdelim}[2]{\cut@setshortfall{\cut@nextrdelim#2{\rule[-0.101pt]{0pt}{#1}}}}
-\newcommand{\cut@lengthmdelim}[2]{\cut@setshortfall{\cut@nextmdelim#2{\rule[-0.101pt]{0pt}{#1}}}}
-\newcommand{\cut@reallengthldelim}[2]{\cut@resizetoheight{#1}{\cut@lengthldelim{#1}{#2}}}
-\newcommand{\cut@reallengthrdelim}[2]{\cut@resizetoheight{#1}{\cut@lengthrdelim{#1}{#2}}}
-\newcommand{\cut@reallengthmdelim}[2]{\cut@resizetoheight{#1}{\cut@lengthmdelim{#1}{#2}}}
-
-%\newcommand{\cut@nextrangle}[1]{%
-% \left.\hspace{-\nulldelimiterspace}\vphantom{#1}\right\rangle%
-%}
-\newcommand{\cut@nextrangle}[1]{\cut@nextrdelim{\rangle}{#1}}
-
-%\newcommand{\cut@nextlangle}[1]{%
-% \left\langle\vphantom{#1}\hspace{-\nulldelimiterspace}\right.%
-%}
-\newcommand{\cut@nextlangle}[1]{\cut@nextldelim{\langle}{#1}}
-
-\newcommand{\cut@iter}[2]{%
- \ifcase#1%
- #2{\cdot} % 0 = smallest. This dot is here to prevent a
- % bug regarding vertical positioning.
- \else%
- \count0=#1%
- \advance\count0 -1\relax%
- \expandafter#2{\expandafter\cut@iter{\the\count0}#2}%
- \fi%
-}
-
-\newcommand{\cut@primitive}[2]{%
- %resetting shortfall
- \cut@setshortfall{\cut@iter#2#1}%
-}
-
-%%%\cut@nthdelim{n}{delim}{f}
-\newcommand{\cut@nthdelim}[3]{
- \def\cut@tempnextdelim{#3{#2}}%
- \cut@primitive\cut@tempnextdelim{#1}%
-}
-\newcommand{\cut@nthldelim}[2]{\cut@nthdelim{#1}{#2}{\cut@nextldelim}}
-\newcommand{\cut@nthrdelim}[2]{\cut@nthdelim{#1}{#2}{\cut@nextrdelim}}
-\newcommand{\cut@nthmdelim}[2]{\cut@nthdelim{#1}{#2}{\cut@nextmdelim}}
-
-\newcommand{\cut@langleprimitive}[1]{\cut@primitive\cut@nextlangle{#1}}
-\newcommand{\cut@rangleprimitive}[1]{\cut@primitive\cut@nextrangle{#1}}
-%\newcommand{\cut@langleprimitive}[1]{\cut@nthldelim{#1}{\langle}}
-%\newcommand{\cut@rangleprimitive}[1]{\cut@nthrdelim{#1}{\rangle}}
-
-\newcommand{\cut@vertprimitiveunscaled}[1]{\cut@nthmdelim{#1}\vert}%\hbox{$\m@th\mathord{|}$}
-
-\newcommand{\cut@Vertprimitiveunscaled}[1]{\cut@nthmdelim{#1}\Vert}
-
-\newsavebox\cut@boxi
-\newsavebox\cut@boxj
-
+%% scale #2 to size #1 (length)
\newcommand{\cut@resizetoheight}[2]{%
\resizebox{!}{#1}{\hbox{$\m@th\currentcutstyle#2$}}%
}
+\newsavebox\cut@boxi
+\newsavebox\cut@boxj
+%% scale #2 to the size of #1. Assumes that #1 goes above and below the base line.
\newcommand{\cut@resizetoheightof}[2]{%
\sbox{\cut@boxi}{$\m@th\currentcutstyle#1$}%
\sbox{\cut@boxj}{$\m@th\currentcutstyle#2$}%
\raisebox{-\dp\cut@boxi}{%
- \resizebox{\width}{\ht\cut@boxi+\dp\cut@boxi}{%
+ \resizebox{!}{\ht\cut@boxi+\dp\cut@boxi}{%
\raisebox{\dp\cut@boxj}{\usebox{\cut@boxj}}%
}%
- }
-}
-
-\newcommand{\cut@vertprimitive}[1]{%
-\setbox0=\hbox{%
- $\m@th\currentcutstyle%
- \cut@resizetoheightof{\cut@langleprimitive{#1}}{\cut@vertprimitiveunscaled{#1}}%
- $}%
-\dimen0=\wd0
-\def\cut@unspace{%removing the margins around the bar
- \kern -.5\dimen0%
- \mkern.75mu%
-}%
-\cut@unspace%
-\copy0%
-\cut@unspace%
-\mspace{\cutinterbarskip}%
-\penalty \the\binoppenalty\relax%
-\cut@unspace%
-\box0%
-\cut@unspace%
-}
-
-\newcommand{\cut@halfvertprimitive}[1]{%
-\cut@resizetoheightof{\cut@langleprimitive{#1}}{\cut@vertprimitiveunscaled{#1}}%
-}
-
-\newcommand{\cut@Vertprimitive}[1]{%
-\mkern-3.26mu%
-\cut@resizetoheightof{\cut@langleprimitive{#1}}{\cut@Vertprimitiveunscaled{#1}}%
-\mkern-3.26mu%
-}
-
-
-\newcommand{\cut@langle}[1]{%
- \edef\cut@n{\expandafter\the#1}%
- %yes, i'm turning the integer into tokens to do call-by-value
- \cut@langleprimitive{\cut@n}%
-}
-
-\newcommand{\cut@rangle}[1]{%
- \edef\cut@n{\expandafter\the#1}%
- \cut@rangleprimitive{\cut@n}%
- \ifcutdebug^\cut@n\else\fi%
-}
-
-\newcommand{\cut@vert}[1]{%
- \edef\cut@n{\expandafter\the#1}%
- \cut@vertprimitive{\cut@n}%
+ }%
}
-\newcommand{\cut@halfvert}[1]{%
- \edef\cut@n{\expandafter\the#1}%
- \cut@halfvertprimitive{\cut@n}%
+%% gives the delimiter #1 which is immediately bigger than #2
+%% notice that \delimitershortfall is not modified so LaTeX can decide to give
+%% a smaller one.
+\newcommand{\cut@nextrdelim}[2]{\left.\hspace{-\nulldelimiterspace}\vphantom{#2}\right#1}
+\newcommand{\cut@nextldelim}[2]{\left#1\vphantom{#2}\hspace{-\nulldelimiterspace}\right.}
+\newcommand{\cut@nextmdelim}[2]{\left.\hspace{-\nulldelimiterspace}\middle#1\vphantom{#2}\hspace{-\nulldelimiterspace}\right.}
+
+%% like the previous one but resized to exactly match argument #1
+%% used in order to have vertical bars of the perfect size
+\newcommand{\cut@matchingldelim}[2]{\mathopen{\cut@resizetoheightof{#1}{\cut@nextldelim{#2}{#1}}}}
+\newcommand{\cut@matchingrdelim}[2]{\mathclose{\cut@resizetoheightof{#1}{\cut@nextrdelim{#2}{#1}}}}
+\newcommand{\cut@matchingmdelim}[2]{\mathrel{\cut@resizetoheightof{#1}{\cut@nextmdelim{#2}{#1}}}}
+
+%% gives the delimiter #2 which is immediately longer than #1 (length)
+\newcommand{\cut@lengthldelim}[2]{\mathopen{\cut@setshortfall{\cut@nextldelim#2{\rule[-0.101pt]{0pt}{#1}}}}}
+\newcommand{\cut@lengthrdelim}[2]{\mathclose{\cut@setshortfall{\cut@nextrdelim#2{\rule[-0.101pt]{0pt}{#1}}}}}
+\newcommand{\cut@lengthmdelim}[2]{\mathrel{\cut@setshortfall{\cut@nextmdelim#2{\rule[-0.101pt]{0pt}{#1}}}}}
+
+%% like the previous one but resized to exactly match #1 (length)
+\newcommand{\cut@reallengthldelim}[2]{\mathopen{\cut@resizetoheight{#1}{\cut@nextldelim#2{\rule[-0.101pt]{0pt}{#1}}}}}
+\newcommand{\cut@reallengthrdelim}[2]{\mathclose{\cut@resizetoheight{#1}{\cut@nextrdelim#2{\rule[-0.101pt]{0pt}{#1}}}}}
+\newcommand{\cut@reallengthmdelim}[2]{\mathrel{\cut@resizetoheight{#1}{\cut@nextmdelim#2{\rule[-0.101pt]{0pt}{#1}}}}}
+
+%I don't get anything about this bug which affects the
+%alignment with respect to the math axis
+\ifcut@fixxits@
+ \def\bugfix{}
+\else
+ \def\bugfix{\cdot}
+\fi
+%% iterates #2 over itself #1 number of times
+\newcommand{\cut@iter}[2]{%
+ \ifcase#1%
+ #2{\bugfix} % 0 = smallest. This dot is here to prevent a
+ % bug regarding vertical positioning.
+ \else%
+ \count0=#1%
+ \advance\count0 -1\relax%
+ \expandafter#2{\expandafter\cut@iter{\the\count0}#2}%
+ \fi%
}
-\newcommand{\cut@Vert}[1]{%
- \edef\cut@n{\expandafter\the#1}%
- \cut@Vertprimitive{\cut@n}%
+%% \cut@nthdelim{n}{delim}{f} iterates f{delim} n time over itself after
+%% resetting delimiter shortfall
+\newcommand{\cut@nthdelim}[3]{
+ \def\cut@tempnextdelim{#3{#2}}%
+ \cut@setshortfall{\cut@iter{#1}\cut@tempnextdelim}%
}
+%% \cut@nthxdelim gives the #1-th size of the delimiter #2
+\newcommand{\cut@nthldelim}[2]{\mathopen{\cut@nthdelim{#1}{#2}{\cut@nextldelim}}}
+\newcommand{\cut@nthrdelim}[2]{\mathclose{\cut@nthdelim{#1}{#2}{\cut@nextrdelim}}}
+\newcommand{\cut@nthmdelim}[2]{\mathrel{\cut@nthdelim{#1}{#2}{\cut@nextmdelim}}}
-\newcommand{\cut@angles}[1]{\cut@langle{#1}\cut@vert{#1}\cut@rangle{#1}}
-%%% now the main algorithm
+%%%% now the main algorithm
\newcounter{cut@depth}
-\newcommand{\cut@testangles}{%
- \setcounter{cut@depth}{0}%
- \def\cut@d{%
- \cut@angles{\value{cut@depth}}%
- \stepcounter{cut@depth}%
- }
- \cut@d\cut@d\cut@d\cut@d\cut@d\cut@d\cut@d
-}
-
-\newcommand{\cut@testssstyle}{\scriptscriptstyle{\cut@testangles}}
-\newcommand{\cut@testsstyle}{\scriptstyle{\cut@testangles}}
-\newcommand{\cut@testnormal}{\textstyle{\cut@testangles}}
-
-\newcommand{\cut@testsize}[1]{
-{#1 \[ \mathrm{\f@size\,pt:} \begin{array}{l}
- \cut@testnormal{}\\
- \cut@testsstyle{}\\
- \cut@testssstyle{}
- \end{array}\]}
-}
-
-\newcommand{\cut@test}{
-\cut@testsize{\Large}
-\cut@testsize{\large}
-\cut@testsize{}
-\cut@testsize{\small}
-\cut@testsize{\footnotesize}
-\cut@testsize{\scriptsize}
-\cut@testsize{\tiny}
-}
-
% lengths with names of the form \cut@height{depth}
\newcommand{\cut@localheight}{cut@height\thecut@depth}
\newcommand{\cut@newlocalheightcounter}{%
\@ifundefined{c@\cut@localheight}{\newcounter{\cut@localheight}}{}
}
-% boxes with names of the form \cut@savebox{num}@{depth}
+% boxes with names of the form \cut@savebox{num}@{depth}
\newcommand{\cut@localsavebox}[1]{cut@savebox#1@\thecut@depth}
\newcommand{\cut@newlocalsavebox}[1]{%
\@ifundefined{\cut@localsavebox{#1}}{%
@@ -278,7 +194,11 @@
\newsavebox\cut@boxleft
\newsavebox\cut@boxright
-\newcommand{\cut@}[2]{%
+%%% Definition of Cut primitives
+
+%% Main loop. #1 determines how the height is incremented. #2 and #3 are saved
+%% in cut@boxleft and cut@boxright. Computed height is stored in cut@finalheight
+\newcommand{\cut@computeBinary@main}[3]{%
\setcounter{cut@finalheight}{0}%
{%
\addtocounter{cut@depth}{1}%
@@ -289,10 +209,10 @@
%computing recursively
\setcounter{\cut@localheight}{-1}%
\expandafter\sbox\csname\cut@localsavebox{0}\endcsname%
- {$\m@th\currentcutstyle#1$}%
- \expandafter\sbox\csname\cut@localsavebox{1}\endcsname%
{$\m@th\currentcutstyle#2$}%
- \addtocounter{\cut@localheight}{1}%
+ \expandafter\sbox\csname\cut@localsavebox{1}\endcsname%
+ {$\m@th\currentcutstyle#3$}%
+ \addtocounter{\cut@localheight}{#1}%
%exporting values outside the local scope
\setcounter{cut@finalheight}{\value{\cut@localheight}}%
\global\sbox\cut@boxleft%
@@ -301,104 +221,255 @@
{\expandafter\usebox\csname\cut@localsavebox{1}\endcsname}%
\addtocounter{cut@depth}{-1}%
}%
- \@ifundefined{c@\cut@localheight}{}{%
+}
+
+%% Displays #1#2#3#4#5. Arguments #2 and #4 can contain other cut primitives.
+%% Calls to cut primitives inside #2 and #4 will have a smaller height.
+%% Arguments #1, #3 and #5 can access the current height in two different
+%% forms via \cut@n and \count0.
+\newcommand{\cut@computeBinary@IncreaseHeight}[5]{%
+ \cut@computeBinary@main{1}{#2}{#4}%
+ \@ifundefined{c@\cut@localheight}{}{% if #2 and #4 did not contain any cut primitive
\ifnum\value{cut@finalheight}>\value{\cut@localheight}%
\setcounter{\cut@localheight}{\value{cut@finalheight}}%
\fi%
- }%end @ifundefined
- \mspace{\cutangleouterskip}%
- {\cut@langle{\value{cut@finalheight}}}%
- \mspace{\cutangleskip}%
+ }%end @ifundefined
+ \count0=\value{cut@finalheight}%
+ \edef\cut@n{\expandafter\the\count0}%
+ #1%
\usebox{\cut@boxleft}%
- \mspace{\cutbarskip}%
- {\cut@bar{\value{cut@finalheight}}}%
- \mspace{\cutbarskip}%
+ #3%
\usebox{\cut@boxright}%
- \mspace{\cutangleskip}%
- {\cut@rangle{\value{cut@finalheight}}}%
- \mspace{\cutangleouterskip}%
+ #5%
}
-\newcommand{\cut@bra}[1]{%
- \setcounter{cut@finalheight}{0}%
- {%
- \addtocounter{cut@depth}{1}%
- %defining variables
- \cut@newlocalheightcounter%
- \cut@newlocalsavebox{0}%
- %\cut@newlocalsavebox{1}%
- %computing recursively
- \setcounter{\cut@localheight}{-1}%
- \expandafter\sbox\csname\cut@localsavebox{0}\endcsname%
- {$\m@th\currentcutstyle#1$}%
- %\expandafter\sbox\csname\cut@localsavebox{1}\endcsname%
- % {$\m@th\currentcutstyle#2$}%
- \addtocounter{\cut@localheight}{1}%
- %exporting values outside the local scope
- \setcounter{cut@finalheight}{\value{\cut@localheight}}%
- \global\sbox\cut@boxleft%
- {\expandafter\usebox\csname\cut@localsavebox{0}\endcsname}%
- %\global\sbox\cut@boxright%
- % {\expandafter\usebox\csname\cut@localsavebox{1}\endcsname}%
- \addtocounter{cut@depth}{-1}%
- }%
- \@ifundefined{c@\cut@localheight}{}{%
+%% Displays #1#2#3#4#5. Arguments #2 and #4 can contain other cut primitives.
+%% Does not increase the current height computed by cut primitives inside #2
+%% and #4.
+%% Arguments #1, #3 and #5 can access the current height in two different
+%% forms via \cut@n and \count0.
+\newcommand{\cut@computeBinary@CurrentHeight}[5]{%
+ \cut@computeBinary@main{0}{#2}{#4}%
+ \ifnum\value{cut@finalheight}<0%
+ \setcounter{cut@finalheight}{0}%
+ \fi%
+ \@ifundefined{c@\cut@localheight}{}{% if #2 and #4 did not contain any cut primitive
\ifnum\value{cut@finalheight}>\value{\cut@localheight}%
\setcounter{\cut@localheight}{\value{cut@finalheight}}%
\fi%
- }%end @ifundefined
- \mspace{\cutangleouterskip}%
- {\cut@langle{\value{cut@finalheight}}}%
- \mspace{\cutangleskip}%
+ }%end @ifundefined
+ \count0=\value{cut@finalheight}%
+ \edef\cut@n{\expandafter\the\count0}%
+ #1%
\usebox{\cut@boxleft}%
- \mspace{\cutbarskip}%
- \mkern-3.26mu%
- {\cut@halfvert{\value{cut@finalheight}}}%
- \mspace{\cutangleouterskip}%
- %\mspace{\cutbarskip}%
- %\usebox{\cut@boxright}%
- %\mspace{\cutangleskip}%
- %\cut@rangle{\value{cut@finalheight}}%
+ #3%
+ \usebox{\cut@boxright}%
+ #5%
}
-\newcommand{\cut@ket}[1]{%
- \setcounter{cut@finalheight}{0}%
- {%
- \addtocounter{cut@depth}{1}%
- %defining variables
- \cut@newlocalheightcounter%
- \cut@newlocalsavebox{0}%
- %\cut@newlocalsavebox{1}%
- %computing recursively
- \setcounter{\cut@localheight}{-1}%
- \expandafter\sbox\csname\cut@localsavebox{0}\endcsname%
- {$\m@th\currentcutstyle#1$}%
- %\expandafter\sbox\csname\cut@localsavebox{1}\endcsname%
- % {$\m@th\currentcutstyle#2$}%
- \addtocounter{\cut@localheight}{1}%
- %exporting values outside the local scope
- \setcounter{cut@finalheight}{\value{\cut@localheight}}%
- \global\sbox\cut@boxleft%
- {\expandafter\usebox\csname\cut@localsavebox{0}\endcsname}%
- %\global\sbox\cut@boxright%
- % {\expandafter\usebox\csname\cut@localsavebox{1}\endcsname}%
- \addtocounter{cut@depth}{-1}%
- }%
- \@ifundefined{c@\cut@localheight}{}{%
+%% Displays #1#2#3#4#5. Arguments #2 and #4 can contain other cut primitives.
+%% Does not increase the current height computed by cut primitives inside #2
+%% and #4 but the height to display is increased by 1.
+%% Arguments #1, #3 and #5 can access the height height in two different
+%% forms via \cut@n and \count0.
+\newcommand{\cut@computeBinary@CurrentHeightPlusOne}[5]{%
+ \cut@computeBinary@main{0}{#2}{#4}
+ \@ifundefined{c@\cut@localheight}{}{% if #2 and #4 did not contain any cut primitive
\ifnum\value{cut@finalheight}>\value{\cut@localheight}%
\setcounter{\cut@localheight}{\value{cut@finalheight}}%
\fi%
- }%end @ifundefined
- %\cut@langle{\value{cut@finalheight}}%
- %\mspace{\cutangleskip}%
- %\usebox{\cut@boxleft}%
- %\mspace{\cutbarskip}%
- \mspace{\cutangleouterskip}%
- {\cut@halfvert{\value{cut@finalheight}}}%
- \mkern-3.26mu%
- \mspace{\cutbarskip}%
- \usebox{\cut@boxleft}%right}%
- \mspace{\cutangleskip}%
- {\cut@rangle{\value{cut@finalheight}}}%
- \mspace{\cutangleouterskip}%
+ }%end @ifundefined
+ \count0=\value{cut@finalheight}%
+ \advance\count0 1%
+ \edef\cut@n{\expandafter\the\count0}%
+ #1%
+ \usebox{\cut@boxleft}%
+ #3%
+ \usebox{\cut@boxright}%
+ #5%
}
+
+%%% Implementation of the particular delimiters
+
+%% special vertical bars
+%% \vert adjusted to #1
+\newcommand{\cut@matchvert}[1]{%
+ \setbox0=\hbox{$\matchmiddle{#1}\vert$}%
+ \mkern.6mu%
+ \kern -.5\wd0%
+ \copy0%
+ \kern -.5\wd0%
+ \mkern.6mu%
+}
+
+%% special double vertical bars
+\newcommand{\cut@doublevert}[1]{%
+ \cut@matchvert{\nthleft{#1}\langle}
+ \mskip\cutinterbarskip%
+ \penalty \the\binoppenalty\relax%
+ \cut@matchvert{\nthleft{#1}\langle}
+}
+
+%% special double vertical bars (alternate)
+\newcommand{\cut@Vert}[1]{%
+ \setbox0=\hbox{$\matchmiddle{\nthleft{#1}\langle}\Vert$}%
+ \mkern.8mu%
+ \kern -.3\wd0%
+ \copy0%
+ \kern -.3\wd0%
+ \mkern.8mu%
+%\mkern-3.26mu%
+%\matchmiddle{\nthleft{#1}\langle}\Vert%
+%\mkern-3.26mu%
+}
+
+%% setting up realVert
+\ifcut@realVert@
+ \let\cut@bars\cut@Vert
+\else
+ \let\cut@bars\cut@doublevert
+\fi
+
+%% \perfectcut
+%% <#1||#2>, increases height, inserts skips
+\newcommand{\cut@}[2]{%
+ \cut@computeBinary@IncreaseHeight%
+ {\mskip\cutangleouterskip%
+ \nthleft{\cut@n}{\langle}%
+ \mskip\cutangleskip}%
+ {#1}%
+ {\mskip\cutbarskip%
+ \cut@bars{\cut@n}%
+ \mskip\cutbarskip}%
+ {#2}%
+ {\mskip\cutangleskip%
+ \nthright{\cut@n}{\rangle}%
+ \mskip\cutangleouterskip}%
+}
+
+%% \perfectbra
+%% <#1|, increases height, inserts skips
+\newcommand{\cut@bra}[1]{%
+ \cut@computeBinary@IncreaseHeight%
+ {\mskip\cutangleouterskip%
+ \nthleft{\cut@n}{\langle}%
+ \mskip\cutangleskip}%
+ {#1}%
+ {\mskip\cutbarskip%
+ \cut@matchvert{\nthleft{\cut@n}\langle}%
+ \mskip\cutangleouterskip}%
+ {}{}%only one argument
+}
+
+%% \perfectket
+%% |#1>, increases height, inserts skips
+\newcommand{\cut@ket}[1]{%
+ \cut@computeBinary@IncreaseHeight%
+ {\mskip\cutangleouterskip%
+ \cut@matchvert{\nthleft{\cut@n}\langle}%
+ \mskip\cutbarskip}%
+ {#1}%
+ {\mskip\cutangleskip%
+ \nthright{\cut@n}{\rangle}%
+ \mskip\cutangleouterskip}%
+ {}{}%only one argument
+}
+
+%% \perfectcase
+%% [#1|#2], height is current height plus one, inserts skips
+\newcommand{\cut@case}[2]{%
+ \cut@computeBinary@CurrentHeightPlusOne%
+ {\nthleft{\cut@n}[%
+ \mskip\cutangleskip}%
+ {#1}%
+ {\mskip\cutbarskip%
+ \cut@matchvert{\nthleft{\cut@n}[}%
+ \mskip\cutbarskip}%
+ {#2}%
+ {\mskip\cutangleskip%
+ \nthright{\cut@n}]}%
+}
+
+%% \perfectbrackets
+%% [#1], height is current height plus one, inserts skips only inside
+\newcommand{\cut@brackets}[1]{%
+ \cut@computeBinary@CurrentHeightPlusOne%
+ {\nthleft{\cut@n}[%
+ \mskip\cutangleskip}%
+ {#1}%
+ {\mskip\cutangleskip%
+ \nthright{\cut@n}]}%
+ {}{}%only one argument
+}
+
+%% \perfectparens
+%% (#1), height is current height, inserts skips only inside
+\newcommand{\cut@parens}[1]{%
+ \cut@computeBinary@CurrentHeight%
+ {\nthleft{\cut@n}(%
+ \mskip\cutangleskip}%
+ {#1}%
+ {\mskip\cutangleskip%
+ \nthright{\cut@n})}%
+ {}{}%only one argument
+}
+
+%% \perfectunary
+%% #2#4#3 where #2 and #3 are delimiters. The size of the delimiters is computed
+%% according to #1 which must be one of IncreaseHeight, CurrentHeight,
+%% or CurrentHeightPlusOne.
+\newcommand{\cut@customUnary}[4]{%
+ \csname cut@computeBinary@#1\endcsname%
+ {\nthleft{\cut@n}#2}%
+ {#4}%
+ {\nthright{\cut@n}#3}%
+ {}{}%
+}%
+
+%% \perfectbinary
+%% #2#5#3#6#4 where #2, #3 and #4 are delimiters. The size of the delimiters is
+%% computed according to #1 which must be one of IncreaseHeight, CurrentHeight,
+%% or CurrentHeightPlusOne.
+\newcommand{\cut@customBinary}[6]{%
+ \csname cut@computeBinary@#1\endcsname%
+ {\nthleft{\cut@n}#2}%
+ {#5}%
+ {\matchmiddle{\nthleft{\cut@n}#2}#3}%{{\nthmiddle{\cut@n}#4}}%
+ {#6}%
+ {\nthright{\cut@n}#4}%
+}%
+%% Example: The following displays a set {#1|#2} with delimiters of the
+%% appropriate size if there are \perfectcommands inside #1 and #2.
+%% \def\Set#1#2{\perfectbinary{IncreaseHeight}\{|\}{#1\mathrel{}}{\mathrel{}#2}}
+
+
+
+%%% for testing purposes
+\newcommand{\cut@testsize}[2]{
+{#1 \[ \mathrm{\f@size\,pt:} \begin{array}{l}
+ \scriptscriptstyle{#2}\\
+ \scriptstyle{#2}\\
+ \textstyle{#2}
+ \end{array}\]}
+}
+\newcommand{\cut@test}[1]{%
+\cut@testsize{\Large}{#1}%
+\cut@testsize{\large}{#1}%
+\cut@testsize{}{#1}%
+\cut@testsize{\small}{#1}%
+\cut@testsize{\footnotesize}{#1}%
+\cut@testsize{\scriptsize}{#1}%
+\cut@testsize{\tiny}{#1}%
+}
+\newcommand{\cut@testangles}{\cut@test{%
+ \cut@{\cut@{\cut@{\cut@{\cut@{a}{b}}{c}}{d}}{e}}{f}}%
+}%
+\newcommand{\cut@testverts}{
+ \def\line{\rule[-3ex]{0.5em}{3ex}}%
+ \def\v##1{\cut@doublevert{##1}\line}
+ \def\V##1{\cut@Vert{##1}\line}
+ \cut@test{%
+ \line\vert\line\v{0}\v{1}\v{2}\v{3}\v{4}\v{5}
+ \line\Vert\line\V{0}\V{1}\V{2}\V{3}\V{4}\V{5}
+}}%
+