src/Pure/Thy/latex.ML
author wenzelm
Thu, 12 Apr 2007 15:01:13 +0200
changeset 22648 8c6b4f7548e3
parent 19265 cae36e16f3c0
child 23621 e070a6ab1891
permissions -rw-r--r--
output_basic: added isaantiq markup (only inside verbatim tokens);
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7726
2c7fc0ba1e12 Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff changeset
     1
(*  Title:      Pure/Thy/latex.ML
2c7fc0ba1e12 Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff changeset
     2
    ID:         $Id$
2c7fc0ba1e12 Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff changeset
     3
    Author:     Markus Wenzel, TU Muenchen
2c7fc0ba1e12 Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff changeset
     4
15801
d2f5ca3c048d superceded by Pure.thy and CPure.thy;
wenzelm
parents: 14992
diff changeset
     5
LaTeX presentation elements -- based on outer lexical syntax.
7726
2c7fc0ba1e12 Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff changeset
     6
*)
2c7fc0ba1e12 Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff changeset
     7
2c7fc0ba1e12 Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff changeset
     8
signature LATEX =
2c7fc0ba1e12 Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff changeset
     9
sig
14924
2be4cbe27a27 added output_known_symbols; tuned;
wenzelm
parents: 14879
diff changeset
    10
  val output_known_symbols: (string -> bool) * (string -> bool) ->
2be4cbe27a27 added output_known_symbols; tuned;
wenzelm
parents: 14879
diff changeset
    11
    Symbol.symbol list -> string
11719
49c14348a42b Exported output_symbols.
berghofe
parents: 11012
diff changeset
    12
  val output_symbols: Symbol.symbol list -> string
17081
e19963723262 eliminated datatype token;
wenzelm
parents: 15801
diff changeset
    13
  val output_basic: OuterLex.token -> string
e19963723262 eliminated datatype token;
wenzelm
parents: 15801
diff changeset
    14
  val output_markup: string -> string -> string
e19963723262 eliminated datatype token;
wenzelm
parents: 15801
diff changeset
    15
  val output_markup_env: string -> string -> string
e19963723262 eliminated datatype token;
wenzelm
parents: 15801
diff changeset
    16
  val output_verbatim: string -> string
e19963723262 eliminated datatype token;
wenzelm
parents: 15801
diff changeset
    17
  val markup_true: string
e19963723262 eliminated datatype token;
wenzelm
parents: 15801
diff changeset
    18
  val markup_false: string
e19963723262 eliminated datatype token;
wenzelm
parents: 15801
diff changeset
    19
  val begin_delim: string -> string
e19963723262 eliminated datatype token;
wenzelm
parents: 15801
diff changeset
    20
  val end_delim: string -> string
e19963723262 eliminated datatype token;
wenzelm
parents: 15801
diff changeset
    21
  val begin_tag: string -> string
e19963723262 eliminated datatype token;
wenzelm
parents: 15801
diff changeset
    22
  val end_tag: string -> string
9707
067c25edd1bd added tex_trailer;
wenzelm
parents: 9668
diff changeset
    23
  val tex_trailer: string
9916
4a703366494b define \isabellecontext;
wenzelm
parents: 9749
diff changeset
    24
  val isabelle_file: string -> string -> string
14924
2be4cbe27a27 added output_known_symbols; tuned;
wenzelm
parents: 14879
diff changeset
    25
  val symbol_source: (string -> bool) * (string -> bool) ->
2be4cbe27a27 added output_known_symbols; tuned;
wenzelm
parents: 14879
diff changeset
    26
    string -> Symbol.symbol list -> string
7726
2c7fc0ba1e12 Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff changeset
    27
  val theory_entry: string -> string
9135
3aa95ab3f02d adapted to improved presentation;
wenzelm
parents: 9038
diff changeset
    28
  val modes: string list
7726
2c7fc0ba1e12 Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff changeset
    29
end;
2c7fc0ba1e12 Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff changeset
    30
2c7fc0ba1e12 Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff changeset
    31
structure Latex: LATEX =
2c7fc0ba1e12 Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff changeset
    32
