I am setting a macro in lualatex, and would like to use ~ as a non-breaking space character. However, it produces a new line between first and last.
\documentclass{scrartcl}
\usepackage{luacode}
\begin{document}
Note tilde is fine in luacode*.\\
\begin{luacode*}
token.set_macro('NAME','First~Last','global')
\end{luacode*}
\NAME
\end{document}
token.set_macro. Just use something along the lines oftex.sprint("\\gdef\\NAME{First~Last}"). – Henri Menke Oct 12 '21 at 16:48