From 74f36c77e91c76c0c6619f6b9ad2a1589e840708 Mon Sep 17 00:00:00 2001 From: Stefan Lippuner <3071885+stefanlippuner@users.noreply.github.com> Date: Thu, 25 Jan 2024 14:51:51 +0100 Subject: [PATCH] Latex - Fix escaping of special chars (tilde, circumflex, dollar) --- proto/cheby/print_latex.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/proto/cheby/print_latex.py b/proto/cheby/print_latex.py index a80a9af3..e0099dda 100644 --- a/proto/cheby/print_latex.py +++ b/proto/cheby/print_latex.py @@ -23,10 +23,13 @@ def escape_printable(text): if idx % 2 == 0: # Escape special characters - SPECIAL_CHARS = ['\\', '&', '%', '#', '_', '{', '}', '~', '^'] # '$' + SPECIAL_CHARS = ['\\', '&', '%', '#', '_', '{', '}', '$'] for char in SPECIAL_CHARS: text_part = text_part.replace(char, '\\' + char) + text_part.replace('~', '\\textasciitilde') + text_part.replace('^', '\\textasciicircum') + # Allow line breaks after '_' and '.' in long strings ALLOW_BREAK_CHARS = ['.', '_'] for char in ALLOW_BREAK_CHARS: