This is my file a.tex
:
\begin{tikzpicture}
\node[] (v) {hi};
\end{tikzpicture}
\endinput
This is main.tex
:
\documentclass{article}
\usepackage{tikz}
\NewDocumentEnvironment{foo}{b}{
% here I process the incoming #1
% here I must revert the effect of \obeylines and \obeyspaces
\input{a.tex}
}{}
\AddToHook{env/foo/begin}{\obeylines\obeyspaces}
\begin{document}
\begin{foo}
first
second
\end{foo}
\end{document}
When I compile main.tex
, it fails with this:
! Package tikz Error: A node must have a (possibly empty) label text.
See the tikz package documentation for explanation.
Type H <return> for immediate help.
...
l.3 \node[]
(v0) {hi};
I suspect that I must revert the effect of \obeylines
and \obeyspaces
somehow inside foo
environment. How?
listings
).listing side text
option from tcolorbox could be useful?