LaTeX backend: fix module name escaping

This commit is contained in:
Louis Gesbert 2024-02-15 17:02:24 +01:00
parent 518bb64ecc
commit 18ec4b3dd3
2 changed files with 8 additions and 6 deletions

View File

@ -271,17 +271,19 @@ let rec law_structure_to_latex
file label
| A.LawInclude (A.CatalaFile _ | A.LegislativeText _) -> ()
| A.ModuleDef (id, extern) ->
Format.fprintf fmt "\n\\textbf{This defines the %s module \\textsc{%s}}"
Format.fprintf fmt
"\n\\textbf{This defines the \\texttt{%s} module \\texttt{%s}}"
(if extern then "external" else "catala")
(Mark.remove id)
(pre_latexify (Mark.remove id))
| A.ModuleUse (id, alias) -> (
Format.fprintf fmt
"\n\\textbf{The following makes use of the module \\textsc{%s}"
(Mark.remove id);
"\n\\textbf{The following makes use of the module \\texttt{%s}"
(pre_latexify (Mark.remove id));
match alias with
| None -> Format.fprintf fmt "}"
| Some al ->
Format.fprintf fmt " under the name \\textsc{%s}" (Mark.remove al))
Format.fprintf fmt " under the name \texttt{%s}"
(pre_latexify (Mark.remove al)))
| A.LawText t -> Format.fprintf fmt "%s" (pre_latexify t)
| A.CodeBlock (_, c, false) when not print_only_law ->
let start_line = Pos.get_start_line (Mark.get c) - 1 in

View File

@ -52,7 +52,7 @@ $ catala Interpret -s A
```catala-test-inline
$ catala latex
\textbf{This defines the catala module \textsc{Test_grave_char_en}}
\textbf{This defines the \texttt{catala} module \texttt{Test\_grave\_char\_en}}
\subsection{Law text should be able to contain grave accent ``'.}