0

I want to generate a list of digit sequences, where a part of a sequence is a counter and another one is generated depending on this counter. My MnotWE

\documentclass{book}

\usepackage{luacode}

\usepackage{tikz}

\usepackage{qrcode}

\newcommand{\Digits}[2]{
    \luaexec{
        a = #1+#2
        b = #1*#2
        tex.sprint(\luastring{#1#2 a b})
    }
}

\newcommand{\PrintQR}

\begin{document}


    \foreach\AA in{1,...,10}{
        \foreach\BB in{1,...,2}{
            \renewcommand{\PrintQR}{\Digits{\AA}{\BB}}
            \PrintQR
            %\qrcode{\PrintQR}
        }
    }

\end{document}

There are two problems:

  1. Instead of the values of a and b the I get the letters themselves.
  2. If I uncomment the line \qrcode I get an error.

1 Answer 1

2

I didn't get which output you want, but don't use \luaexec in this case. It is not expandable. I also doubt that you need \luastring, but if you use it don't put variables in its argument.

\documentclass{book}

\usepackage{luacode}

\usepackage{tikz}

\usepackage{qrcode}

\newcommand{\Digits}[2]{%
    \directlua{
        a = #1 + #2;
        b = #1 * #2;
        tex.sprint("#1#2="..a..b)
    }%
}


\newcommand{\PrintQR}

\begin{document}


    \foreach\AA in{1,...,10}{
        \foreach\BB in{1,...,2}{
            \renewcommand{\PrintQR}{\Digits{\AA}{\BB}}
            \PrintQR
            \qrcode{\Digits{\AA}{\BB}}
        }
    }

\end{document}
1
  • Yes, works as needed. I just didn't need the =. Oct 20, 2017 at 12:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .