6

I would like to automate the creation of some beamer slides using LuaLaTeX. These are my first steps with LuaLaTeX so please excuse my ignorance.

\documentclass{beamer}

\begin{document}

\directlua{
  for i=0, 5 do
    tex.print("\unexpanded{\\begin{frame}}")
    tex.print("Math: $x_{" .. i .. "}$")
    tex.print("\unexpanded{\\end{frame}}")
  end
}

\end{document}

The example compiles and gives the expected result; 6 frames with x_0,1,2,3,5 on it.

I'm a bit unhappy about the additional \unexpands and \s before \begin and \end.

Is there a dedicated LuaTeX command that just inserts latex code 1:1 to the document?

Joseph Wright
  • 259,911
  • 34
  • 706
  • 1,036
Somebody
  • 61
  • 1

1 Answers1

2

a short \frame{..} is possible

\documentclass{beamer}

\begin{document}

\directlua{
  for i=0, 5 do
    tex.print("\string\\frame{")
    tex.print("Math: $x_{" .. i .. "}$")
    tex.print("}")
  end
}

\end{document}