1

Possible Duplicate:
Print large macro block from Lua to TeX

I need to escape a string in Lua code in LuaLaTeX. I'm trying to print a string but LaTeX seems to hiccup on some special characters. I know I can call \luatexluaescapestring from inside text but I need an equivalent function in Lua that will either remove the offending characters or escape them properly.

Uiy
  • 6,132
  • 4
    What are the special characters that give the problem? – egreg Mar 29 '12 at 17:55
  • 1
    I am really really very happy now and I have no intention for another comment flaming but I am really trying to understand why you are reluctant to post a simple code example. It has been the topic of your previous questions for no reason but why again I wonder. – percusse Mar 29 '12 at 17:56
  • I have the feeling that I've just answered this on your last question. I think this should be closed as a duplicate. – topskip Mar 29 '12 at 18:21
  • By "offending characters" you mean the literal ones? The Lua Reference Manual recommends to use literal strings ([[ one\ntwo ]]) in this case (the literal char \n is already escaped). I'm not sure Lua has a built-in function for this (they explicitly recommend literal strings for escaping literal chars), but maybe a solution is to write a local function which string.sub's all the 14 literal chars and return a "clean" string. :) – Paulo Cereda Mar 29 '12 at 18:21
  • 8
    Please no further down-voting, as it isn't productive. – Martin Scharrer Mar 29 '12 at 18:32
  • @PatrickGundlach This is not the same question. They have nothing to do with one another. One is to print a string literal that represents a tex macro and one is to print a variable with some type of character in it that is causing tex to crap out. It turns out it is the '_' characters and tex is wanting to go into math mode. I had no issues with the code before but something changed causing problems. – Uiy Mar 30 '12 at 00:03
  • @Uiy did you actually try my code in the other question? It doesn't seem so. Otherwise the underscore _ would not have had any problem. Next time, please provide a minimal example! – topskip Mar 30 '12 at 06:15

0 Answers0