struct
2c7fc0ba1e12 Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff changeset
    33
2c7fc0ba1e12 Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff changeset
    34
2c7fc0ba1e12 Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff changeset
    35
(* symbol output *)
2c7fc0ba1e12 Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff changeset
    36
7900
e62973fccc97 output \isasymbols;
wenzelm
parents: 7852
diff changeset
    37
local
e62973fccc97 output \isasymbols;
wenzelm
parents: 7852
diff changeset
    38
7726
2c7fc0ba1e12 Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff changeset
    39
val output_chr = fn
9505
09c75c801dde improved output of space symbol;
wenzelm
parents: 9144
diff changeset
    40
  " " => "\\ " |
7726
2c7fc0ba1e12 Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff changeset
    41
  "\n" => "\\isanewline\n" |
9668
b5e709fd1e42 more \isachars;
wenzelm
parents: 9663
diff changeset
    42
  "!" => "{\\isacharbang}" |
b5e709fd1e42 more \isachars;
wenzelm
parents: 9663
diff changeset
    43
  "\"" => "{\\isachardoublequote}" |
9663
e4d58f1be05b output \isachar;
wenzelm
parents: 9558
diff changeset
    44
  "#" => "{\\isacharhash}" |
e4d58f1be05b output \isachar;
wenzelm
parents: 9558
diff changeset
    45
  "$" => "{\\isachardollar}" |
e4d58f1be05b output \isachar;
wenzelm
parents: 9558
diff changeset
    46
  "%" => "{\\isacharpercent}" |
e4d58f1be05b output \isachar;
wenzelm
parents: 9558
diff changeset
    47
  "&" => "{\\isacharampersand}" |
e4d58f1be05b output \isachar;
wenzelm
parents: 9558
diff changeset
    48
  "'" => "{\\isacharprime}" |
e4d58f1be05b output \isachar;
wenzelm
parents: 9558
diff changeset
    49
  "(" => "{\\isacharparenleft}" |
e4d58f1be05b output \isachar;
wenzelm
parents: 9558
diff changeset
    50
  ")" => "{\\isacharparenright}" |
e4d58f1be05b output \isachar;
wenzelm
parents: 9558
diff changeset
    51
  "*" => "{\\isacharasterisk}" |
9668
b5e709fd1e42 more \isachars;
wenzelm
parents: 9663
diff changeset
    52
  "+" => "{\\isacharplus}" |
b5e709fd1e42 more \isachars;
wenzelm
parents: 9663
diff changeset
    53
  "," => "{\\isacharcomma}" |
9663
e4d58f1be05b output \isachar;
wenzelm
parents: 9558
diff changeset
    54
  "-" => "{\\isacharminus}" |
9668
b5e709fd1e42 more \isachars;
wenzelm
parents: 9663
diff changeset
    55
  "." => "{\\isachardot}" |
b5e709fd1e42 more \isachars;
wenzelm
parents: 9663
diff changeset
    56
  "/" => "{\\isacharslash}" |
b5e709fd1e42 more \isachars;
wenzelm
parents: 9663
diff changeset
    57
  ":" => "{\\isacharcolon}" |
b5e709fd1e42 more \isachars;
wenzelm
parents: 9663
diff changeset
    58
  ";" => "{\\isacharsemicolon}" |
9663
e4d58f1be05b output \isachar;
wenzelm
parents: 9558
diff changeset
    59
  "<" => "{\\isacharless}" |
9668
b5e709fd1e42 more \isachars;
wenzelm
parents: 9663
diff changeset
    60
  "=" => "{\\isacharequal}" |
9663
e4d58f1be05b output \isachar;
wenzelm
parents: 9558
diff changeset
    61
  ">" => "{\\isachargreater}" |
9668
b5e709fd1e42 more \isachars;
wenzelm
parents: 9663
diff changeset
    62
  "?" => "{\\isacharquery}" |
b5e709fd1e42 more \isachars;
wenzelm
parents: 9663
diff changeset
    63
  "@" => "{\\isacharat}" |
9663
e4d58f1be05b output \isachar;
wenzelm
parents: 9558
diff changeset
    64
  "[" => "{\\isacharbrackleft}" |
