%!TEX root = r6rs.tex

\usepackage{latexsym}
\usepackage{mathrsfs}
\usepackage{stmaryrd}

\newcounter{subfig}
\newcommand{\subfigurestart}{\renewcommand{\thefigure}{A.\arabic{figure}\alph{subfig}}\setcounter{subfig}{1}}


% needed for the second thru the nth figure
\newcommand{\subfigureadjust}{\addtocounter{figure}{-1}\addtocounter{subfig}{1}}

\newcommand{\subfigurestop}{\renewcommand{\thefigure}{A.\arabic{figure}}}


\newcommand{\semanticsindex}[2]{\index{#1@{\texttt{#1} (formal semantics)}}}

\newcommand{\pltreducks}{PLT Redex}
\newcommand{\rnrs}{Report}
\newcommand{\rnrslongspace}{\mbox{Revised\ensuremath{\,^{\mbox{\textrm{\scriptsize 5}}}} Report on Scheme}}
\newcommand{\rnrslong}{\mbox{Revised\ensuremath{^{\mbox{\textrm{\scriptsize 5}}}} Report on Scheme}}
\newcommand{\largernrslong}{\mbox{Revised\ensuremath{\,^{\mbox{\textrm{\large 5}}}} Report on Scheme}}

%\newenvironment*{proof}
%{\noindent\textbf{Proof} }
%{$\Box$ \\}

%\newcommand{\either}{*\!{}\!{}\!\!\circ}
\newcommand{\either}{*\!\circ}

\newcommand{\hole}{[~]}
\newcommand{\holes}{\ensuremath{\hole_{\star}}}
\newcommand{\holeone}{\ensuremath{\hole_\circ}}
\newcommand{\holeany}{\ensuremath{\hole_{\either}}}

%% multi-letter nonterminals (one-letter can be done with $_$)
\newcommand{\nt}[1]{\textnormal{\textit{#1}}}

%\newcommand{\sy}[1]{\textnormal{\textbf{#1}}}
%\newcommand{\va}[1]{\textnormal{\textsf{#1}}}

\newcommand{\sy}[1]{{\cf #1}}
\newcommand{\va}[1]{{\cf #1}}


\newcommand{\beginF}{\ensuremath{\textbf{begin}^{\mbox{\textrm{\textbf{\scriptsize F}}}}}}
\newcommand{\Eo}{\ensuremath{E^{\circ}}}
\newcommand{\Estar}{\ensuremath{E^{\star}}}
\newcommand{\Fo}{\ensuremath{F^{\circ}}}
\newcommand{\Fstar}{\ensuremath{F^{\star}}}
\newcommand{\Io}{\ensuremath{I^{\circ}}}
\newcommand{\Istar}{\ensuremath{I^{\star}}}

\imgdef\calP{\ensuremath{\mathcal{P}}}
\imgdef\calS{\ensuremath{\mathcal{S}}}
\imgdef\calR{\ensuremath{\mathcal{R}}}
\imgdef\calRv{\ensuremath{\mathcal{R}_v}}
\imgdef\calA{\ensuremath{\mathcal{A}}}
\imgdef\scrO{\ensuremath{\mathscr{O}}}

\newcommand{\semfalse}{\texttt{\#f}}
\newcommand{\semtrue}{\texttt{\#t}}

\newcommand{\aline}{\noindent\hrulefill\par}

%\def\beginfig{\begin{figure*}[t]{\noindent\hrulefill\par}\small}
%\def\endfig{{\noindent\hrulefill\par}\end{figure*}}

\def\beginfig{\begin{figure*}[tb!]{\noindent\par}\small}
\def\endfig{{\noindent\hrulefill\par}\end{figure*}}

\newcommand{\dom}{\textit{dom}}

\newcommand{\gopen}{{^{\scriptscriptstyle\lceil}\!\!}}
\newcommand{\gclose}{\!\!{}^{\scriptscriptstyle\rceil}}

\newcommand{\mrk}{\diamond}
\newcommand{\umrk}{^\mrk}

\newcommand{\rulename}[1]{\textsf{[#1]}}

\newcommand{\extraspterm}{\\[6pt]}

\newcommand{\twolinerule}[3]{\twolineruleA{#1}{#2}{\rulename{#3}}{\rightarrow}}
\newcommand{\twolinescrule}[4]{\twolinescruleA{#1}{#2}{\rulename{#3}}{#4}{\rightarrow}}
\newcommand{\onelinerule}[3]{\onelineruleA{#1}{#2}{\rulename{#3}}{\rightarrow}}
\newcommand{\onelinescrule}[4]{\onelinescruleA{#1}{#2}{\rulename{#3}}{#4}{\rightarrow}}

\newcommand{\twolineruleA}[4]{
\multicolumn{3}{l}{{#1} {#4}} & {#3}\\ 
\multicolumn{3}{l}{{#2}} & \extraspterm}

\newcommand{\twolinescruleA}[5]{
\multicolumn{3}{l}{{#1} {#5}} & {#3}\\ 
\multicolumn{4}{l}{{#2 ~ ~ ~ {#4}}} \extraspterm}

\newcommand{\twolinescruleB}[5]{
\multicolumn{3}{l}{{#1} {#5}} & {#3}\\ 
\multicolumn{4}{l}{#2} \\
\multicolumn{4}{l}{~ ~ ~ #4} \extraspterm}

\newcommand{\threelinescruleA}[5]{
\multicolumn{3}{l}{{#1} {#5}} & {#4}\\ 
\multicolumn{4}{l}{#2} \\
\multicolumn{4}{l}{#3} \extraspterm}

\newcommand{\threelinescruleB}[6]{
\multicolumn{3}{l}{{#1} {#6}} & {#4}\\ 
\multicolumn{4}{l}{#2} \\
\multicolumn{4}{l}{#3} \\
\multicolumn{4}{l}{~ ~ ~ #5} \extraspterm}


\newcommand{\fourlinescruleB}[7]{
\multicolumn{3}{l}{{#1} {#7}} & {#5}\\ 
\multicolumn{4}{l}{#2} \\
\multicolumn{4}{l}{#3} \\
\multicolumn{4}{l}{#4} \\
\multicolumn{4}{l}{~ ~ ~ #6} \extraspterm}


\newcommand{\onelineruleA}[4]{
\multicolumn{1}{l}{#1} & {#4} ~ & {#2} & {#3} \extraspterm}

\newcommand{\onelinescruleA}[5]{
\multicolumn{1}{l}{#1} & {#5} ~ & {#2} & {#3} \\
& & {#4} \extraspterm}
