Hallo, I have a few silly questions about tex.print() To produce $\sqrt{2}=1.4142135623731$ it should be enough to write tex.print("$\\sqrt{2}=" .. math.sqrt(2) .. "$") or better tex.print([[$\sqrt{2}=]] .. math.sqrt(2) .. "$") but that's both not working. The following instead does the job: tex.print("$\string\\sqrt{2}=" .. math.sqrt(2) .. "$") why? Another question: What is the differenz between 'tex.sprint()' and 'tex.write()'? Wolfgang
Wolfgang Werners-Lucchini wrote:
Hallo,
I have a few silly questions about
tex.print()
To produce
$\sqrt{2}=1.4142135623731$
it should be enough to write
tex.print("$\\sqrt{2}=" .. math.sqrt(2) .. "$")
this is because \\ can mean anything, for instance it may expand to \par or \crlf or .. there is a \luaescapestring primitive which catches things like quotes tex.print("\detokenize{$\sqrt{2}=}" .. math.sqrt(2) .. "$") may also work ok
or better
tex.print([[$\sqrt{2}=]] .. math.sqrt(2) .. "$")
but that's both not working. The following instead does the job:
tex.print("$\string\\sqrt{2}=" .. math.sqrt(2) .. "$")
why?
Another question:
What is the differenz between 'tex.sprint()' and 'tex.write()'?
tokenization under a catcode regime versus writing strings ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
participants (2)
-
Hans Hagen
-
Wolfgang Werners-Lucchini