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