e4d58f1be05b output \isachar;
wenzelm
parents: 9558
diff changeset
    65
  "\\" => "{\\isacharbackslash}" |
e4d58f1be05b output \isachar;
wenzelm
parents: 9558
diff changeset
    66
  "]" => "{\\isacharbrackright}" |
e4d58f1be05b output \isachar;
wenzelm
parents: 9558
diff changeset
    67
  "^" => "{\\isacharcircum}" |
e4d58f1be05b output \isachar;
wenzelm
parents: 9558
diff changeset
    68
  "_" => "{\\isacharunderscore}" |
9668
b5e709fd1e42 more \isachars;
wenzelm
parents: 9663
diff changeset
    69
  "`" => "{\\isacharbackquote}" |
9663
e4d58f1be05b output \isachar;
wenzelm
parents: 9558
diff changeset
    70
  "{" => "{\\isacharbraceleft}" |
e4d58f1be05b output \isachar;
wenzelm
parents: 9558
diff changeset
    71
  "|" => "{\\isacharbar}" |
e4d58f1be05b output \isachar;
wenzelm
parents: 9558
diff changeset
    72
  "}" => "{\\isacharbraceright}" |
e4d58f1be05b output \isachar;
wenzelm
parents: 9558
diff changeset
    73
  "~" => "{\\isachartilde}" |
14992
a16bc5abad45 tuned output;
wenzelm
parents: 14981
diff changeset
    74
  c => if Symbol.is_ascii_digit c then enclose "{\\isadigit{" "}}" c else c;
7726
2c7fc0ba1e12 Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff changeset
    75
14924
2be4cbe27a27 added output_known_symbols; tuned;
wenzelm
parents: 14879
diff changeset
    76
val output_chrs = translate_string output_chr;
2be4cbe27a27 added output_known_symbols; tuned;
wenzelm
parents: 14879
diff changeset
    77
2be4cbe27a27 added output_known_symbols; tuned;
wenzelm
parents: 14879
diff changeset
    78
fun output_known_sym (known_sym, known_ctrl) sym =
14874
23c73484312f Symbol.decode;
wenzelm
parents: 14840
diff changeset
    79
  (case Symbol.decode sym of
23c73484312f Symbol.decode;
wenzelm
parents: 14840
diff changeset
    80
    Symbol.Char s => output_chr s
14924
2be4cbe27a27 added output_known_symbols; tuned;
wenzelm
parents: 14879
diff changeset
    81
  | Symbol.Sym s => if known_sym s then enclose "{\\isasym" "}" s else output_chrs sym
2be4cbe27a27 added output_known_symbols; tuned;
wenzelm
parents: 14879
diff changeset
    82
  | Symbol.Ctrl s => if known_ctrl s then enclose "\\isactrl" " " s else output_chrs sym
14874
23c73484312f Symbol.decode;
wenzelm
parents: 14840
diff changeset
    83
  | Symbol.Raw s => s);
7900
e62973fccc97 output \isasymbols;
wenzelm
parents: 7852
diff changeset
    84
e62973fccc97 output \isasymbols;
wenzelm
parents: 7852
diff changeset
    85
in
e62973fccc97 output \isasymbols;
wenzelm
parents: 7852
diff changeset
    86
14924
2be4cbe27a27 added output_known_symbols; tuned;
wenzelm
parents: 14879
diff changeset
    87
val output_known_symbols = implode oo (map o output_known_sym);
2be4cbe27a27 added output_known_symbols; tuned;
wenzelm
parents: 14879
diff changeset
    88
val output_symbols = output_known_symbols (K true, K true);
8192
45a7027136e3 added old_symbol_source;
wenzelm
parents: 8117
diff changeset
    89
val output_syms = output_symbols o Symbol.explode;
7900
e62973fccc97 output \isasymbols;
wenzelm
parents: 7852
diff changeset
    90
22648
8c6b4f7548e3 output_basic: added isaantiq markup (only inside verbatim tokens);
wenzelm
parents: 19265
diff changeset
    91
