From c323e97ada4b9c09aee417afa1db2efe4ce12e99 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sun, 11 Nov 2018 21:55:56 +0000 Subject: cryptocode (11nov18) git-svn-id: svn://tug.org/texlive/trunk@49131 c570f23f-e606-0410-a88d-b1316a301751 --- .../texmf-dist/tex/latex/cryptocode/cryptocode.sty | 424 ++++++++++++++++----- 1 file changed, 326 insertions(+), 98 deletions(-) (limited to 'Master/texmf-dist/tex/latex/cryptocode') diff --git a/Master/texmf-dist/tex/latex/cryptocode/cryptocode.sty b/Master/texmf-dist/tex/latex/cryptocode/cryptocode.sty index 5c1edac52b2..d406c963067 100644 --- a/Master/texmf-dist/tex/latex/cryptocode/cryptocode.sty +++ b/Master/texmf-dist/tex/latex/cryptocode/cryptocode.sty @@ -1,4 +1,4 @@ - %% Copyright 2015 Arno Mittelbach + %% Copyright 2018 Arno Mittelbach % % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3 @@ -13,12 +13,50 @@ % The Current Maintainer of this work is Arno Mittelbach. % % This work consists of the files cryptocode.tex and cryptocode.sty + % + % Changelog + % + % 2016/11/30 + % - changed \pckeystyle to ensure that subscripts on \sk and \pk are aligned the same + % before, $(\sk_R, \pk_R)$ had slightly misaligned subscripts due to Tex treating + % subscripts on composite objects with descenders differently than without. + % see https://groups.google.com/forum/#!msg/comp.text.tex/IaXu_xBG06Q/CibRPH5GCAAJ + % - added \NAND + % - added pcmbox environment for matrices in pseudocode + % + % 2016/12/02 + % - changed minheight for bbrbox environment to actually reflect a minimum height in tikz + % the old minheight which added space at the bottom was preserved as addheight + % - added namepos middle for bbrbox + % - added pcfail + % - added valign to pseudocode to allow minipage vertical alignment + % - added \setgameproceduredefaultstyle + % - ensure line numbers are right aligned to allow for two digit linenumbers having the same width + % + % 2017/08/26 + % - added \pcabort + % - better control whitespace for \pcif, \pcelse, \pcelseif + % + % 2017/10/02 + % - side and oside support to \bbroracleqryto and \bbroracleqryfrom + % - add bottom to namepos in bbrbox + % - names for brrinput and bbroutput + % - angle for bbrloop + % - fix length for bbrinput + % - introduce hoffset for bbrinput + % + % 2017/12/21 + % - added \pcunless + % + % 2018/11/11 + % replace obsolete l3regex + % \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{cryptocode} - [2015/04/22 v0.1 Cryptocode LaTeX package for writing pseudocode in cryptographic settings] + [2018/11/11 v0.3.0 Cryptocode LaTeX package for typesetting pseudocode, algorithms and protocols as well as cryptographic proofs.] -\def\hi{Hello, this is Arno's crypto code package. } +\def\hi{Hello, this is cryptocode.} \let\myDate\date \RequirePackage{amsmath} @@ -92,8 +130,10 @@ \providecommand{\supp}[1]{ \ensuremath{\operatorname{Supp}\olrk{#1}}} \providecommand{\entropy}[1]{\ensuremath{\operatorname{H}\olrk{#1}}} + \providecommand{\condentropy}[2]{\ensuremath{\operatorname{H}\olrk{#1\,\left|\,#2\vphantom{#1}\right.}}} \providecommand{\minentropy}[1]{\ensuremath{\operatorname{H_\infty}\olrk{#1}}} - \providecommand{\condminentropy}[2]{\ensuremath{\operatorname{\tilde{H}_\infty}\olrk{#1|#2}}} + \providecommand{\condminentropy}[2]{\ensuremath{\operatorname{H_\infty}\olrk{#1\,\left|\,#2\vphantom{#1}\right.}}} + \providecommand{\condavgminentropy}[2]{\ensuremath{\operatorname{\tilde{H}_\infty}\olrk{#1\,\left|\,#2\vphantom{#1}\right.}}} } \DeclareOption{sets}{ @@ -140,8 +180,12 @@ \DeclareOption{logic}{ \providecommand{\AND}{\ensuremath{\mathrm{AND}}} \providecommand{\OR}{\ensuremath{\mathrm{OR}}} + \providecommand{\NOR}{\ensuremath{\mathrm{NOR}}} \providecommand{\NOT}{\ensuremath{\mathrm{NOT}}} - \providecommand{\xor}{\ensuremath{\oplus}} + \providecommand{\NAND}{\ensuremath{\mathrm{NAND}}} + \providecommand{\XOR}{\ensuremath{\mathrm{XOR}}} + \providecommand{\XNOR}{\ensuremath{\mathrm{XNOR}}} + \providecommand{\xor}{\ensuremath{\oplus}} \providecommand{\false}{\mathsf{false}} \providecommand{\true}{\mathsf{true}} } @@ -154,6 +198,7 @@ \providecommand{\kgen}{\pcalgostyle{KGen}} \providecommand{\pgen}{\pcalgostyle{Pgen}} \providecommand{\eval}{\pcalgostyle{Eval}} + \providecommand{\invert}{\pcalgostyle{Inv}} \providecommand{\il}{\pcalgostyle{il}} \providecommand{\ol}{\pcalgostyle{ol}} @@ -227,7 +272,7 @@ } \DeclareOption{keys}{ - \providecommand{\pckeystyle}[1]{\ensuremath{\mathsf{#1}}} + \providecommand{\pckeystyle}[1]{\ensuremath{\mathsf{\protect\vphantom{p}#1}}} \providecommand{\pk}{\pckeystyle{pk}} \providecommand{\vk}{\pckeystyle{vk}} @@ -259,6 +304,8 @@ \ProcessOptions\relax +\RequirePackage{etex} + %amsfonts \ifpc@amsfonts \RequirePackage{amsfonts} @@ -274,13 +321,11 @@ \RequirePackage{forloop} \RequirePackage{array} \RequirePackage{xparse} -\RequirePackage{l3regex} +\RequirePackage{expl3} \RequirePackage{pbox} \RequirePackage{varwidth} \RequirePackage{suffix} \RequirePackage{etoolbox} -\RequirePackage{etex} -%\RequirePackage{etextools} \RequirePackage{environ} %\RequirePackage{xspace} \RequirePackage{xkeyval} @@ -460,6 +505,12 @@ \tl_use:N \l_pc_strsub_input_tl } +\NewDocumentCommand{\@pc@centercolifnec}{m}% +{% +#1% +} + + \ExplSyntaxOff @@ -501,8 +552,12 @@ %keep hyperref happy \ifmeasuring@\else\pc@original@label{#1}\fi% }% +\ifthenelse{\value{pclinenumber}<10}{\hspace{1ex}}{}% \hspace{\pclnspace}\text{\scriptsize\arabic{pclinenumber}}\pclnseparator\quad}% +% allow to skip numbering single lines if linenumbering=on +\providecommand{\pcnoln}{% +} % right align line numbers (same counter) \providecommand{\pclnr}{% @@ -532,6 +587,7 @@ \newcommand{\@withingame}{false} \newcommand{\@withinbxgame}{false} \newcommand{\@bxgameheader}{} +\newcommand{\@withingamedescription}{false} %%%%%%%%%%%% @@ -541,15 +597,17 @@ \newcommand{\@pc@beginnewline}{% -\@pseudocodelinenumber\@pc@and\@pcln% +\@pseudocodecodeatbeginline\@pseudocodelinenumber\@pc@and\@pcln% %checkspace \ifthenelse{\equal{\@pseudocodespace}{auto}}% {\expandafter\pcind\expandafter[\value{@pc@indentationlevel}]}% {}% +%reset column counter +\setcounter{pccolumncounter}{2}% %beginmode \@pc@modebegin} \newcommand{\@pc@and}{&} -\newcommand{\@pc@and@wrap@end}{\@pc@modeend&} +\newcommand{\@pc@and@wrap@end}{\@pc@modeend&\@pseudocodecodeatendline} \newcommand{\@pc@and@wrap@start}{\@pc@beginnewline} \newcommand{\pctabname}{>} \newcommand{\pcdbltabname}{<} @@ -568,6 +626,7 @@ \newcommand*\@pseudocodelnstartright{0} \newcommand*\@pseudocodesyntaxhighlighting{} \newcommand*\@pseudocodenodraft{false} +\newcommand*\@pseudocodecolspace{} % empty per default, use length, \newcommand*\@pseudocodeheadlinesep{0em} \newcommand*\@pseudocodebodylinesep{-0.5\baselineskip} @@ -575,9 +634,14 @@ \newcommand*\@pseudocodecolsep{0em} \newcommand*\@pseudocodeaddtolength{2pt} +\newcommand*\@pseudocodecodeatbeginline{} +\newcommand*\@pseudocodecodeatendline{} +\newcommand*\@pseudocodecodejot{0em} \newcommand*\@pseudocodecodesize{\small} \newcommand*\@pseudocodesubcodesize{\footnotesize} +\newcommand*\@pseudocodeminipagealign{t} + %%%%%%%%%%%%%% % Define keywords for the automatic syntax highlighting % the accompanying add provides additional keywords. @@ -593,12 +657,17 @@ \end{@withspaces} +\define@key{pseudocode}{beginline}[]{\renewcommand*\@pseudocodecodeatbeginline{#1}} +\define@key{pseudocode}{endline}[]{\renewcommand*\@pseudocodecodeatendline{#1}} +\define@key{pseudocode}{jot}[0em]{\renewcommand*\@pseudocodecodejot{#1}} \define@key{pseudocode}{codesize}[\small]{\renewcommand*\@pseudocodecodesize{#1}} \define@key{pseudocode}{subcodesize}[\small]{\renewcommand*\@pseudocodesubcodesize{#1}} \define@key{pseudocode}{head}[]{\renewcommand*\@pseudocodehead{#1}} \define@key{pseudocode}{width}[]{\renewcommand*\@pseudocodewidth{#1}} +\define@key{pseudocode}{valign}[t]{\renewcommand*\@pseudocodeminipagealign{#1}} \define@key{pseudocode}{xshift}[]{\renewcommand*\@pseudocodexshift{#1}} \define@key{pseudocode}{yshift}[]{\renewcommand*\@pseudocodeyshift{#1}} +\define@key{pseudocode}{colspace}[]{\renewcommand*\@pseudocodecolspace{#1}} \define@key{pseudocode}{linenumbering}[on]{\ifthenelse{\equal{#1}{on}}{\renewcommand*\@pseudocodelinenumber{\pcln}}{\renewcommand*\@pseudocodelinenumber{}}} \define@key{pseudocode}{beforeskip}[]{\renewcommand*\@pseudocodebeforeskip{#1}} \define@key{pseudocode}{afterskip}[]{\renewcommand*\@pseudocodeafterskip{#1}} @@ -613,8 +682,9 @@ \renewcommand*\@pc@modebegin{\begin{varwidth}{\textwidth}% %introduce line magic for text mode \let\@pc@lb\\% -\renewcommandx*{\\}[2][1=,2=]{\@pc@modeend\@pc@and \ifthenelse{\equal{####1}{}}{\@pc@lb}{\@pc@lb[####1]}####2 \@pc@beginnewline}% +\renewcommandx*{\\}[2][1=,2=]{\@pc@modeend\@pc@and \@pseudocodecodeatendline\ifthenelse{\equal{####1}{}}{\@pc@lb}{\@pc@lb[####1]}####2 \@pc@beginnewline}% \def\pclb{\let\\\@pc@lb\relax\@pc@modeend\\}% +\def\pcolb{\let\\\@pc@lb\relax\@pc@modeend\\}% }% \renewcommand*\@pc@modeend{\end{varwidth}} }{}% @@ -731,6 +801,8 @@ {\highlightaltkeyword{\@pc@spacesubstitution{#1}{ }{~}}}% } +\newcommand{\@pc@colspace}{} + %%%%%%%%%%%%%%%%% % Allow for spacing \newcommand{\@withinspaces}{false}% @@ -748,6 +820,9 @@ \newcommand{\@pc@decreaseindent}{\ifthenelse{\equal{\@pseudocodespace}{auto}}{\pcind[-1]}{}\addtocounter{@pc@indentationlevel}{-1}} \newcommand{\@pc@tmpdecreaseindent}{\ifthenelse{\equal{\@pseudocodespace}{auto}}{\pcind[-1]}{}} +\newcounter{pccolumncounter} +\setcounter{pccolumncounter}{2} + % store original halign \let\@pc@halign\halign% @@ -778,15 +853,22 @@ % % create tabbing command \ifcsname \pctabname\endcsname% -\expandafter\renewcommand\csname \pctabname\endcsname{\@pc@modeend&\@pc@modebegin}% +\expandafter\renewcommand\csname \pctabname\endcsname{\@pc@modeend&\@pc@colspace\@pc@modebegin}% \else% -\expandafter\newcommand\csname \pctabname\endcsname{\@pc@modeend&\@pc@modebegin}% +\expandafter\newcommand\csname \pctabname\endcsname{\@pc@modeend&\@pc@colspace\@pc@modebegin}% \fi% \ifcsname \pcdbltabname\endcsname% -\expandafter\renewcommand\csname \pcdbltabname\endcsname{\@pc@modeend&&\@pc@modebegin}% +\expandafter\renewcommand\csname \pcdbltabname\endcsname{\@pc@modeend&&\@pc@colspace\@pc@modebegin}% \else% -\expandafter\newcommand\csname \pcdbltabname\endcsname{\@pc@modeend&&\@pc@modebegin}% +\expandafter\newcommand\csname \pcdbltabname\endcsname{\@pc@modeend&&\@pc@colspace\@pc@modebegin}% \fi% +% create colspace command if necessary (must be empty for multicolumns +\ifthenelse{\equal{\@pseudocodecolspace}{}} + {} + {\renewcommand{\@pc@colspace}{\hspace{\@pseudocodecolspace}}}% +% +%adjust row width +\addtolength{\jot}{\@pseudocodecodejot}% % create indent command \expandafter\let\csname \pcindentname\endcsname\pcind% % @@ -801,6 +883,8 @@ \setlength{\@pc@alt@minipage@length}{0pt}% \setcounter{@pclinenumbertmp}{\value{pclinenumber}}% \setcounter{@pcrlinenumbertmp}{\value{pcrlinenumber}}% +%reset column counter +\setcounter{pccolumncounter}{2}% % % vertical space \vspace{\@pseudocodeyshift}% @@ -813,10 +897,11 @@ % line magic \ifthenelse{\value{@pc@global@pc@nestcnt}=1}{% \let\@pc@halign\halign% +\newenvironment{pcmbox}{\let\halign\@pc@halign}{}% \def\halign{% \renewcommand{\label}[1]{\ifmeasuring@\else\pc@original@label{####1}\fi}% \let\@pc@lb\\% -\renewcommandx*{\\}[2][1=,2=]{\@pc@modeend\@pc@and \ifthenelse{\equal{####1}{}}{\@pc@lb}{\@pc@lb[####1]}####2 \@pc@beginnewline}% +\renewcommandx*{\\}[2][1=,2=]{\@pc@modeend\@pc@and\@pseudocodecodeatendline \ifthenelse{\equal{####1}{}}{\@pc@lb}{\@pc@lb[####1]}####2 \@pc@beginnewline}% \def\pclb{\let\\\@pc@lb\relax\@pc@modeend\\}% \@pc@halign}% }{}% @@ -849,7 +934,7 @@ % %do the actual mini page \hspace{\@pseudocodexshift}% -\begin{minipage}[t]{\@pc@minipage@length}% +\begin{minipage}[\@pseudocodeminipagealign]{\@pc@minipage@length}% \ifthenelse{\value{@pcsubprogstep}=0}{% \pc@display@pseudocode{\@pseudocodehead}{\@pc@thecontent}% }{% if sub procedure @@ -914,8 +999,7 @@ $\begin{aligned}#2\end{aligned}$% \newcommand{\@pc@ensureremember}{% \ifthenelse{\value{@pc@remember}=0}{\tikzstyle{every picture}+=[remember picture]}{}% -\addtocounter{@pc@remember}{1} -} +\addtocounter{@pc@remember}{1}} \newcommand{\@pc@releaseremember}{% \addtocounter{@pc@remember}{-1}% @@ -949,8 +1033,8 @@ $\begin{aligned}#2\end{aligned}$% }% \endgroup} -\newcommandx*{\pcdraw}[1]{% -\begin{tikzpicture}[overlay,inner sep=0ex,baseline=0pt] +\newcommandx*{\pcdraw}[2][2=]{% +\begin{tikzpicture}[overlay,inner sep=0ex,baseline=0pt,#2] #1 \end{tikzpicture}} @@ -979,14 +1063,14 @@ $\begin{aligned}#2\end{aligned}$% \newcommand{\bbrenvnodenameprefix}{env-} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Black Box Reduction Enviconment +% Black Box Reduction Environment \newenvironmentx{bbrenv}[3][1=0pt,3=0pt]{% \addtocounter{@bb@env@nestcnt}{1}% \renewcommand{\@bb@lastbox}{#2}% % % reset lengths -\setlength{\@bb@message@hoffset}{0pt}% -\setlength{\@bb@query@hoffset}{0pt}% +\@pc@globalsetlength{\@bb@message@hoffset}{0pt}% +\@pc@globalsetlength{\@bb@query@hoffset}{0pt}% \@pc@globalsetlength{\@bb@oraclequery@hoffset}{0pt}% \@pc@globalsetlength{\@bb@challengerquery@hoffset}{0pt}% % @@ -1009,6 +1093,11 @@ $\begin{aligned}#2\end{aligned}$% }{\egroup}% \vspace{\@bbendskip}% \addtocounter{@bb@env@nestcnt}{-1}% +% reset lengths +\@pc@globalsetlength{\@bb@message@hoffset}{0pt}% +\@pc@globalsetlength{\@bb@query@hoffset}{0pt}% +\@pc@globalsetlength{\@bb@oraclequery@hoffset}{0pt}% +\@pc@globalsetlength{\@bb@challengerquery@hoffset}{0pt}% } %%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1017,19 +1106,23 @@ $\begin{aligned}#2\end{aligned}$% \newcommand*\bbrboxname{} \newcommand*\bbrboxnamepos{right} \newcommand*\bbrboxnamestyle{} -\newcommand*\@bbrboxnamepos{below=0.5ex of \@bb@lastbox.north east,anchor=north east} -\newcommand*\@bbrboxnameposoffset{below left=0cm of phantomname.north west} +\newcommand*\@bbrboxnamepos{below right=0.5ex and -0.5ex of \@bb@lastbox.north east,anchor=north east} +\newcommand*\bbrboxabovesep{\baselineskip} +\newcommand*\@bbrboxnameposoffset{below left=\bbrboxabovesep of phantomname.south west} \newcommand*\bbrboxstyle{draw} \newcommand*\bbrboxafterskip{} +\newcommand*\bbrboxminheight{0cm} \newcommand*\bbrboxminwidth{2cm} \newcommand*\bbrboxxshift{0cm} \newcommand*\bbrboxyshift{0cm} +\define@key{bbrbox}{abovesep}[]{\renewcommand*\bbrboxabovesep{#1}} \define@key{bbrbox}{name}[]{\renewcommand*\bbrboxname{#1}} \define@key{bbrbox}{namestyle}[]{\renewcommand*\bbrboxnamestyle{#1}} \define@key{bbrbox}{namepos}[]{\renewcommand*\bbrboxnamepos{#1}} \define@key{bbrbox}{style}[draw]{\renewcommand*\bbrboxstyle{#1}} \define@key{bbrbox}{minwidth}[]{\renewcommand*\bbrboxminwidth{#1}} -\define@key{bbrbox}{minheight}[]{\renewcommand*\bbrboxafterskip{#1}} +\define@key{bbrbox}{addheight}[]{\renewcommand*\bbrboxafterskip{#1}} +\define@key{bbrbox}{minheight}[]{\renewcommand*\bbrboxminheight{#1}} \define@key{bbrbox}{xshift}[]{\renewcommand*\bbrboxxshift{#1}} \define@key{bbrbox}{yshift}[]{\renewcommand*\bbrboxyshift{#1}} @@ -1040,13 +1133,17 @@ $\begin{aligned}#2\end{aligned}$% \ifthenelse{\equal{\bbrboxnamepos}{center}} {\renewcommand{\@bbrboxnamepos}{below=0.5ex of \@bb@lastbox.north,anchor=north}}{} \ifthenelse{\equal{\bbrboxnamepos}{left}} - {\renewcommand{\@bbrboxnamepos}{below=0.5ex of \@bb@lastbox.north west,anchor=north west}\renewcommand{\@bbrboxnameposoffset}{below left=1\baselineskip of phantomname.south west}}{} + {\renewcommand{\@bbrboxnamepos}{below=0.5ex of \@bb@lastbox.north west,anchor=north west}}{} \ifthenelse{\equal{\bbrboxnamepos}{top right}} - {\renewcommand{\@bbrboxnamepos}{above=0cm of \@bb@lastbox.north east,anchor=south east}}{} + {\renewcommand{\@bbrboxnamepos}{above=0cm of \@bb@lastbox.north east,anchor=south east}\renewcommand{\@bbrboxnameposoffset}{below left=0cm of phantomname.north west}}{} \ifthenelse{\equal{\bbrboxnamepos}{top center}} - {\renewcommand{\@bbrboxnamepos}{above=0cm of \@bb@lastbox.north,anchor=south}}{} + {\renewcommand{\@bbrboxnamepos}{above=0cm of \@bb@lastbox.north,anchor=south}\renewcommand{\@bbrboxnameposoffset}{below left=0cm of phantomname.north west}}{} \ifthenelse{\equal{\bbrboxnamepos}{top left}} - {\renewcommand{\@bbrboxnamepos}{above=0cm of \@bb@lastbox.north west,anchor=south west}}{} + {\renewcommand{\@bbrboxnamepos}{above=0cm of \@bb@lastbox.north west,anchor=south west}\renewcommand{\@bbrboxnameposoffset}{below left=0cm of phantomname.north west}}{} +\ifthenelse{\equal{\bbrboxnamepos}{middle}} + {\renewcommand{\@bbrboxnamepos}{above=0.5ex of \@bb@lastbox.base,anchor=south}}{} +\ifthenelse{\equal{\bbrboxnamepos}{bottom}} + {\renewcommand{\@bbrboxnamepos}{above=0.5ex of \@bb@lastbox.base,anchor=north}}{} \tikzset{BBRBOXSTYLE/.style/.expand once=\bbrboxstyle}% @@ -1055,17 +1152,18 @@ $\begin{aligned}#2\end{aligned}$% \tikzset{BBRBOXNAMEPOSOFFSET/.style/.expand once=\@bbrboxnameposoffset}% \node[inner sep=0pt,outer sep=0pt] (\@bb@lastbox-tmpouter) {}; -\node[inner sep=.3333em,anchor=north,BBRBOXSTYLE,below right=\bbrboxyshift and \bbrboxxshift of \@bb@lastbox-tmpouter] (\@bb@lastbox) \bgroup +\node[inner sep=.3333em,anchor=north,BBRBOXSTYLE,minimum height=\bbrboxminheight,below right=\bbrboxyshift and \bbrboxxshift of \@bb@lastbox-tmpouter] (\@bb@lastbox) \bgroup \tikz{ - \node[inner sep=0pt,outer sep=0pt] (phantomname) {}; %minimum width - \node[BBRBOXNAMEPOSOFFSET] (inner) {\begin{varwidth}{2\linewidth}\BODY\end{varwidth}}; + \node[inner sep=0pt,outer sep=0pt,minimum height=0cm] (phantomname) {}; %minimum width + \node[BBRBOXNAMEPOSOFFSET,minimum height=0cm] (\@bb@lastbox-inner) {\begin{varwidth}{2\linewidth}\BODY\end{varwidth}}; \ifthenelse{\equal{\bbrboxafterskip}{}}{}{ - \node[below=0cm of inner,minimum height=\bbrboxafterskip] {}; + \node[below=0cm of \@bb@lastbox-inner,minimum height=\bbrboxafterskip] {}; } - \node[inner sep=0pt,outer sep=0pt,at=(inner.south west)] () {\phantom{\hspace{\bbrboxminwidth}}}; %minimum width + \node[inner sep=0pt,outer sep=0pt,at=(\@bb@lastbox-inner.south west),minimum height=0cm] () {\phantom{\hspace{\bbrboxminwidth}}}; %minimum width } \egroup; -\node[BBRBOXNAMEPOS,BBRBOXNAMESTYLE, inner sep=0.2ex, outer sep=0pt, overlay] () {\bbrboxname}; +\ifthenelse{\equal{\bbrboxnamepos}{none}} +{}{\node[BBRBOXNAMEPOS,BBRBOXNAMESTYLE, inner sep=0.2ex, outer sep=0pt, overlay] () {\bbrboxname};} } @@ -1148,17 +1246,64 @@ $\begin{aligned}#2\end{aligned}$% } +\newcommand*\bbrinputlength{0.5cm} +\newcommand*\bbrinputhoffset{0.5cm} +\newcommand*\bbrinputbottom{} +\newcommand*\bbrinputtop{} +\newcommand*\bbrinputedgestyle{} +\newcommand*\bbrinputtopstyle{} +\newcommand*\bbrinputbottomstyle{} +\newcommand*\bbrinputnodestyle{} +\newcommand*\bbrinputnodename{} +\define@key{bbrinput}{length}[]{\renewcommand*\bbrinputlength{#1}} +\define@key{bbrinput}{hoffset}[]{\renewcommand*\bbrinputhoffset{#1}} +\define@key{bbrinput}{name}[]{\renewcommand*\bbrinputnodename{#1}} +\define@key{bbrinput}{top}[]{\renewcommand*\bbrinputtop{#1}} +\define@key{bbrinput}{bottom}[]{\renewcommand*\bbrinputbottom{#1}} + + +\newcommand{\@bb@inputsetup}[1]{ + %load keys + \begingroup % for local keys + + \setkeys{bbrinput}{#1}% + + \tikzset{BBRINPUT-NODESTYLE/.style/.expand once=\bbrinputedgestyle}% + \tikzset{BBRINPUT-TOPSTYLE/.style/.expand once=\bbrinputtopstyle}% + \tikzset{BBRINPUT-BOTTOMSTYLE/.style/.expand once=\bbrinputbottomstyle}% + \tikzset{BBRINPUT-EDGESTYLE/.style/.expand once=\bbrinputedgestyle}% + +} + +\newcommand{\@bb@inputfinalize}{ + \endgroup +} -\newcommandx{\bbrinput}[2][1=0.75cm]{% -\node[above right=#1 of \@bb@lastbox.north west] (input) {#2}; -\draw[->] (input) --++ (0,-0.75cm); +\newcommandx*{\bbrinput}[2][2=]{% +\@bb@inputsetup{#2} +\ifthenelse{\equal{\bbrinputnodename}{}} + {\renewcommand{\bbrinputnodename}{\@bb@lastbox-input}}{} + +\node[overlay,above right={\bbrinputlength} and {\bbrinputhoffset} of \@bb@lastbox.north west, anchor=south,BBRINPUT-NODESTYLE] (\bbrinputnodename) {#1}; +\path[->] (\bbrinputnodename.south) edge[BBRINPUT-EDGESTYLE] node[above,anchor=east,BBRINPUT-TOPSTYLE] () {\bbrinputtop} node[below,anchor=west,BBRINPUT-BOTTOMSTYLE] () {\bbrinputbottom} (\bbrinputnodename.south|-\@bb@lastbox.north); +\@bb@inputfinalize } -\newcommandx{\bbroutput}[2][1=0.75cm]{% -\node[below right=#1 of \@bb@lastbox.south west] (output) {#2}; -\draw[<-] (output) --++ (0,#1); +\newcommandx*{\bbroutput}[2][2=]{% +\@bb@inputsetup{#2} +\ifthenelse{\equal{\bbrinputnodename}{}} + {\renewcommand{\bbrinputnodename}{\@bb@lastbox-output}}{} + +\node[overlay,below right={\bbrinputlength} and {\bbrinputhoffset} of \@bb@lastbox.south west, anchor=north] (\bbrinputnodename) {#1}; +\draw[->] (\bbrinputnodename.north|-\@bb@lastbox.south) -- (\bbrinputnodename.north|-\bbrinputnodename.north); +\@bb@inputfinalize } +\newenvironment{bbrpic}[1][]{% +\begin{tikzpicture}[overlay,inner sep=0ex,baseline=0pt,#1]% +}{% +\end{tikzpicture}} + %%%%%%%%%%% % communication %temporary lengths @@ -1173,6 +1318,7 @@ $\begin{aligned}#2\end{aligned}$% \newcommand*\bbrcomtopstyle{} \newcommand*\bbrcombottomstyle{} \newcommand*\bbrcomside{} +\newcommand*\bbrcomoside{} \newcommand*\bbrcomtop{} \newcommand*\bbrcombottom{} \newcommand*\bbrcomedgestyle{} @@ -1187,6 +1333,7 @@ $\begin{aligned}#2\end{aligned}$% \define@key{bbrcom}{topstyle}[]{\renewcommand*\bbrcomtopstyle{#1}} \define@key{bbrcom}{bottomstyle}[]{\renewcommand*\bbrcombottomstyle{#1}} \define@key{bbrcom}{side}[]{\renewcommand*\bbrcomside{#1}} +\define@key{bbrcom}{oside}[]{\renewcommand*\bbrcomoside{#1}} \define@key{bbrcom}{top}[]{\renewcommand*\bbrcomtop{#1}} \define@key{bbrcom}{bottom}[]{\renewcommand*\bbrcombottom{#1}} \define@key{bbrcom}{edgestyle}[]{\renewcommand*\bbrcomedgestyle{#1}} @@ -1220,11 +1367,13 @@ $\begin{aligned}#2\end{aligned}$% \ifthenelse{\lengthtest{#2<\@bb@firstmessageheight}} {#3{\@bb@firstmessageheight}} { - #3{0.75\baselineskip} - \ifthenelse{\equal{\bbrcomtop}{}}{}{#3{0.75\baselineskip}} + #3{1.25\baselineskip} + \ifthenelse{\equal{\bbrcomtop}{}}{}{#3{0.5\baselineskip}} } - \setlength{\@bb@com@tmpoffset}{#2+\bbrcombeforeskip}% + #3{\bbrcombeforeskip} + + \setlength{\@bb@com@tmpoffset}{#2}% } \newcommand{\@bb@comfinalize}[1]{ @@ -1233,33 +1382,38 @@ $\begin{aligned}#2\end{aligned}$% \endgroup } -\newcommand{\@bbrmsg}[7]{ - \@bb@comsetup{#1}{#6}{#7} +\newcommand{\@bbrmsg}[8]{ + \@bb@comsetup{#1}{#7}{#8} % - \node[#3=\@bb@com@tmpoffset and \bbrcomlength of \@bb@lastbox.#4,BBRCOM-SIDESTYLE] (\bbrcomsidename) {\bbrcomside}; - \path[#2] (\bbrcomsidename) edge[BBRCOM-EDGESTYLE] node[above,BBRCOM-TOPSTYLE] (\bbrcomtopname) {\bbrcomtop} node[below,BBRCOM-BOTTOMSTYLE] (\bbrcombottomname) {\bbrcombottom} (\@bb@lastbox.#5|-\bbrcomsidename) node[inner sep=0pt,outer sep=0pt] (\bbrcomosidename) {}; + \node[#3=\@bb@com@tmpoffset and \bbrcomlength of \@bb@lastbox.#4,anchor=#6,BBRCOM-SIDESTYLE] (\bbrcomsidename) {\bbrcomside}; + \path[#2] (\bbrcomsidename.#6) edge[BBRCOM-EDGESTYLE] node[above,BBRCOM-TOPSTYLE] (\bbrcomtopname) {\bbrcomtop} node[below,BBRCOM-BOTTOMSTYLE] (\bbrcombottomname) {\bbrcombottom} (\@bb@lastbox.#5|-\bbrcomsidename) node[inner sep=0pt,outer sep=0pt] (\bbrcomosidename) {}; % - \@bb@comfinalize{#7} + \@bb@comfinalize{#8} } \newcommandx{\bbrmsgto}[1]{% -\@bbrmsg{#1}{->}{below left}{north west}{west}{\@bb@message@hoffset}{\bbrmsgspace} +\@bbrmsg{#1}{->}{below left}{north west}{west}{east}{\@bb@message@hoffset}{\bbrmsgspace} } \newcommandx{\bbrmsgfrom}[1]{% -\@bbrmsg{#1}{<-}{below left}{north west}{west}{\@bb@message@hoffset}{\bbrmsgspace} +\@bbrmsg{#1}{<-}{below left}{north west}{west}{east}{\@bb@message@hoffset}{\bbrmsgspace} +} +\newcommandx{\bbrmsgvdots}{% + \bbrmsgtxt[xshift=\bbrcomlength/2,beforeskip=-0.5\baselineskip,afterskip=-0.5\baselineskip]{$\vdots$} } + + \newcommandx{\bbrqryto}[1]{% -\@bbrmsg{#1}{<-}{below right}{north east}{east}{\@bb@query@hoffset}{\bbrqryspace} +\@bbrmsg{#1}{<-}{below right}{north east}{east}{west}{\@bb@query@hoffset}{\bbrqryspace} } \newcommandx{\bbrqryfrom}[1]{% -\@bbrmsg{#1}{->}{below right}{north east}{east}{\@bb@query@hoffset}{\bbrqryspace} +\@bbrmsg{#1}{->}{below right}{north east}{east}{west}{\@bb@query@hoffset}{\bbrqryspace} } \newcommand{\@bbroracleqry}[4]{ \@bb@comsetup{#1}{#3}{#4} % - \path[#2] (\@bb@lastoracle.north west) -- ++ (0,-\@bb@com@tmpoffset) node[inner sep=0pt,outer sep=0pt] (\bbrcomsidename){} edge[BBRCOM-EDGESTYLE] node[above,BBRCOM-TOPSTYLE] (\bbrcomtopname) {\bbrcomtop} node[below,BBRCOM-BOTTOMSTYLE] (\bbrcombottomname) {\bbrcombottom} (\@bb@lastbox.east|-\bbrcomsidename) node[inner sep=0pt,outer sep=0pt] (\bbrcomosidename) {}; + \path[#2] (\@bb@lastoracle.north west) -- ++ (0,-\@bb@com@tmpoffset) node[inner sep=0pt,outer sep=0pt] (\bbrcomsidename){\bbrcomside} edge[BBRCOM-EDGESTYLE] node[above,BBRCOM-TOPSTYLE] (\bbrcomtopname) {\bbrcomtop} node[below,BBRCOM-BOTTOMSTYLE] (\bbrcombottomname) {\bbrcombottom} (\@bb@lastbox.east|-\bbrcomsidename) node[inner sep=0pt,outer sep=0pt] (\bbrcomosidename) {\bbrcomoside}; % \@bb@comfinalize{#4} } @@ -1276,7 +1430,7 @@ $\begin{aligned}#2\end{aligned}$% \@bb@comsetup{#1}{#3}{#4} % - \path[#2] (\@bb@lastchallenger.north east) -- ++ (0,-\@bb@com@tmpoffset) node[inner sep=0pt,outer sep=0pt] (\bbrcomsidename){} edge[BBRCOM-EDGESTYLE] node[above,BBRCOM-TOPSTYLE] (\bbrcomtopname) {\bbrcomtop} node[below,BBRCOM-BOTTOMSTYLE] (\bbrcombottomname) {\bbrcombottom} (\@bb@lastbox.west|-\bbrcomsidename) node[inner sep=0pt,outer sep=0pt] (\bbrcomosidename) {}; + \path[#2] (\@bb@lastchallenger.north east) -- ++ (0,-\@bb@com@tmpoffset) node[inner sep=0pt,outer sep=0pt] (\bbrcomsidename){\bbrcomside} edge[BBRCOM-EDGESTYLE] node[above,BBRCOM-TOPSTYLE] (\bbrcomtopname) {\bbrcomtop} node[below,BBRCOM-BOTTOMSTYLE] (\bbrcombottomname) {\bbrcombottom} (\@bb@lastbox.west|-\bbrcomsidename) node[inner sep=0pt,outer sep=0pt] (\bbrcomosidename) {\bbrcomoside}; % \@bb@comfinalize{#4} } @@ -1294,16 +1448,18 @@ $\begin{aligned}#2\end{aligned}$% \newcommand*\bbrcomloopleft{} \newcommand*\bbrcomloopright{} \newcommand*\bbrcomloopcenter{} +\newcommand*\bbrcomloopangle{50} \define@key{bbrcomloop}{left}[]{\renewcommand*\bbrcomloopleft{#1}} \define@key{bbrcomloop}{right}[]{\renewcommand*\bbrcomloopright{#1}} \define@key{bbrcomloop}{center}[]{\renewcommand*\bbrcomloopcenter{#1}} +\define@key{bbrcomloop}{angle}[]{\renewcommand*\bbrcomloopangle{#1}} \newcommand{\bbrloop}[3]{ \begingroup % for local keys \setkeys{bbrcomloop}{#3}% - \path[->] (#1) edge[bend right=50] node[midway,left] (bbrleft) {\bbrcomloopleft} (#2); - \path[->] (#2) edge[bend right=50] node[midway,right] (bbrright) {\bbrcomloopright} (#1); + \path[->] (#1) edge[bend right=\bbrcomloopangle] node[midway,left] (bbrleft) {\bbrcomloopleft} (#2); + \path[->] (#2) edge[bend right=\bbrcomloopangle] node[midway,right] (bbrright) {\bbrcomloopright} (#1); \node[at=($(bbrleft.north west)!0.5!(bbrright.north east)$),anchor=north]() {\bbrcomloopcenter}; \endgroup @@ -1329,11 +1485,12 @@ $\begin{aligned}#2\end{aligned}$% \newcommand{\@bbrintertext}[6]{ \@bb@intertextsetup{#1} - %introduce space - #5{\baselineskip} - - %compute offset - \setlength{\@bb@com@tmpoffset}{#4+\@bb@firstmessageheight+\bbrcombeforeskip}% + % increase space + \ifthenelse{\lengthtest{#4<\@bb@firstmessageheight}} + {#5{\@bb@firstmessageheight}} + {#5{1\baselineskip}} + + \setlength{\@bb@com@tmpoffset}{#4+\bbrcombeforeskip}% % \node[#2=\@bb@com@tmpoffset and \bbrintertexthoffset of \@bb@lastbox.#3,BBRBASE-NODESTYLE] (\bbrbasenodename) {#6}; @@ -1396,11 +1553,11 @@ $\begin{aligned}#2\end{aligned}$% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % stacking -\providecommand{\pccenteraboveskip}{0.5\baselineskip} -\providecommand{\pccenterbelowskip}{0.5\baselineskip} +\providecommand{\pccenteraboveskip}{0.5\baselineskip plus 0.25\baselineskip minus 0.25\baselineskip} +\providecommand{\pccenterbelowskip}{0.5\baselineskip plus 0.25\baselineskip minus 0.25\baselineskip} \newenvironment{pccenter}{% \setlength\topsep{0pt}\setlength\parskip{0pt}% -\begin{center}\vspace{\pccenteraboveskip} +\begin{center}\vspace{\pccenteraboveskip}% }{% \vspace{\pccenteraboveskip}% \end{center}} @@ -1510,6 +1667,9 @@ $\begin{aligned}#2\end{aligned}$% % create procedure \createprocedurecommand{procedure}{}{}{} + + + %%% % send message \newcommand{\pcshortmessageoffset}{0.5cm} @@ -1557,7 +1717,7 @@ $\begin{aligned}#2\end{aligned}$% \define@key{pcsendmessage}{afterskip}[]{\renewcommand*\@pcsendmessageafterskip{#1}} -\newcommand{\centerincol}[2]{% +\newcommand{\@pc@centerincol}[2]{% \ifmeasuring@% #2% \else% @@ -1565,12 +1725,14 @@ $\begin{aligned}#2\end{aligned}$% \fi% } +\newcommand{\centerincol}[1]{\@pc@centerincol{\thepccolumncounter}{#1}} + \newcommand{\@do@sendmessage}[1]{% \ifthenelse{\equal{\@pcsendmessagecol}{}}{% \ifthenelse{\equal{\@pcsendmessagewidth}{}}{#1}{% we have some width \makebox[\@pcsendmessagewidth]{$\displaystyle#1$}% }}{%we know the column to center on -\centerincol{\@pcsendmessagecol}{#1}% +\@pc@centerincol{\@pcsendmessagecol}{#1}% }% } @@ -1645,6 +1807,9 @@ $\begin{aligned}#2\end{aligned}$% % \newcounter{pcstartgamecounter} + +\newcommand*{\pcgameprocedurestyle}{} % define pseudocode arguments for game procedures + \newcommand*{\pcgamename}{\ensuremath{\mathsf{Game}}} \newcommand*{\gameprocedurearg}{\ensuremath{(\secpar)}} \newcommand*\@pcgameproofgamenr{0} @@ -1654,16 +1819,19 @@ $\begin{aligned}#2\end{aligned}$% \newenvironment{gameproof}[1][]{% \begingroup% -\setkeys{pcgameproof}{#1} +\setkeys{pcgameproof}{#1}% \@pc@ensureremember% \setcounter{pcgamecounter}{\@pcgameproofgamenr}% \setcounter{pcstartgamecounter}{\@pcgameproofgamenr}\stepcounter{pcstartgamecounter}% }{\@pc@releaseremember\endgroup} +\newcommand{\setgameproceduredefaultstyle}[1]{% \createpseudocodecommand{gameprocedure} {\addtocounter{pcgamecounter}{1}\renewcommand{\@withingame}{true}} {\ensuremath{\pcgamename_{\thepcgamecounter}\gameprocedurearg}} - {} + {#1} +} +\setgameproceduredefaultstyle{} \def\@bxgame@pseudocodeA[#1]#2#3{\setkeys*{pcspace}{#1}\renewcommand{\@bxgameheader}{$\pcgamename_{#2}$\gameprocedurearg}% \@pseudocode[head=\ensuremath{\pcgamename_{\thepcgamecounter}\gameprocedurearg},#1]{#3}} @@ -1695,11 +1863,15 @@ $\begin{aligned}#2\end{aligned}$% \newcommand*\@pcgamehopedgestyle{bend left} \newcommand*\@pcgamehoppathestyle{} \newcommand*\@pcgamehophint{} +\newcommand*\@pcgamehophintbelow{} +\newcommand*\@pcgamehopinhint{} \newcommand*\@pcgamehoplength{1.5cm} \define@key{pcgamehop}{nodestyle}[]{\renewcommand*\@pcgamehopnodestyle{#1}} \define@key{pcgamehop}{edgestyle}[]{\renewcommand*\@pcgamehopedgestyle{#1}} \define@key{pcgamehop}{pathstyle}[]{\renewcommand*\@pcgamehoppathestyle{#1}} \define@key{pcgamehop}{hint}[]{\renewcommand*\@pcgamehophint{#1}} +\define@key{pcgamehop}{belowhint}[]{\renewcommand*\@pcgamehophintbelow{#1}} +\define@key{pcgamehop}{inhint}[]{\renewcommand*\@pcgamehopinhint{#1}} \define@key{pcgamehop}{length}[]{\renewcommand*\@pcgamehoplength{#1}} @@ -1715,24 +1887,31 @@ $\begin{aligned}#2\end{aligned}$% } \newcommandx*{\addgamehop}[3]{% -\begingroup -\ifthenelse{#1<#2}{}{\renewcommand*\@pcgamehopedgestyle{bend right}} -\@pc@setupgamehop{#3} -\begin{tikzpicture}[overlay] -\ifthenelse{#1<#2}{ - \path[->,GAMEHOP-PATH-STYLE] (gamenode#1) edge[GAMEHOP-EDGE-STYLE] node[above,GAMEHOP-NODE-STYLE] {\@pcgamehophint} (gamenode#2); -}{ - \path[->,GAMEHOP-PATH-STYLE] (bgamenode#1) edge[GAMEHOP-EDGE-STYLE] node[above,GAMEHOP-NODE-STYLE] {\@pcgamehophint} (bgamenode#2); -} -\end{tikzpicture} -\@pc@finalizegamehop -\endgroup +\begingroup% +\ifthenelse{#1<#2}% + {\ifthenelse{\equal{\@withingamedescription}{true}}% + {\renewcommand*\@pcgamehopedgestyle{bend right=20}\renewcommand*\@pcgamehopnodestyle{rotate=90}}{}% + }% + {\renewcommand*\@pcgamehopedgestyle{bend right}}% +\@pc@setupgamehop{#3}% +\begin{tikzpicture}[overlay]% +\ifthenelse{#1<#2}{% + \path[->,GAMEHOP-PATH-STYLE] (gamenode#1) edge[GAMEHOP-EDGE-STYLE] node[above,GAMEHOP-NODE-STYLE] {\@pcgamehophint} + node[below,GAMEHOP-NODE-STYLE] {\@pcgamehophintbelow} (gamenode#2); +}{% + \path[->,GAMEHOP-PATH-STYLE] (bgamenode#1) edge[GAMEHOP-EDGE-STYLE] node[above,GAMEHOP-NODE-STYLE] {\@pcgamehophint} + node[above,GAMEHOP-NODE-STYLE] {\@pcgamehophintbelow} (bgamenode#2); +}% +\end{tikzpicture}% +\@pc@finalizegamehop% +\endgroup% } \newcommandx*{\addstartgamehop}[2][1=\thepcstartgamecounter]{% \@pc@setupgamehop{#2} \begin{tikzpicture}[overlay] \node[left=\@pcgamehoplength of gamenode#1] (tmpgamenode0) {}; - \path[->,GAMEHOP-PATH-STYLE] (tmpgamenode0) edge[GAMEHOP-EDGE-STYLE] node[above,GAMEHOP-NODE-STYLE] {\@pcgamehophint} (gamenode#1); + \path[->,GAMEHOP-PATH-STYLE] (tmpgamenode0) edge[GAMEHOP-EDGE-STYLE] node[above,GAMEHOP-NODE-STYLE] {\@pcgamehophint} + node[below,GAMEHOP-NODE-STYLE] {\@pcgamehophintbelow} (gamenode#1); \end{tikzpicture} \@pc@finalizegamehop } @@ -1740,14 +1919,16 @@ $\begin{aligned}#2\end{aligned}$% \@pc@setupgamehop{#2} \begin{tikzpicture}[overlay] \node[right=\@pcgamehoplength of gamenode#1] (tmpgamenode#1) {}; - \path[->,GAMEHOP-PATH-STYLE] (gamenode#1) edge[GAMEHOP-EDGE-STYLE] node[above,GAMEHOP-NODE-STYLE] {\@pcgamehophint} (tmpgamenode#1); + \path[->,GAMEHOP-PATH-STYLE] (gamenode#1) edge[GAMEHOP-EDGE-STYLE] node[above,GAMEHOP-NODE-STYLE] {\@pcgamehophint} + node[below,GAMEHOP-NODE-STYLE] {\@pcgamehophintbelow} (tmpgamenode#1); \end{tikzpicture} \@pc@finalizegamehop } \newcommandx*{\addbxgamehop}[3]{% \@pc@setupgamehop{#3} \begin{tikzpicture}[overlay] - \path[->,GAMEHOP-PATH-STYLE] (bgamenode#1) edge[GAMEHOP-EDGE-STYLE] node[above,GAMEHOP-NODE-STYLE]] {\@pcgamehophint} (bgamenode#2); + \path[->,GAMEHOP-PATH-STYLE] (bgamenode#1) edge[GAMEHOP-EDGE-STYLE] node[above,GAMEHOP-NODE-STYLE]] {\@pcgamehophint} + node[below,GAMEHOP-NODE-STYLE] {\@pcgamehophintbelow} (bgamenode#2); \end{tikzpicture} \@pc@finalizegamehop } @@ -1755,12 +1936,56 @@ $\begin{aligned}#2\end{aligned}$% \@pc@setupgamehop{#2} \begin{tikzpicture}[overlay] \node (looptemp1) [right=0.5cm of gamenode#1] {}; - \draw[->,GAMEHOP-PATH-STYLE] (gamenode#1) -- (looptemp1|-gamenode#1) -- node[right,GAMEHOP-NODE-STYLE] {\@pcgamehophint} (looptemp1|-bgamenode#1)-- (bgamenode#1); + \draw[->,GAMEHOP-PATH-STYLE] (gamenode#1) -- (looptemp1|-gamenode#1) -- node[right,GAMEHOP-NODE-STYLE] {\@pcgamehophint} + node[left,GAMEHOP-NODE-STYLE] {\@pcgamehophintbelow} (looptemp1|-bgamenode#1)-- (bgamenode#1); \end{tikzpicture} \@pc@finalizegamehop } +%%%%%%%% +% game description +\newenvironment{gamedescription}[1][]{% +\begingroup% +\setkeys{pcgameproof}{#1} +\renewcommand{\@withingamedescription}{true}% +\@pc@ensureremember% +\setcounter{pcgamecounter}{\@pcgameproofgamenr}% +\setcounter{pcstartgamecounter}{\@pcgameproofgamenr}\stepcounter{pcstartgamecounter}% +\begin{description}% +}{\end{description}\@pc@releaseremember\endgroup} + +\newcommandx*{\describegame}[1][1=]{% +\addtocounter{pcgamecounter}{1}% +\item[% +\pcdraw{ +\gdef\i{\thepcgamecounter}% +\node[inner sep=0.0em,outer sep=0, xshift=-1ex, yshift=0.5ex] (gamenode\i) {}; +}% +\ensuremath{\pcgamename_{\thepcgamecounter}\gameprocedurearg}:]% +\begingroup\setkeys{pcgamehop}{#1}% +\ifthenelse{\equal{}{\@pcgamehophint}} + {} + {\hspace{-0.7ex}\pcdraw{%the -0.7ex is a horrible hack to fix a whitespace issue with tikz (see http://tex.stackexchange.com/questions/22873/tikzpicture-with-overlay-takes-up-space +\tikzset{GAMEHOP-PATH-STYLE/.style/.expand once=\@pcgamehoppathestyle}% +\tikzset{GAMEHOP-NODE-STYLE/.style/.expand once=\@pcgamehopnodestyle}% +\draw[->,GAMEHOP-PATH-STYLE] (gamenode\thepcgamecounter) --++ (0,-\@pcgamehoplength) node[midway,above,xshift=-1mm,rotate=90,GAMEHOP-NODE-STYLE] {\@pcgamehophint}; +}}% +\ifthenelse{\equal{}{\@pcgamehopinhint}} + {} + {\hspace{-0.7ex}\pcdraw{%the -0.7ex is a horrible hack to fix a whitespace issue with tikz (see http://tex.stackexchange.com/questions/22873/tikzpicture-with-overlay-takes-up-space +\tikzset{GAMEHOP-PATH-STYLE/.style/.expand once=\@pcgamehoppathestyle}% +\tikzset{GAMEHOP-NODE-STYLE/.style/.expand once=\@pcgamehopnodestyle}% +\draw[<-,GAMEHOP-PATH-STYLE] (gamenode\thepcgamecounter) --++ (0,\@pcgamehoplength) node[midway,above,xshift=-1mm,rotate=90,GAMEHOP-NODE-STYLE] {\@pcgamehopinhint}; +}% +}% +\endgroup% +} + + + + + %%%%%%%% % basic pseudocode constants @@ -1773,13 +1998,14 @@ $\begin{aligned}#2\end{aligned}$% \newcommand{\pcwhile}{\@pc@increaseindent\highlightkeyword{while}} \newcommand{\pcendwhile}{\@pc@decreaseindent\highlightkeyword{endwhile}} \newcommandx*{\pcdo}[2][1=\ ,2=]{#1\highlightkeyword[#2]{do}} -\newcommand{\pcif}{\@pc@increaseindent\highlightkeyword{if}} -\newcommand{\pcelse}{\@pc@tmpdecreaseindent\highlightkeyword{else}} -\newcommand{\pcelseif}{\@pc@tmpdecreaseindent\highlightkeyword{else if}} +\newcommandx*{\pcif}[1][1=\ ]{\@pc@increaseindent\highlightkeyword[#1]{if}} +\newcommandx*{\pcunless}[1][1=\ ]{\@pc@increaseindent\highlightkeyword[#1]{unless}} +\newcommandx*{\pcelse}[1][1=\ ]{\@pc@tmpdecreaseindent\highlightkeyword[#1]{else}} +\newcommandx*{\pcelseif}[1][1=\ ]{\@pc@tmpdecreaseindent\highlightkeyword[#1]{else if}} \newcommand{\pcfi}{\@pc@decreaseindent\highlightkeyword{fi}} \newcommand{\pcendif}{\@pc@decreaseindent\highlightkeyword{endif}} \newcommand{\pcendfor}{\@pc@decreaseindent\highlightkeyword{endfor}} -\newcommandx*{\pcthen}[2][1=\ ,2=]{#1\highlightkeyword[#2]{then}} +\newcommandx*{\pcthen}[2][1=\ ,2=\ ]{#1\highlightkeyword[#2]{then}} \newcommand{\pcreturn}{\highlightkeyword{return}} \newcommandx*{\pcin}[2][1=\ ,2=]{#1\highlightkeyword[#2]{in}} \newcommand{\pcfor}{\@pc@increaseindent\highlightkeyword{for}} @@ -1789,18 +2015,20 @@ $\begin{aligned}#2\end{aligned}$% \newcommand{\pcendforeach}{\@pc@decreaseindent\highlightkeyword{endforeach}} \newcommand{\pcuntil}{\@pc@decreaseindent\highlightkeyword{until}} \newcommand{\pccontinue}{\highlightkeyword{continue}} -\newcommand{\pcfalse}{\highlightkeyword{false}} -\newcommand{\pctrue}{\highlightkeyword{true}} -\newcommand{\pcnull}{\highlightkeyword{null}} +\newcommandx*{\pcfalse}[2][1=\ ,2=]{\highlightkeyword[#2]{false}} +\newcommandx*{\pctrue}[2][1=\ ,2=]{\highlightkeyword[#2]{true}} +\newcommandx*{\pcnull}[2][1=\ ,2=]{\highlightkeyword[#2]{null}} \newcommand{\pccomment}[1]{{\mbox{/\!\!/ } \text{\scriptsize#1}}} \newcommand{\pcdone}{\highlightkeyword{done}} \newcommand{\pcparse}{\highlightkeyword{parse}} +\newcommand{\pcfail}{\highlightkeyword{fail}} +\newcommand{\pcabort}{\highlightkeyword{abort}} %%% % highlighting -\definecolor{highlight-gray}{gray}{0.90} -\newcommand{\gamechange}[2][highlight-gray]{% -{\setlength{\fboxsep}{0pt}\colorbox{#1}{\ifmmode$\displaystyle#2$\else#2\fi}} +\definecolor{gamechangecolor}{gray}{0.90} +\newcommand{\gamechange}[2][gamechangecolor]{% +{\setlength{\fboxsep}{0pt}\colorbox{#1}{\ifmmode$\displaystyle#2$\else#2\fi}}% } %%% -- cgit v1.2.3