diff options
| author | Alasdair Armstrong | 2018-11-12 17:26:17 +0000 |
|---|---|---|
| committer | Alasdair Armstrong | 2018-11-12 17:26:17 +0000 |
| commit | f638a84add3ed60261bb86544e4332fd2180e1a6 (patch) | |
| tree | 79646c469a30562e85cdb6df28929d3ad138f0cb /src | |
| parent | 518776b45c4ad1f689bcd89ea6583c92583982a8 (diff) | |
Add referencing commands to generated latex
Diffstat (limited to 'src')
| -rw-r--r-- | src/latex.ml | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/latex.ml b/src/latex.ml index 3c0ce03a..9b1e6da2 100644 --- a/src/latex.ml +++ b/src/latex.ml @@ -127,6 +127,10 @@ let category_name = function "fcl" ^ String.sub str 1 (String.length str - 1) ^ unique_postfix n | FunclApp str -> "fcl" ^ str +let category_name_val = function + | Val -> "" + | cat -> category_name cat + (* Generate a unique latex identifier from a Sail identifier. We store a mapping from identifiers to strings in state so we always return the same latex id for a sail id. *) @@ -417,8 +421,17 @@ let defs (Defs defs) = ^ "}" |> string in + let ref_command cat ids = + sprintf "\\newcommand{\\%sref%s}[2]{\n " !opt_prefix (category_name cat) + ^ Util.string_of_list "%\n " (fun id -> sprintf "\\ifstrequal{#1}{%s}{\\hyperref[%s%s]{#2}}{}" (string_of_id id) (category_name_val cat) (refcode_id id)) + (IdSet.elements ids) + ^ "}" + |> string + in tex ^^ separate (twice hardline) [id_command Val !valspecs; - id_command Function !fundefs] + ref_command Val !valspecs; + id_command Function !fundefs; + ref_command Function !fundefs] ^^ hardline |
