How can I test for a TeX boolean in Lua?

This kind of code doesn't work:



   -- some lua code

      -- some more lua code
      -- another lua code

   -- again some lua code

Is there a way to achieve this?


Tex expansion happens before control is passed to lua. The following minimal example works.



% \luaflagtrue

  print("before flag")
    print("lua flag true")
    print("lua flag false")

  • I don't see a thing. This only outputs "test" in the PDF, using lualatex from TeXLive 2011. – ℝaphink Sep 14 '11 at 17:47
  • Ah sorry, saw it in the output. – ℝaphink Sep 14 '11 at 17:49
  • OK found the issue: @ is redefined to other inside the luacode environment for some reason, so booleans using @ in their names won't work. – ℝaphink Sep 14 '11 at 17:52
  • 1
    @Raphink: You can still access them with \csname … \endcsname. – Andrey Vihrov Sep 15 '11 at 6:37
  • 1
    @Andrey: Good to know. I've switched to names without @ though, and it helped ;-) – ℝaphink Sep 15 '11 at 7:14

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.