Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
5  
You might find Which Lua environment should I use with LuaTeX (LuaLaTeX)? useful. –  Joseph Wright Sep 9 '12 at 12:50
add comment

1 Answer

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}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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