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
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to