lib/texinputs/isabelle.sty
author wenzelm
Fri Nov 25 14:10:33 2016 +0100 (2016-11-25)
changeset 64525 9c3da2276e19
parent 63590 4854f7ee0987
child 67139 8fe0aba577af
permissions -rw-r--r--
avoid extra space intruding rail diagrams (amending 4854f7ee0987);
     1 %%
     2 %% macros for Isabelle generated LaTeX output
     3 %%
     4 
     5 %%% Simple document preparation (based on theory token language and symbols)
     6 
     7 % isabelle environments
     8 
     9 \newcommand{\isabellecontext}{UNKNOWN}
    10 \newcommand{\setisabellecontext}[1]{\def\isabellecontext{#1}}
    11 
    12 \newcommand{\isastyle}{\UNDEF}
    13 \newcommand{\isastylett}{\UNDEF}
    14 \newcommand{\isastyleminor}{\UNDEF}
    15 \newcommand{\isastyleminortt}{\UNDEF}
    16 \newcommand{\isastylescript}{\UNDEF}
    17 \newcommand{\isastyletext}{\normalsize\rm}
    18 \newcommand{\isastyletxt}{\rm}
    19 \newcommand{\isastylecmt}{\rm}
    20 
    21 \newcommand{\isaspacing}{%
    22   \sfcode 42 1000 % .
    23   \sfcode 63 1000 % ?
    24   \sfcode 33 1000 % !
    25   \sfcode 58 1000 % :
    26   \sfcode 59 1000 % ;
    27   \sfcode 44 1000 % ,
    28 }
    29 
    30 %symbol markup -- \emph achieves decent spacing via italic corrections
    31 \newcommand{\isamath}[1]{\emph{$#1$}}
    32 \newcommand{\isatext}[1]{\emph{#1}}
    33 \DeclareRobustCommand{\isascriptstyle}{\def\isamath##1{##1}\def\isatext##1{\mbox{\isaspacing\isastylescript##1}}}
    34 \newcommand{\isactrlsub}[1]{\emph{\isascriptstyle${}\sb{#1}$}}
    35 \newcommand{\isactrlsup}[1]{\emph{\isascriptstyle${}\sp{#1}$}}
    36 \DeclareRobustCommand{\isactrlbsub}{\emph\bgroup\math{}\sb\bgroup\mbox\bgroup\isaspacing\isastylescript}
    37 \DeclareRobustCommand{\isactrlesub}{\egroup\egroup\endmath\egroup}
    38 \DeclareRobustCommand{\isactrlbsup}{\emph\bgroup\math{}\sp\bgroup\mbox\bgroup\isaspacing\isastylescript}
    39 \DeclareRobustCommand{\isactrlesup}{\egroup\egroup\endmath\egroup}
    40 \newcommand{\isactrlbold}[1]{{\bfseries\upshape\boldmath#1}}
    41 
    42 \newcommand{\isaantiqcontrol}[1]{\isatt{{\char`\\}{\char`\<}{\char`\^}#1{\char`\>}}}
    43 \newenvironment{isaantiq}{{\isacharat\isacharbraceleft}}{{\isacharbraceright}}
    44 
    45 \newdimen\isa@parindent\newdimen\isa@parskip
    46 
    47 \newenvironment{isabellebody}{%
    48 \isamarkuptrue\par%
    49 \isa@parindent\parindent\parindent0pt%
    50 \isa@parskip\parskip\parskip0pt%
    51 \isaspacing\isastyle}{\par}
    52 
    53 \newenvironment{isabellebodytt}{%
    54 \isamarkuptrue\par%
    55 \isa@parindent\parindent\parindent0pt%
    56 \isa@parskip\parskip\parskip0pt%
    57 \isaspacing\isastylett}{\par}
    58 
    59 \newenvironment{isabelle}
    60 {\begin{trivlist}\begin{isabellebody}\item\relax}
    61 {\end{isabellebody}\end{trivlist}}
    62 
    63 \newenvironment{isabellett}
    64 {\begin{trivlist}\begin{isabellebodytt}\item\relax}
    65 {\end{isabellebodytt}\end{trivlist}}
    66 
    67 \newcommand{\isa}[1]{\emph{\isaspacing\isastyleminor #1}}
    68 \newcommand{\isatt}[1]{\emph{\isaspacing\isastyleminortt #1}}
    69 
    70 \newcommand{\isaindent}[1]{\hphantom{#1}}
    71 \newcommand{\isanewline}{\mbox{}\par\mbox{}}
    72 \newcommand{\isasep}{}
    73 \newcommand{\isadigit}[1]{#1}
    74 
    75 \newcommand{\isachardefaults}{%
    76 \def\isacharbell{\isamath{\bigbox}}%requires stmaryrd
    77 \chardef\isacharbang=`\!%
    78 \chardef\isachardoublequote=`\"%
    79 \chardef\isachardoublequoteopen=`\"%
    80 \chardef\isachardoublequoteclose=`\"%
    81 \chardef\isacharhash=`\#%
    82 \chardef\isachardollar=`\$%
    83 \chardef\isacharpercent=`\%%
    84 \chardef\isacharampersand=`\&%
    85 \chardef\isacharprime=`\'%
    86 \chardef\isacharparenleft=`\(%
    87 \chardef\isacharparenright=`\)%
    88 \chardef\isacharasterisk=`\*%
    89 \chardef\isacharplus=`\+%
    90 \chardef\isacharcomma=`\,%
    91 \chardef\isacharminus=`\-%
    92 \chardef\isachardot=`\.%
    93 \chardef\isacharslash=`\/%
    94 \chardef\isacharcolon=`\:%
    95 \chardef\isacharsemicolon=`\;%
    96 \chardef\isacharless=`\<%
    97 \chardef\isacharequal=`\=%
    98 \chardef\isachargreater=`\>%
    99 \chardef\isacharquery=`\?%
   100 \chardef\isacharat=`\@%
   101 \chardef\isacharbrackleft=`\[%
   102 \chardef\isacharbackslash=`\\%
   103 \chardef\isacharbrackright=`\]%
   104 \chardef\isacharcircum=`\^%
   105 \chardef\isacharunderscore=`\_%
   106 \def\isacharunderscorekeyword{\_}%
   107 \chardef\isacharbackquote=`\`%
   108 \chardef\isacharbackquoteopen=`\`%
   109 \chardef\isacharbackquoteclose=`\`%
   110 \chardef\isacharbraceleft=`\{%
   111 \chardef\isacharbar=`\|%
   112 \chardef\isacharbraceright=`\}%
   113 \chardef\isachartilde=`\~%
   114 \def\isacharverbatimopen{\isacharbraceleft\isacharasterisk}%
   115 \def\isacharverbatimclose{\isacharasterisk\isacharbraceright}%
   116 \def\isacartoucheopen{\isatext{\raise.3ex\hbox{$\scriptscriptstyle\langle$}}}%
   117 \def\isacartoucheclose{\isatext{\raise.3ex\hbox{$\scriptscriptstyle\rangle$}}}%
   118 }
   119 
   120 
   121 % keyword and section markup
   122 
   123 \newcommand{\isakeyword}[1]
   124 {\emph{\bf\def\isachardot{.}\def\isacharunderscore{\isacharunderscorekeyword}%
   125 \def\isacharbraceleft{\{}\def\isacharbraceright{\}}#1}}
   126 \newcommand{\isacommand}[1]{\isakeyword{#1}}
   127 
   128 \newcommand{\isamarkupheader}[1]{\section{#1}}
   129 \newcommand{\isamarkupchapter}[1]{\chapter{#1}}
   130 \newcommand{\isamarkupsection}[1]{\section{#1}}
   131 \newcommand{\isamarkupsubsection}[1]{\subsection{#1}}
   132 \newcommand{\isamarkupsubsubsection}[1]{\subsubsection{#1}}
   133 \newcommand{\isamarkupparagraph}[1]{\paragraph{#1}}
   134 \newcommand{\isamarkupsubparagraph}[1]{\subparagraph{#1}}
   135 
   136 \newif\ifisamarkup
   137 \newcommand{\isabeginpar}{\par\ifisamarkup\relax\else\medskip\fi}
   138 \newcommand{\isaendpar}{\par\medskip}
   139 \newenvironment{isapar}{\parindent\isa@parindent\parskip\isa@parskip\isabeginpar}{\isaendpar}
   140 \newenvironment{isamarkuptext}{\par\isastyletext\begin{isapar}}{\end{isapar}}
   141 \newenvironment{isamarkuptxt}{\par\isastyletxt\begin{isapar}}{\end{isapar}}
   142 \newcommand{\isamarkupcmt}[1]{{\isastylecmt--- #1}}
   143 
   144 
   145 % styles
   146 
   147 \def\isabellestyle#1{\csname isabellestyle#1\endcsname}
   148 
   149 \newcommand{\isabellestyledefault}{%
   150 \def\isastyle{\small\tt\slshape}%
   151 \def\isastylett{\small\tt}%
   152 \def\isastyleminor{\small\tt\slshape}%
   153 \def\isastyleminortt{\small\tt}%
   154 \def\isastylescript{\footnotesize\tt\slshape}%
   155 \isachardefaults%
   156 }
   157 \isabellestyledefault
   158 
   159 \newcommand{\isabellestylett}{%
   160 \def\isastyle{\small\tt}%
   161 \def\isastylett{\small\tt}%
   162 \def\isastyleminor{\small\tt}%
   163 \def\isastyleminortt{\small\tt}%
   164 \def\isastylescript{\footnotesize\tt}%
   165 \isachardefaults%
   166 }
   167 
   168 \newcommand{\isabellestyleit}{%
   169 \def\isastyle{\small\it}%
   170 \def\isastylett{\small\tt}%
   171 \def\isastyleminor{\it}%
   172 \def\isastyleminortt{\tt}%
   173 \def\isastylescript{\footnotesize\it}%
   174 \isachardefaults%
   175 \def\isacharunderscorekeyword{\mbox{-}}%
   176 \def\isacharbang{\isamath{!}}%
   177 \def\isachardoublequote{}%
   178 \def\isachardoublequoteopen{}%
   179 \def\isachardoublequoteclose{}%
   180 \def\isacharhash{\isamath{\#}}%
   181 \def\isachardollar{\isamath{\$}}%
   182 \def\isacharpercent{\isamath{\%}}%
   183 \def\isacharampersand{\isamath{\&}}%
   184 \def\isacharprime{\isamath{\mskip2mu{'}\mskip-2mu}}%
   185 \def\isacharparenleft{\isamath{(}}%
   186 \def\isacharparenright{\isamath{)}}%
   187 \def\isacharasterisk{\isamath{*}}%
   188 \def\isacharplus{\isamath{+}}%
   189 \def\isacharcomma{\isamath{\mathord,}}%
   190 \def\isacharminus{\isamath{-}}%
   191 \def\isachardot{\isamath{\mathord.}}%
   192 \def\isacharslash{\isamath{/}}%
   193 \def\isacharcolon{\isamath{\mathord:}}%
   194 \def\isacharsemicolon{\isamath{\mathord;}}%
   195 \def\isacharless{\isamath{<}}%
   196 \def\isacharequal{\isamath{=}}%
   197 \def\isachargreater{\isamath{>}}%
   198 \def\isacharat{\isamath{@}}%
   199 \def\isacharbrackleft{\isamath{[}}%
   200 \def\isacharbackslash{\isamath{\backslash}}%
   201 \def\isacharbrackright{\isamath{]}}%
   202 \def\isacharunderscore{\mbox{-}}%
   203 \def\isacharbraceleft{\isamath{\{}}%
   204 \def\isacharbar{\isamath{\mid}}%
   205 \def\isacharbraceright{\isamath{\}}}%
   206 \def\isachartilde{\isamath{{}\sp{\sim}}}%
   207 \def\isacharbackquoteopen{\isatext{\raise.3ex\hbox{$\scriptscriptstyle\langle$}}}%
   208 \def\isacharbackquoteclose{\isatext{\raise.3ex\hbox{$\scriptscriptstyle\rangle$}}}%
   209 \def\isacharverbatimopen{\isamath{\langle\!\langle}}%
   210 \def\isacharverbatimclose{\isamath{\rangle\!\rangle}}%
   211 }
   212 
   213 \newcommand{\isabellestyleliteral}{%
   214 \isabellestyleit%
   215 \def\isacharunderscore{\_}%
   216 \def\isacharunderscorekeyword{\_}%
   217 \chardef\isacharbackquoteopen=`\`%
   218 \chardef\isacharbackquoteclose=`\`%
   219 }
   220 
   221 \newcommand{\isabellestyleliteralunderscore}{%
   222 \isabellestyleliteral%
   223 \def\isacharunderscore{\textunderscore}%
   224 \def\isacharunderscorekeyword{\textunderscore}%
   225 }
   226 
   227 \newcommand{\isabellestylesl}{%
   228 \isabellestyleit%
   229 \def\isastyle{\small\sl}%
   230 \def\isastylett{\small\tt}%
   231 \def\isastyleminor{\sl}%
   232 \def\isastyleminortt{\tt}%
   233 \def\isastylescript{\footnotesize\sl}%
   234 }
   235 
   236 
   237 % tagged regions
   238 
   239 %plain TeX version of comment package -- much faster!
   240 \let\isafmtname\fmtname\def\fmtname{plain}
   241 \usepackage{comment}
   242 \let\fmtname\isafmtname
   243 
   244 \newcommand{\isafold}[1]{\emph{$\langle\mathord{\mathit{#1}}\rangle$}}
   245 
   246 \newcommand{\isakeeptag}[1]%
   247 {\includecomment{isadelim#1}\includecomment{isatag#1}\csarg\def{isafold#1}{}}
   248 \newcommand{\isadroptag}[1]%
   249 {\excludecomment{isadelim#1}\excludecomment{isatag#1}\csarg\def{isafold#1}{}}
   250 \newcommand{\isafoldtag}[1]%
   251 {\includecomment{isadelim#1}\excludecomment{isatag#1}\csarg\def{isafold#1}{\isafold{#1}}}
   252 
   253 \isakeeptag{theory}
   254 \isakeeptag{proof}
   255 \isakeeptag{ML}
   256 \isakeeptag{visible}
   257 \isadroptag{invisible}
   258 
   259 \IfFileExists{isabelletags.sty}{\usepackage{isabelletags}}{}