val output_syms_antiqs =
8c6b4f7548e3 output_basic: added isaantiq markup (only inside verbatim tokens);
wenzelm
parents: 19265
diff changeset
    92
  Antiquote.scan_antiquotes #> map
8c6b4f7548e3 output_basic: added isaantiq markup (only inside verbatim tokens);
wenzelm
parents: 19265
diff changeset
    93
  (fn Antiquote.Text s => output_syms s
8c6b4f7548e3 output_basic: added isaantiq markup (only inside verbatim tokens);
wenzelm
parents: 19265
diff changeset
    94
    | Antiquote.Antiq (s, _) => enclose "%\n\\isaantiq\n" "%\n\\endisaantiq\n" (output_syms s)) #>
8c6b4f7548e3 output_basic: added isaantiq markup (only inside verbatim tokens);
wenzelm
parents: 19265
diff changeset
    95
  implode;
8c6b4f7548e3 output_basic: added isaantiq markup (only inside verbatim tokens);
wenzelm
parents: 19265
diff changeset
    96
7900
e62973fccc97 output \isasymbols;
wenzelm
parents: 7852
diff changeset
    97
end;
7726
2c7fc0ba1e12 Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff changeset
    98
2c7fc0ba1e12 Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff changeset
    99
2c7fc0ba1e12 Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff changeset
   100
(* token output *)
2c7fc0ba1e12 Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff changeset
   101
2c7fc0ba1e12 Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff changeset
   102
structure T = OuterLex;
2c7fc0ba1e12 Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff changeset
   103
7756
f9f8660de23f improved presentation;
wenzelm
parents: 7752
diff changeset
   104
val invisible_token = T.keyword_with (equal ";") orf T.is_kind T.Comment;
f9f8660de23f improved presentation;
wenzelm
parents: 7752
diff changeset
   105
17081
e19963723262 eliminated datatype token;
wenzelm
parents: 15801
diff changeset
   106
fun output_basic tok =
e19963723262 eliminated datatype token;
wenzelm
parents: 15801
diff changeset
   107
  let val s = T.val_of tok in
e19963723262 eliminated datatype token;
wenzelm
parents: 15801
diff changeset
   108
    if invisible_token tok then ""
e19963723262 eliminated datatype token;
wenzelm
parents: 15801
diff changeset
   109
    else if T.is_kind T.Command tok then
e19963723262 eliminated datatype token;
wenzelm
parents: 15801
diff changeset
   110
      "\\isacommand{" ^ output_syms s ^ "}"
e19963723262 eliminated datatype token;
wenzelm
parents: 15801
diff changeset
   111
    else if T.is_kind T.Keyword tok andalso Syntax.is_ascii_identifier s then
e19963723262 eliminated datatype token;
wenzelm
parents: 15801
diff changeset
   112
      "\\isakeyword{" ^ output_syms s ^ "}"
17169
1f12d55060bf output_basic: handle AltString token;
wenzelm
parents: 17081
diff changeset
   113
    else if T.is_kind T.String tok then
1f12d55060bf output_basic: handle AltString token;
wenzelm
parents: 17081
diff changeset
   114
      enclose "{\\isachardoublequoteopen}" "{\\isachardoublequoteclose}" (output_syms s)
1f12d55060bf output_basic: handle AltString token;
wenzelm
parents: 17081
diff changeset
   115
    else if T.is_kind T.AltString tok then
1f12d55060bf output_basic: handle AltString token;
wenzelm
parents: 17081
diff changeset
   116
      enclose "{\\isacharbackquoteopen}" "{\\isacharbackquoteclose}" (output_syms s)
17186
797433ca1ab3 delimiter markup for verbatim tokens;
wenzelm
parents: 17169
diff changeset
   117
    else if T.is_kind T.Verbatim tok then
22648
8c6b4f7548e3 output_basic: added isaantiq markup (only inside verbatim tokens);
wenzelm
parents: 19265
diff changeset
   118
      enclose "{\\isacharverbatimopen}" "{\\isacharverbatimclose}"
8c6b4f7548e3 output_basic: added isaantiq markup (only inside verbatim tokens);
wenzelm
parents: 19265
diff changeset
   119
        (output_syms_antiqs (s, T.position_of tok))
