2

How can one get a carriage return at the end of each line (Lualatex) ?

\documentclass{article}
\usepackage[nolinks,forget]{qrcode}%
\begin{document}

\newcommand{\Space}[0]{\ }% 
\newcommand{\CarriageReturn}[0]{\?}%
\qrset{height=2.5cm}

\qrcode[version=5]{
    \directlua{
        for i,p in ipairs( table.pack(1,2,3) )
        do
        tex.sprint (tostring(p),"\Space line \Space then \Space carriage \Space return" \CarriageReturn)
        end
    }
}% 

% Doesn't work:  tex.sprint([[\noexpand\newline]])
% Doesn't work:  \CarriageReturn
% Doesn't work:  empty line

\end{document}

enter image description here

2

You can use \noexpand\n to print a newline character (\n in a lua string) through \directlua within a document. Adjusting your example we get the following:

\documentclass{article}
\usepackage[nolinks,forget]{qrcode}%
\begin{document}

\newcommand{\Space}[0]{\ }%

\qrset{height=2.5cm}

\qrcode[version=5]{
    \directlua{
        for i,p in ipairs( table.pack(1,2,3) )
        do
        tex.sprint (tostring(p),"\Space line \Space then \Space carriage \Space return\noexpand\n")
        end
    }
}%

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.