### Get Site Info in PHP Format Source: https://wiki.luatex.org/api.php?action=help&modules=phpfm Use this example to retrieve site information, specifically the namespaces, formatted as PHP. This requires read access to the API. ```api api.php?action=query&meta=siteinfo&siprop=namespaces&format=phpfm ``` -------------------------------- ### Parse Examples Source: https://wiki.luatex.org/api.php?action=help&modules=parse Illustrative examples of how to use the 'parse' action with different parameters. ```APIDOC ## API Examples ### Example 1: Parse a page ``` api.php?action=parse&page=Project:Sandbox ``` ### Example 2: Parse wikitext ``` api.php?action=parse&text={{Project:Sandbox}}&contentmodel=wikitext ``` ### Example 3: Parse wikitext, specifying the page title ``` api.php?action=parse&text={{PAGENAME}}&title=Test ``` ### Example 4: Parse a summary ``` api.php?action=parse&summary=Some+[[link]]&prop= ``` ``` -------------------------------- ### Markup Input and Output Examples Source: https://wiki.luatex.org/api.php?action=feedcontributions&feedformat=atom&user=Halfb1t Examples of input text and the corresponding expected TeX output. ```text This is in /italic/ and this is in *bold*. ``` ```text This is in \italic{italic} and this is in \bold{bold}. ``` ```text This will /not be/ in italic. ``` -------------------------------- ### Markup Transformation Examples Source: https://wiki.luatex.org/api.php?action=feedcontributions&feedformat=atom&user=Halfb1t Examples of input and output strings for lightweight markup processing. ```text This is in /italic/ and this is in *bold*. ``` ```text This is in \italic{italic} and this is in \bold{bold}. ``` -------------------------------- ### LaTeX Document with LuaTeX Hyphenation Example Source: https://wiki.luatex.org/index.php?oldid=60&title=Show_the_hyphenation_points A basic LaTeX document setup that includes the necessary packages and the Lua code to demonstrate showing hyphenation points. Ensure you have 'blindtext' and 'fontspec' packages installed. ```latex \documentclass[12pt,a4paper]{scrartcl} \usepackage[english]{babel} \usepackage{blindtext} \usepackage{fontspec} \directlua{ show_hyph = function(head) while head do if head.id == 0 or head.id == 1 then % hlist, vlist show_hyph(head.list) % should be head.head in a newer luatex than 0.64 elseif head.id == 7 then  % disc local n = node.new("whatsit","pdf_literal") n.mode = 0 n.data = "q 0.3 w 0 2 m 0 7 l S Q" n.next = head.next n.prev = head head.next = n head = n end head = head.next end return true end luatexbase.add_to_callback("post_linebreak_filter",show_hyph,"show_hyph") } \begin{document} \begin{minipage}{5cm} \blindtext \end{minipage} \end{document} ``` -------------------------------- ### Retrieve API Help Examples Source: https://wiki.luatex.org/index.php/Special%3AApiHelp/help These examples demonstrate how to query the API help module for specific module information, submodules, and recursive documentation. ```http api.php?action=help ``` ```http api.php?action=help&modules=query&submodules=1 ``` ```http api.php?action=help&recursivesubmodules=1 ``` ```http api.php?action=help&modules=help ``` ```http api.php?action=help&modules=query+info|query+categorymembers ``` -------------------------------- ### Main Module Initialization Source: https://wiki.luatex.org/api.php?action=feedcontributions&feedformat=atom&user=Rkrug Initializes the main module, loads utility and format modules, and sets up package. ```lua local main = {} package.loaded[...] = main local util = require("utils") local link_nodes = util.link_nodes local make_glyph = util.make_glyph local make_glue = util.make_glue local make_penalty = util.make_penalty local is_whitespace = util.is_whitespace local is_linefeed = util.is_linefeed local is_nobreak = util.is_nobreak local copy_table = util.copy_table local read_line = util.read_line local reader = require("reader") local read_value = reader.read_value local format = require("format") local update_state = format.update_state local update_locals = format.update_locals local push_tbl = format.push_tbl local pop_tbl = format.pop_tbl local top_tbl = format.top_tbl local pop_do_command_stop = format.pop_do_command_stop local commands = commands or require("commands") local get_command ``` -------------------------------- ### Example: Get Main Page Content Source: https://wiki.luatex.org/index.php?printable=yes&title=Special%3AApiSandbox An example of how to retrieve the content of the 'Main Page' using the MediaWiki API. ```APIDOC ## GET /api.php ### Description Fetches the content of a specified page using the 'query' action. ### Method GET ### Endpoint /api.php ### Query Parameters - **action** (string) - Required - 'query' - **format** (string) - Required - 'json' - **titles** (string) - Required - The title of the page to retrieve (e.g., 'Main Page'). - **prop** (string) - Required - 'content' to get the page content. ### Request Example `GET /api.php?action=query&format=json&titles=Main%20Page&prop=content` ### Response #### Success Response (200) - **query** (object) - Contains information about the query. - **pages** (object) - Contains details about the requested pages. - **pageid** (integer) - The unique identifier for the page. - **ns** (integer) - The namespace of the page. - **title** (string) - The title of the page. - **revisions** (array) - An array of page revisions. - **slots** (object) - **main** (object) - **contentformat** (string) - The format of the content. - **contentmodel** (string) - The model of the content. - ***content** (string) - The actual content of the page. #### Response Example ```json { "batchcomplete": "", "query": { "pages": { "1": { "pageid": 1, "ns": 0, "title": "Main Page", "revisions": [ { "slots": { "main": { "contentformat": "text/x-wiki", "contentmodel": "wikitext", "*": "{{Welcome}}" } } } ] } } } } ``` ``` -------------------------------- ### Basic TikZ and LuaTeX Setup Source: https://wiki.luatex.org/index.php?diff=10870&oldid=148&title=Writing_Lua_in_TeX A standard LaTeX document setup using the TikZ package for drawing and amsmath for mathematical formulas. This serves as a boilerplate for examples involving graphical elements and mathematical typesetting. ```tex \documentclass[tikz,border=3mm]{standalone} \usepackage{amsmath} % 用于数学公式 \usetikzlibrary{positioning, arrows.meta} \begin{document} \begin{tikzpicture}[ box/.style={draw, rectangle, minimum width=2cm, minimum height=1cm, thick}, ell/.style={draw, ellipse, minimum width=0.8cm, minimum height=0.8cm}, arrow/.style={-Stealth, thick} ] % 上半部分:直接效应模型 % 节点定义 ``` -------------------------------- ### Create and Shipout a Node List Source: https://wiki.luatex.org/api.php?action=feedcontributions&feedformat=atom&user=109.104.4.161 Demonstrates creating a whatsit node for a PDF action, packing nodes into an hbox, and shipping the page to the PDF output. ```lua start_link.action = node.new("whatsit","pdf_action") start_link.action.action_type = 1 start_link.action.action_id = dest local rule = mkrule(tenpt) local hbox = hpack(start_link, rule, end_link) add_to_page(hbox) -- This pagelist consists of an hbox whose contents is "start_link", -- the 10pt x 10pt rule and the "end_link" node. shipout() --------------------------- -- Just to show you that you can get some memory usage statistics: print(string.format("\nnode_mem_usage=%s",status.node_mem_usage)) ``` -------------------------------- ### Useful Modules and Examples Source: https://wiki.luatex.org/index.php?diff=10858&oldid=4&printable=yes&title=Main_Page Highlights useful LuaTeX modules and provides examples of code for traversing TeX nodes, tokens, and exploring font tables. ```WikiText == Useful modules == * [http://ctan.org/pkg/nodetree] nodetree] visualize node lists in a tree view * [https://gist.github.com/556247 viznodelist] LuaTeX nodelist visualization * [https://ctan.org/pkg/minim] minim] A modern plain format for the LuaTeX engine == From the old bluwiki.com == (Mostly by and thanks to [http://omega.enstb.org/yannis/ Yannis Haralambous]) * An example of code [[traversing TeX nodes]] before an horizontal list goes through the line breaking engine; * An example of code [[traversing tokens]] just before execution or expansion; * you want to [[explore the table obtained from a TrueType font]], loaded by font.read_ttf; * you want to [[explore the internal font table]] of a pre-loaded font or of a font you have loaded by \font and then used for at least one glyph; * how to [[use a TrueType font]] without going through a TFM or a OFM file; ``` -------------------------------- ### Get pages containing files Source: https://wiki.luatex.org/api.php?action=help&recursivesubmodules=1 Uses the generator to retrieve pages that contain the files starting from B. ```http api.php?action=query&generator=allfileusages&gaffrom=B ``` -------------------------------- ### Build luatex-plain format Source: https://wiki.luatex.org/api.php?action=feedcontributions&feedformat=atom&user=73.170.253.19 Command to initialize the luatex-plain format file. ```bash luatex --ini /usr/local/share/texmf-dist/tex/generic/context/luatex/luatex-plain.tex ``` -------------------------------- ### Example output for glyph 12 and 13 Source: https://wiki.luatex.org/index.php?direction=prev&oldid=38&title=Explore_the_table_obtained_from_a_TrueType_font Output showing the parenright glyph and the start of the next glyph entry. ```text ......12 -> { .........boundingbox -> { ............1 -> 41 ............2 -> -315 ............3 -> 530 ............4 -> 1600 .........} .........name -> parenright .........unicodeenc -> 41 .........possub -> { ............1 -> { ...............flags -> 0 ...............type -> substitution ...............subs -> { ..................variant -> parenleft ...............} ...............script_lang_index -> 1 ...............tag -> rtla ............} .........} .........width -> 649 ......} ......13 -> { .........boundingbox -> { ............1 -> 70 ............2 -> 709 ............3 -> 846 ``` -------------------------------- ### Example output for glyphs 12-13 Source: https://wiki.luatex.org/index.php?direction=next&oldid=38&title=Explore_the_table_obtained_from_a_TrueType_font Continued output showing glyph 12 with substitution and the start of glyph 13. ```text ......12 -> { .........boundingbox -> { ............1 -> 41 ............2 -> -315 ............3 -> 530 ............4 -> 1600 .........} .........name -> parenright .........unicodeenc -> 41 .........possub -> { ............1 -> { ...............flags -> 0 ...............type -> substitution ...............subs -> { ..................variant -> parenleft ...............} ...............script_lang_index -> 1 ...............tag -> rtla ............} .........} .........width -> 649 ......} ......13 -> { .........boundingbox -> { ............1 -> 70 ............2 -> 709 ``` -------------------------------- ### Show the hyphenation points example Source: https://wiki.luatex.org/api.php?action=feedcontributions&feedformat=atom&user=59.52.192.198 An example demonstrating the use of callbacks, specifically related to showing hyphenation points. ```wiki [[Show the hyphenation points]] ``` -------------------------------- ### Get pages containing redirects Source: https://wiki.luatex.org/api.php?action=help&recursivesubmodules=1 This generator retrieves pages that contain redirects, starting from the redirect title 'B'. ```api api.php?action=query&generator=allredirects&garfrom=B ``` -------------------------------- ### LuaTeX Node and Page Management Source: https://wiki.luatex.org/api.php?action=feedcontributions&feedformat=atom&user=Mars-Json A comprehensive example demonstrating node manipulation, box creation, and page shipout using Lua. ```Lua do -- this will hold the items that go onto the page local pagelist -- Call tex.shipout() with the contents of the pagelist function shipout() local vbox,b = node.vpack(pagelist) -- we ignore the badness 'b' tex.box[666] = vbox tex.shipout(666) pagelist = nil -- Not strictly necessary. TeX holds the current page number in counter 0. -- TeX displays the contents of this counter when it puts a page into -- the pdf (tex.shipout()). If we don't change the counter, TeX will -- display [1] [1], instead of [1] [2] for our two page document. tex.count[0] = tex.count[0] + 1 end function add_to_page( list ) -- We attach the nodelist 'list' to the end of the pagelist -- if pagelist doesn't exist, 'list' is our new pagelist -- if it exists, we go to the end with node.tail() and adjust -- the prev and next pointers, so list becomes part -- of pagelist. if not pagelist then pagelist = list else local tail = node.tail(pagelist) tail.next = list list.prev = tail end end end -- This creates a new square rule and returns the pointer to it. function mkrule( size ) local r = node.new("rule") r.width = size r.height = size / 2 r.depth = size / 2 return r end do local destcounter = 0 -- Create a pdf anchor (dest object). It returns a whatsit node and the -- number of the anchor, so it can be used in a pdf link or an outline. function mkdest() destcounter = destcounter + 1 local d = node.new("whatsit","pdf_dest") d.named_id = 0 d.dest_id = destcounter d.dest_type = 3 return d, destcounter end end -- Take a list of nodes and put them into an hbox. The prev and next fields -- of the nodes will be set automatically. Return a pointer to the hbox. function hpack( ... ) local start, tmp, cur start = select(1,...) tmp = start for i=2,select("#",...) do cur = select(i,...) tmp.next = cur cur.prev = tmp tmp = cur end local h,b = node.hpack(start) -- ignore badness return h end local tenpt = 10 * 2^16 --------------------------- -- page 1 --------------------------- local n,dest = mkdest() -- dest is needed for the link to this anchor add_to_page(n) add_to_page(mkrule(2 * tenpt)) -- The pagelist contains a pdf dest node (a link destination) and a rule of size 20pt x 20pt. shipout() --------------------------- -- page 2 --------------------------- -- This is the page with the link to the anchor (dest) on page one. A -- link consists of three nodes: a pdf_start_link, a pdf_end_link and and -- action node that specifies the action to perform when the user clicks on -- the link. -- The pdf link must be inside a horizontal box, that's why we hpack() it. -- The link_attr (link attributes) is optional, here it draws a yellowish border -- around the link. local start_link = node.new("whatsit"," ``` -------------------------------- ### Wiki Formatting Example Source: https://wiki.luatex.org/index.php?diff=10858&oldid=10817&title=Main_Page This example demonstrates basic wiki markup for creating headings, links, and lists. It's useful for understanding how content is structured on the wiki. ```wiki == Welcome to the LuaTeX wiki == This is a wiki for [http://www.luatex.org LuaTeX], a typesetting engine derived from [http://en.wikipedia.org/wiki/TeX TeX] that includes [http://www.lua.org Lua] as an embedded scripting language. See [[Special:Allpages|all the articles]] or the [[Special:Recentchanges|recent changes]]. * [http://www.mediawiki.org/wiki/Help:Formatting How to edit wiki pages] * [[Bug tracking|Bug tracking]]: Mantis [http://tracker.luatex.org bug tracker] == Some articles == * [[Documentation and help]] points to other online resources (manuals, mailing list, etc.) related to LuaTeX. * [[Writing Lua in TeX]] explains how to write Lua code in a TeX document (and back). * [[Attributes]] introduces LuaTeX's thrilling new concept. * Pages on callbacks: ** [[Callbacks]] introduces callbacks and how to use them. ** There is a page on the [[Post linebreak filter|post_linebreak_filter]] callback, explaining and illustrating it with a couple of examples. The [[Show the hyphenation points]] article is another example of use. ** The page on [[process input buffer|the process_input_buffer callback]] illustrates how to read documents with non-UTF-8 encoding, and how to write TeX with lightweight markup instead of the usual commands. ** Another callback is [[show error hook|show_error_hook]], which lets you enliven your error messages! ** You can fake XeTeX's interchar tokens with the [[token filter|token_filter]]. * [[TeX without TeX]] is about using TeX's functionality (typesetting, pdf writing) only using Lua code (no \TeX macros). * [[TeX_without_TeX_revised_and_expanded]] is a revision and expansion of the above. * [[fontsampler|Create a fontsampler]] using plain LuaTeX and luaotfload. * [[Annotate math expressions]] in PDF with a bounding box using LuaLaTeX. == Packages on LuaTeX == * [http://ctan.org/pkg/lua-visual-debug lua-visual-debug] Visual debugging with LuaLaTeX. * [https://github.com/koppor/luabibentry luabibentry] Repeat BibTeX entries in a LuaLaTeX document body. * [http://ctan.org/pkg/luacode luacode] Helper for executing lua code from within TeX. * [http://en.sourceforge.jp/projects/luatex-ja/ LuaTeX-ja] LuaTeX-ja is a macro package to typeset Japanese(also Chinese) texts using Lua(La)TeX. * [http://ctan.org/pkg/luaindex luaindex] Create index using lualatex. * [http://ctan.org/pkg/luainputenc luainputenc] Replacing inputenc for use in LuaTeX. * [http://ctan.org/pkg/lualatex-math lualatex-math] Fixes for mathematics-related LuaLaTeX issues. * [http://ctan.org/pkg/lualibs lualibs] Additional Lua functions for LuaTeX macro programmers. * [http://ctan.org/pkg/luamplib luamplib] Use LuaTeX's built-in MetaPost interpreter. * [http://ctan.org/pkg/luaotfload luaotfload] OpenType layout system for Plain TeX and LaTeX. * [http://ctan.org/pkg/luasseq luasseq] Drawing spectral sequences in LuaLaTeX. * [http://ctan.org/pkg/luatexbase luatexbase] Basic resource management for LuaTeX code. == Useful modules == * [http://ctan.org/pkg/nodetree nodetree] visualize node lists in a tree view * [https://gist.github.com/556247 viznodelist] LuaTeX nodelist visualization * [https://ctan.org/pkg/minim minim] A modern plain format for the LuaTeX engine == From the old bluwiki.com == (Mostly by and thanks to [http://omega.enstb.org/yannis/ Yannis Haralambous]) * An example of code [[traversing TeX nodes]] before an horizontal list goes through the line breaking engine; * An example of code [[traversing tokens]] just before execution or expansion; * you want to [[explore the table obtained from a TrueType font]], loaded by font.read_ttf; * you want to [[explore the internal font table]] of a pre-loaded font or of a font you have loaded by \font and then used for at least one glyph; ``` -------------------------------- ### Fetch Revisions of Pages with Prefix Source: https://wiki.luatex.org/index.php/Special%3AApiHelp/query This example shows how to fetch revisions for pages whose titles start with a specific prefix. ```APIDOC ## GET api.php?action=query&generator=allpages&gapprefix=API/&prop=revisions&continue= ### Description Fetches revisions of pages whose titles begin with the prefix 'API/'. ### Method GET ### Endpoint /api.php ### Query Parameters - **action** (string) - Required - Set to 'query'. - **generator** (string) - Required - Specifies a generator to use, e.g., 'allpages'. - **gapprefix** (string) - Required - The prefix to filter page titles. - **prop** (string) - Required - Specifies the properties to retrieve, e.g., 'revisions'. - **continue** (string) - Optional - Used for continuation of paginated results. ``` -------------------------------- ### Get All Submodules of a Query Module Source: https://wiki.luatex.org/api.php?action=help&modules=paraminfo This example demonstrates how to fetch information for all submodules of a specific module, such as 'query', by using the wildcard character '*'. ```api api.php?action=paraminfo&modules=query%2B* ``` -------------------------------- ### Create and Shipout a Simple Page with Nodes Source: https://wiki.luatex.org/index.php?action=edit&title=TeX_without_TeX&undo=140&undoafter=139 Demonstrates creating a simple page by assembling nodes (action, rule, links) into an hbox and shipping it out. Useful for basic page construction. ```lua local start_link = node.new("action") start_link.action = node.new("whatsit","pdf_action") start_link.action.action_type = 1 start_link.action.action_id = dest local rule = mkrule(tenpt) local hbox = hpack(start_link, rule, end_link) add_to_page(hbox) shipout() ``` -------------------------------- ### LuaTeX: Get Font Parameters Source: https://wiki.luatex.org/index.php?action=history&feed=atom&title=TeX_without_TeX Retrieves font parameters for the current font. This is a common setup step before manipulating font nodes. ```lua local font_parameters = font.getfont(current_font).parameters ``` -------------------------------- ### Create and Shipout PDF Links Source: https://wiki.luatex.org/api.php?action=feedcontributions&feedformat=atom&user=Mars-Json Demonstrates creating a link structure with whatsit nodes and shipping it to the PDF output. ```lua local start_link = node.new("whatsit","pdf_start_link") local end_link = node.new("whatsit","pdf_end_link") start_link.width = tenpt start_link.height = tenpt / 2 start_link.depth = tenpt / 2 start_link.link_attr = "/C [0.9 1 0] /Border [0 0 2]" --start_link.action = node.new("action") --there has been an update of the luatex start_link.action = node.new("whatsit","pdf_action") start_link.action.action_type = 1 start_link.action.action_id = dest local rule = mkrule(tenpt) local hbox = hpack(start_link, rule, end_link) add_to_page(hbox) -- This pagelist consists of an hbox whose contents is "start_link", -- the 10pt x 10pt rule and the "end_link" node. shipout() --------------------------- -- Just to show you that you can get some memory usage statistics: print(string.format("\nnode_mem_usage=%s",status.node_mem_usage)) ``` -------------------------------- ### Example: Fetch Site Info and Revisions Source: https://wiki.luatex.org/index.php/Special%3AApiHelp/query This example demonstrates how to fetch site information and revisions for a specific page. ```APIDOC ## GET /websites/wiki_luatex ### Description Fetches general site information and revisions for specified pages. ### Method GET ### Endpoint `/websites/wiki_luatex` ### Query Parameters - **action** (string) - Required - The action to perform (e.g., `query`). - **list** (string) - Optional - Specifies a list module to query (e.g., `recentchanges`). - **titles** (string) - Optional - A list of titles to work on. Separate values with `|` or alternative. Maximum number of values is 50 (500 for bots). - **prop** (string) - Optional - Specifies properties to retrieve for each page (e.g., `revisions`). - **rvlimit** (integer) - Optional - Limit the number of revisions to return. - **format** (string) - Optional - The output format (e.g., `json`). ### Request Example ```json { "action": "query", "titles": "Main Page", "prop": "revisions", "rvlimit": 1, "format": "json" } ``` ### Response #### Success Response (200) - **query** (object) - Contains the query results. - **pages** (object) - An object where keys are page IDs. - **[pageid]** (object) - Information about the page. - **title** (string) - The title of the page. - **revisions** (array) - An array of revision objects. - **slots** (object) - Contains the content of the revision. - **main** (object) - **content** (string) - The content of the revision. #### Response Example ```json { "batchcomplete": "", "query": { "pages": { "1": { "pageid": 1, "ns": 0, "title": "Main Page", "revisions": [ { "slots": { "main": { "content": "This is the main page content." } } } ] } } } } ``` ``` -------------------------------- ### Get all target pages, marking missing ones Source: https://wiki.luatex.org/api.php?action=help&recursivesubmodules=1 This generator fetches all target pages and marks the missing ones. It starts from the redirect title 'B'. ```api api.php?action=query&generator=allredirects&garunique=&garfrom=B ``` -------------------------------- ### Initialize luatex-plain format Source: https://wiki.luatex.org/index.php?diff=3556&oldid=3553&title=T_wo_T_r%3Atwotr Command to initialize the luatex-plain format file. ```bash luatex --ini /usr/local/share/texmf-dist/tex/generic/context/luatex/luatex-plain.tex ``` -------------------------------- ### Basic TikZ Diagram Setup Source: https://wiki.luatex.org/index.php?diff=10870&oldid=49&printable=yes&title=Writing_Lua_in_TeX Sets up styles for boxes, ellipses, and arrows for drawing diagrams. Includes document structure and TikZ environment. ```tex \usepackage{amsmath} % 用于数学公式 \usetikzlibrary{positioning, arrows.meta} \begin{document} \begin{tikzpicture}[ box/.style={draw, rectangle, minimum width=2cm, minimum height=1cm, thick}, ell/.style={draw, ellipse, minimum width=0.8cm, minimum height=0.8cm}, arrow/.style={-Stealth, thick} ] % 上半部分:直接效应模型 % 节点定义 \node[box] (X1) at (0,0) {$Flex_{it}$}; \node[box] (Y1) at (4,0) {$Y_{lnincomeit}$}; \node[ell] (e1) at (6,0) {$e1$}; % 路径连接 \draw[arrow] (X1) -- node[above] {$c$} (Y1); \draw[arrow] (Y1) -- (e1); % 方程标注 \node[align=center] (eq1) at (2,-1) {$Y_{lnincomeit} = c Flex_{it} + e1$}; % 下半部分:中介效应模型 % 节点定义 \node[box] (X2) at (0,-3) {$Flex_{it}$}; \node[box] (M) at (2,-5) {$M_{it}$}; \node[box] (Y2) at (4,-3) {$Y_{lnincomeit}$}; \node[ell] (e2) at (4,-5) {$e2$}; \node[ell] (e3) at (6,-3) {$e3$}; % 路径连接 \draw[arrow] (X2) -- node[above] {$c'$} (Y2); \draw[arrow] (X2) -- node[above,sloped] {$a$} (M); \draw[arrow] (M) -- node[above,sloped] {$b$} (Y2); \draw[arrow] (M) -- (e2); \draw[arrow] (Y2) -- (e3); % 方程标注 \node[align=center] (eq2) at (2,-6) {$M_{it} = a Flex_{it} + e2$}; \node[align=center] (eq3) at (2,-7) {$Y_{lnincomeit} = c' Flex_{it} + b M_{it} + e3$}; \end{tikzpicture} \end{document} ``` -------------------------------- ### Get User Contributions by IP Prefix Source: https://wiki.luatex.org/api.php?action=help&recursivesubmodules=1 Retrieve contributions from all IP addresses starting with a given prefix. This is useful for analyzing edits from a range of IP addresses. ```api api.php?action=query&list=usercontribs&ucuserprefix=192.0.2. ``` -------------------------------- ### LuaTeX Node Manipulation and Shipout Source: https://wiki.luatex.org/api.php?action=feedcontributions&feedformat=atom&user=109.104.4.161 A comprehensive example demonstrating node creation, page assembly, and PDF shipout using Lua. ```lua do -- this will hold the items that go onto the page local pagelist -- Call tex.shipout() with the contents of the pagelist function shipout() local vbox,b = node.vpack(pagelist) -- we ignore the badness 'b' tex.box[666] = vbox tex.shipout(666) pagelist = nil -- Not strictly necessary. TeX holds the current page number in counter 0. -- TeX displays the contents of this counter when it puts a page into -- the pdf (tex.shipout()). If we don't change the counter, TeX will -- display [1] [1], instead of [1] [2] for our two page document. tex.count[0] = tex.count[0] + 1 end function add_to_page( list ) -- We attach the nodelist 'list' to the end of the pagelist -- if pagelist doesn't exist, 'list' is our new pagelist -- if it exists, we go to the end with node.tail() and adjust -- the prev and next pointers, so list becomes part -- of pagelist. if not pagelist then pagelist = list else local tail = node.tail(pagelist) tail.next = list list.prev = tail end end end -- This creates a new square rule and returns the pointer to it. function mkrule( size ) local r = node.new("rule") r.width = size r.height = size / 2 r.depth = size / 2 return r end do local destcounter = 0 -- Create a pdf anchor (dest object). It returns a whatsit node and the -- number of the anchor, so it can be used in a pdf link or an outline. function mkdest() destcounter = destcounter + 1 local d = node.new("whatsit","pdf_dest") d.named_id = 0 d.dest_id = destcounter d.dest_type = 3 return d, destcounter end end -- Take a list of nodes and put them into an hbox. The prev and next fields -- of the nodes will be set automatically. Return a pointer to the hbox. function hpack( ... ) local start, tmp, cur start = select(1,...) tmp = start for i=2,select("#",...) do cur = select(i,...) tmp.next = cur cur.prev = tmp tmp = cur end local h,b = node.hpack(start) -- ignore badness return h end local tenpt = 10 * 2^16 --------------------------- -- page 1 --------------------------- local n,dest = mkdest() -- dest is needed for the link to this anchor add_to_page(n) add_to_page(mkrule(2 * tenpt)) -- The pagelist contains a pdf dest node (a link destination) and a rule of size 20pt x 20pt. shipout() --------------------------- -- page 2 --------------------------- -- This is the page with the link to the anchor (dest) on page one. A -- link consists of three nodes: a pdf_start_link, a pdf_end_link and and -- action node that specifies the action to perform when the user clicks on -- the link. -- The pdf link must be inside a horizontal box, that's why we hpack() it. -- The link_attr (link attributes) is optional, here it draws a yellowish border -- around the link. local start_link = node.new("whatsit","pdf_start_link") local end_link = node.new("whatsit","pdf_end_link") start_link.width = tenpt start_link.height = tenpt / 2 start_link.depth = tenpt / 2 start_link.link_attr = "/C [0.9 1 0] /Border [0 0 2]" --start_link.action = node.new("action") ``` -------------------------------- ### Using TrueType fonts without TFM/OFM Source: https://wiki.luatex.org/index.php?action=edit&title=Main_Page&undo=10858&undoafter=10141 Example demonstrating how to use a TrueType font directly without relying on TFM or OFM files. This simplifies font setup in some cases. ```tex \directlua{fonts.addfont('myfont.ttf')} \font\myfontfont=myfont at 12pt \myfontfont Hello, world! ``` -------------------------------- ### Create a PDF Link with LuaTeX Nodes Source: https://wiki.luatex.org/index.php?diff=10845&oldid=117&printable=yes&title=TeX_without_TeX Demonstrates creating a PDF link using whatsit nodes and adding it to a page via shipout. ```lua local start_link = node.new("whatsit","pdf_start_link") local end_link = node.new("whatsit","pdf_end_link") start_link.width = tenpt start_link.height = tenpt / 2 start_link.depth = tenpt / 2 start_link.link_attr = "/C [0.9 1 0] /Border [0 0 2]" --start_link.action = node.new("action") --there has been an update of the luatex start_link.action = node.new("whatsit","pdf_action") start_link.action.action_type = 1 start_link.action.action_id = dest local rule = mkrule(tenpt) local hbox = hpack(start_link, rule, end_link) add_to_page(hbox) -- This pagelist consists of an hbox whose contents is "start_link", -- the 10pt x 10pt rule and the "end_link" node. shipout() --------------------------- -- Just to show you that you can get some memory usage statistics: print(string.format("\nnode_mem_usage=%s",status.node_mem_usage)) ``` -------------------------------- ### Use TrueType Font Without TFM/OFM Source: https://wiki.luatex.org/index.php?action=edit&oldid=95&title=Main_Page This example demonstrates how to use a TrueType font directly in LuaTeX without relying on TFM or OFM files, simplifying font setup. ```tex \documentclass{article} \usepackage{luacode} \begin{document} \begin{luacode} local font_file = 'path/to/your/font.ttf' local font_id = font.load_ttf(font_file) if font_id then -- Use the loaded font local font_node = node.new('font') font_node.id = font_id node.write(font_node) tex.print('Successfully loaded and used TrueType font: ' .. font_file .. '\n') else tex.print('Failed to load TrueType font: ' .. font_file .. '\n') end \end{luacode} This section shows using a TrueType font directly. \end{document} ```