You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
note that I am not even using the macro, this yields:
System Message: WARNING/2 ([>=latex',dotted,thick] \draw[->] (0,0) -- (1,1) -- (1,0) -- (2,0);)
! LaTeX Error: Missing \begin{document}. See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ... l.9 e wcommand\Foo[1]{Z} ! Undefined control sequence. l.9 ewcommand\Foo [1]{Z} (/nix/store/2kqi4kak6rgpzr5s2kh1fsv3ynz9s3xd-texlive-2022-env-texmfdist/tex/lat ex/l3backend/l3backend-pdftex.def) No file tikz-9623d8fec8222981fc4dda796d12608e10225c41.aux. (/nix/store/2kqi4kak6rgpzr5s2kh1fsv3ynz9s3xd-texlive-2022-env-texmfdist/tex/con text/base/mkii/supp-pdf.mkii [Loading MPS to PDF converter (version 2006.09.02).] ) (/nix/store/2kqi4kak6rgpzr5s2kh1fsv3ynz9s3xd-texlive-2022-env-
because the \n in \newcommand is interpreted as a newline, not as latex code.
Expected behavior
tikz_latex_preamble is interpreted as latex code or automatically escapes backslashes.
Imho this is a question of correct usage of Python. In Python, a literal string "\newcommand" starts with a newline. A literal string r"\newcommand" starts with a backslash.
This leaves the choice of how to provide literal strings to tikz_latex_preamble up to the user.
Adding escaping magic to tikz_latex_preamble would be an interface change and would break code that uses escapes on purpose. See example 1 below.
behavior
consider this setting in
conf.py
where I'm just trying to define a macroThen using one of the examples:
note that I am not even using the macro, this yields:
because the
\n
in\newcommand
is interpreted as a newline, not as latex code.Expected behavior
tikz_latex_preamble
is interpreted as latex code or automatically escapes backslashes.Workaround
manually escape the newline like:
or use a raw string:
A more complicated example
Consider this preamble:
note the
\r
in\relax
and\t
in\tp
and the\f
in\foreach
and\fi
. Each of these will need to be escaped as wellThe text was updated successfully, but these errors were encountered: