I'm trying to define a simple command using xparse
and it's verbatim
argument:
\DeclareDocumentCommand\macro{v}{#1}
but see
! LaTeX error: "xparse/verbatim-newline"
!
! Verbatim argument of \macrocode ended by end of line.
!
! See the LaTeX3 documentation for further information.
!
! For immediate help type H <return>.
when the argument is multiple lines of code (i.e., contains a new line):
\macro{This
Is
A
Test}
but it has no problem for something like
\macro{This Is A Test}
In my case, I need it to work with new lines.
Update:
\documentclass{book}
\usepackage{luatex,xparse}
\directlua{tex.enableprimitives('',tex.extraprimitives())}
\begin{document}
\DeclareDocumentCommand{\macro}{+v}{\directlua{print("\luaescapestring{#1}")}}
\DeclareDocumentCommand{\macroa}{+v}{#1}
\macro{
This
Is
A
Test
}
\macroa{
This
Is
A
Test
}
\end{document}
macro prints "ThisIsATest" without newlines. I need to print Exactly what is passed to the macro. macroa gives fi Thisfi Isfi Afi Testfi.
BTW, here is a MWE of it working but I want to "wrap" the behavior inside a macro for convenience:
\documentclass{book}
\usepackage{luatex}
\directlua{tex.enableprimitives('',tex.extraprimitives())}
\begin{document}
\endlinechar`\^^J%
\catcode`\^^M=13%
\directlua{print("\luaescapestring\expandafter{\detokenize{%
This
Is
A
Test
}}")}%
\catcode`\^^M=5
\end{document}
EXCEPT Some random characters are output to the pdf (In my working example this doesn't happen because, I guess, I'm using a different font encoding).
xparse
, as far as I can see. to me, it looks like it would make a better question separately. – Joseph Wright♦ Sep 8 '12 at 22:01