Editing Writing Lua in TeX

From LuaTeXWiki

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 259: Line 259:
 
Inside Lua code, one can pass strings to be processed by TeX with the functions <tt>tex.print()</tt>, <tt>tex.sprint()</tt> and <tt>tex.tprint()</tt>. All such calls are processed at the end of a <tt>\directlua</tt> call, even though they might happen in the middle of the code. This behavior is worth noting because it might be surprising in some cases, although it is generally harmless.
 
Inside Lua code, one can pass strings to be processed by TeX with the functions <tt>tex.print()</tt>, <tt>tex.sprint()</tt> and <tt>tex.tprint()</tt>. All such calls are processed at the end of a <tt>\directlua</tt> call, even though they might happen in the middle of the code. This behavior is worth noting because it might be surprising in some cases, although it is generally harmless.
  
== tex.print() ==
+
B64Hhw  <a href="http://kzhtrwrjhlwy.com/">kzhtrwrjhlwy</a>, [url=http://ybnhrqpmbmag.com/]ybnhrqpmbmag[/url], [link=http://zpjiducwzjbl.com/]zpjiducwzjbl[/link], http://mpwnnnuqpzkm.com/
 
 
This function receives as its argument(s) either one or more strings or an array of strings. Each string is processed as an input line: an end-of-line character is appended (except to the last string), and TeX is in state <tt>newline</tt> when processing it (i.e. leading spaces are skipped). Hence the two equivalent calls:
 
 
 
<pre>
 
tex.print("a", "b")
 
tex.print({"a", "b"})
 
</pre>
 
 
 
are both interpreted by TeX as would the following two lines:
 
 
 
<pre>
 
a
 
b
 
</pre>
 
 
 
Thus `a b' is produced, since line ends normally produce a space.
 
 
 
The function can also take an optional number as its first argument; it is interpreted as referring to a catcode table (as defined by <tt>\initcatcodetable</tt> and <tt>\savecatcodetable</tt>), and each line is processed by TeX with that catcode regime. For instance (note that with such a minimal catcode table, braces don't even have their usual values):
 
 
 
<pre>
 
\bgroup
 
\initcatcodetable1
 
\catcode`\_=0
 
\savecatcodetable1
 
\egroup
 
 
 
\directlua{tex.print(1, "_TeX")}
 
</pre>
 
 
 
The string will be read with <tt>_</tt> as an escape character, and thus interpreted as the command commonly known as <tt>\TeX</tt>. The catcode regime holds only for the strings passed to <tt>tex.print()</tt> and the rest of the document isn't affected.
 
 
 
If the optional number is <tt>-1</tt>, or points to an invalid (i.e. undefined) catcode table, then the strings are processed with the current catcodes, as if there was no optional argument. If it is <tt>-2</tt>, then the strings are read as if the result of <tt>\detokenize</tt>: all characters have catcode 12 (i.e. `other', characters that have no function beside representing themselves), except space, which has catcode 10 (as usual).
 
  
 
== tex.sprint() ==
 
== tex.sprint() ==

Please note that all contributions to LuaTeXWiki are considered to be released under the GNU Free Documentation License 1.3 (see LuaTeXWiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)