17081
e19963723262 eliminated datatype token;
wenzelm
parents: 15801
diff changeset
   120
    else output_syms s
e19963723262 eliminated datatype token;
wenzelm
parents: 15801
diff changeset
   121
  end;
e19963723262 eliminated datatype token;
wenzelm
parents: 15801
diff changeset
   122
e19963723262 eliminated datatype token;
wenzelm
parents: 15801
diff changeset
   123
fun output_markup cmd txt = "%\n\\isamarkup" ^ cmd ^ "{" ^ Symbol.strip_blanks txt ^ "%\n}\n";
7745
131005d3a62d strip_blanks;
wenzelm
parents: 7726
diff changeset
   124
17081
e19963723262 eliminated datatype token;
wenzelm
parents: 15801
diff changeset
   125
fun output_markup_env cmd txt =
e19963723262 eliminated datatype token;
wenzelm
parents: 15801
diff changeset
   126
  "%\n\\begin{isamarkup" ^ cmd ^ "}%\n" ^
e19963723262 eliminated datatype token;
wenzelm
parents: 15801
diff changeset
   127
  Symbol.strip_blanks txt ^
e19963723262 eliminated datatype token;
wenzelm
parents: 15801
diff changeset
   128
  "%\n\\end{isamarkup" ^ cmd ^ "}%\n";
7756
f9f8660de23f improved presentation;
wenzelm
parents: 7752
diff changeset
   129
17081
e19963723262 eliminated datatype token;
wenzelm
parents: 15801
diff changeset
   130
fun output_verbatim txt = "%\n" ^ Symbol.strip_blanks txt ^ "\n";
7726
2c7fc0ba1e12 Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff changeset
   131
17081
e19963723262 eliminated datatype token;
wenzelm
parents: 15801
diff changeset
   132
val markup_true = "\\isamarkuptrue%\n";
e19963723262 eliminated datatype token;
wenzelm
parents: 15801
diff changeset
   133
val markup_false = "\\isamarkupfalse%\n";
7726
2c7fc0ba1e12 Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff changeset
   134
17081
e19963723262 eliminated datatype token;
wenzelm
parents: 15801
diff changeset
   135
val begin_delim = enclose "%\n\\isadelim" "\n";
e19963723262 eliminated datatype token;
wenzelm
parents: 15801
diff changeset
   136
val end_delim = enclose "%\n\\endisadelim" "\n";
e19963723262 eliminated datatype token;
wenzelm
parents: 15801
diff changeset
   137
val begin_tag = enclose "%\n\\isatag" "\n";
e19963723262 eliminated datatype token;
wenzelm
parents: 15801
diff changeset
   138
fun end_tag tg = enclose "%\n\\endisatag" "\n" tg ^ enclose "{\\isafold" "}%\n" tg;
11860
36ba0d4a836c flag_markup;
wenzelm
parents: 11719
diff changeset
   139
36ba0d4a836c flag_markup;
wenzelm
parents: 11719
diff changeset
   140
7726
2c7fc0ba1e12 Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff changeset
   141
(* theory presentation *)
2c7fc0ba1e12 Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff changeset
   142
9707
067c25edd1bd added tex_trailer;
wenzelm
parents: 9668
diff changeset
   143
val tex_trailer =
067c25edd1bd added tex_trailer;
wenzelm
parents: 9668
diff changeset
   144
  "%%% Local Variables:\n\
9135
3aa95ab3f02d adapted to improved presentation;
wenzelm
parents: 9038
diff changeset
   145
  \%%% mode: latex\n\
3aa95ab3f02d adapted to improved presentation;
wenzelm
parents: 9038
diff changeset
   146
  \%%% TeX-master: \"root\"\n\
9144
wenzelm
parents: 9135
diff changeset
   147
  \%%% End:\n";
8192
45a7027136e3 added old_symbol_source;
wenzelm
parents: 8117
diff changeset
   148
9916
4a703366494b define \isabellecontext;
wenzelm
parents: 9749
diff changeset
   149
