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