# TikZ environment style options don't work inside \ExplSyntaxOn

I want to use a TikZ environment inside an \ExplSyntaxOn... \ExplSyntaxOff block.

\documentclass{article}

\usepackage[utf8]{inputenc}

\usepackage{xparse}

\usepackage{tikz}
\usetikzlibrary{positioning}

\ExplSyntaxOn

\NewDocumentCommand{\maketikz}{ O{,} m }{%
\begin{tikzpicture}[%
node distance=2pt
]
\node[draw] {#2};
\end{tikzpicture}
}

\ExplSyntaxOff

\begin{document}

\maketikz[;]{Yes}

\end{document}


During the build process I get errors for the TikZ styles: I do not know the key '/tikz/padding/.appendstyle', to which you passed 'innersep=2px... and I do not know the key '/tikz/nodedistance', to which you passed '2pt'....

Without \ExplSyntaxOn it builds without any errors.

\documentclass{article}

\usepackage[utf8]{inputenc}

\usepackage{xparse}

\usepackage{tikz}
\usetikzlibrary{positioning}

\newcommand{\maketikz}[2][,]{
\begin{tikzpicture}[%
node distance=2pt
]
\node[draw] {#2};
\end{tikzpicture}
}

\begin{document}

\maketikz[;]{Yes}

\end{document}


Where is my mistake?

• in expl3 context spaces are ignored, and you must use ~, e.g. padding/.append~style={inner~sep=2px} Aug 3 at 9:47
• Don't use px. Very likely it is not what you might think it to be. Aug 3 at 9:52
• @UlrikeFischer ooohhh, this should have been so obvious, thanks alot! Aug 3 at 13:24
• @egreg it was just a typo of CSS muscle memory, thanks Aug 3 at 13:24
• @UlrikeFischer Want to make that an answer? yesterday