fun isabelle_file name txt =
4a703366494b define \isabellecontext;
wenzelm
parents: 9749
diff changeset
   150
  "%\n\\begin{isabellebody}%\n\
10247
33e542b4934c \isabellecontext: output_syms;
wenzelm
parents: 10184
diff changeset
   151
  \\\def\\isabellecontext{" ^ output_syms name ^ "}%\n" ^ txt ^
9916
4a703366494b define \isabellecontext;
wenzelm
parents: 9749
diff changeset
   152
  "\\end{isabellebody}%\n" ^ tex_trailer;
9707
067c25edd1bd added tex_trailer;
wenzelm
parents: 9668
diff changeset
   153
14924
2be4cbe27a27 added output_known_symbols; tuned;
wenzelm
parents: 14879
diff changeset
   154
fun symbol_source known name syms = isabelle_file name
2be4cbe27a27 added output_known_symbols; tuned;
wenzelm
parents: 14879
diff changeset
   155
  ("\\isamarkupheader{" ^ output_known_symbols known (Symbol.explode name) ^ "}%\n" ^
2be4cbe27a27 added output_known_symbols; tuned;
wenzelm
parents: 14879
diff changeset
   156
    output_known_symbols known syms);
7726
2c7fc0ba1e12 Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff changeset
   157
9038
63d20536971f session.tex: nsert blank lines in order to guarantee new paragraphs
wenzelm
parents: 8965
diff changeset
   158
fun theory_entry name = "\\input{" ^ name ^ ".tex}\n\n";
7726
2c7fc0ba1e12 Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff changeset
   159
2c7fc0ba1e12 Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff changeset
   160
8460
274426d1adbc tuned comments;
wenzelm
parents: 8192
diff changeset
   161
(* print mode *)
274426d1adbc tuned comments;
wenzelm
parents: 8192
diff changeset
   162
8965
d46b36785c70 proper token_translation for latex mode;
wenzelm
parents: 8896
diff changeset
   163
val latexN = "latex";
17218
64242b791c19 removed obsolete 'symbols' mode;
wenzelm
parents: 17186
diff changeset
   164
val modes = [latexN, Symbol.xsymbolsN];
8965
d46b36785c70 proper token_translation for latex mode;
wenzelm
parents: 8896
diff changeset
   165
8460
274426d1adbc tuned comments;
wenzelm
parents: 8192
diff changeset
   166
fun latex_output str =
274426d1adbc tuned comments;
wenzelm
parents: 8192
diff changeset
   167
  let val syms = Symbol.explode str
274426d1adbc tuned comments;
wenzelm
parents: 8192
diff changeset
   168
  in (output_symbols syms, real (Symbol.length syms)) end;
274426d1adbc tuned comments;
wenzelm
parents: 8192
diff changeset
   169
19265
cae36e16f3c0 Output.add_mode: keyword component;
wenzelm
parents: 17218
diff changeset
   170
fun latex_keyword cmd =
cae36e16f3c0 Output.add_mode: keyword component;
wenzelm
parents: 17218
diff changeset
   171
  apfst (enclose (if cmd then "\\isacommand{" else "\\isakeyword{") "}") o latex_output;
cae36e16f3c0 Output.add_mode: keyword component;
wenzelm
parents: 17218
diff changeset
   172
10955
36741b4fe109 setuo indent: \isaindent;
wenzelm
parents: 10393
diff changeset
   173
fun latex_indent "" = ""
36741b4fe109 setuo indent: \isaindent;
wenzelm
parents: 10393
diff changeset
   174
  | latex_indent s = enclose "\\isaindent{" "}" s;
36741b4fe109 setuo indent: \isaindent;
wenzelm
parents: 10393
diff changeset
   175
19265
cae36e16f3c0 Output.add_mode: keyword component;
wenzelm
parents: 17218
diff changeset
   176
val _ = Output.add_mode latexN (latex_output, latex_keyword, latex_indent o #1, Symbol.encode_raw);
8460
274426d1adbc tuned comments;
wenzelm
parents: 8192
diff changeset
   177
7726
2c7fc0ba1e12 Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff changeset
   178
end;