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