Thanks, Taco! than this question is to Hans. ;-) another example with a table: \documentclass{article} \usepackage{lua} \begin{document} \section{Example} \begin{table} \tabcolsep=0pc \caption{My table} \begin{tabular*}{\columnwidth}{@{\extracolsep{\fill}}llllll@{}} \hline Coll1 & \multicolumn{5}{l@{}}{Coll2} \\ \hline & B0 & A0 & G0 & K0 & WD \\ \hline V & 20 & 19.8 & 19.7 & 19.7 & 19.7 \\ \hline \end{tabular*} \end{table} $2+2-E(R) = n$ \end{document} if I use pre_output_filter, I don't see table :( output 1 node.count=6 attr=nil <-- section seen here output 2 node.count=2 attr=nil output 3 node.count=12 attr=nil <-- section and formula seen here output 4 node.count=3 attr=nil output 5 node.count=4 attr=nil question: how to see all the nodes using callback in a shipout mode? or how to find out which hlist/vlist will be outputted? thanks in advance :) Taco Hoekwater wrote:
Hi,
linuxss wrote:
Hi, lua experts!! I'm running a simple vpack_filter callback on a simple example: \documentclass{article} \usepackage{lua} %<--there is my callback \begin{document} $2+2-E(R) = n$ \end{document}
i see, that the formula is traversed in 1,3,4 vbox: vbox 1 node.count=6 attr=nil <--here vbox 2 node.count=2 attr=nil vbox 3 node.count=6 attr=nil <--here vbox 4 node.count=2 attr=nil <--here split_keep 5 node.count=2 attr=nil split_off 6 node.count=1 attr=nil vbox 7 node.count=4 attr=nil
Question is: how to know which one is shipout mode or is there something like checking \ifvmode, useing vpack_filter???
Probably Hans knows these extra packtypes better than I do by now, but the shipout packaging has a dedicated callback: pre_output_filter.
Best wishes, Taco
On 19-8-2010 9:36, linuxss wrote:
question: how to see all the nodes using callback in a shipout mode? or how to find out which hlist/vlist will be outputted?
shipout is somewhat special and we don't have a callback for the shipout itself in a regular macro package, the page is packaged in a box (often 255 ) and you can hook in some lua code there: - locate the \shipout command being used - see what box is shipped out - do a directlua just before \shipout and look the box so, something: \directlua{analyze(tex.box[255)} (there will be a callback for this but it's not an isolated event as for instance xforms are also shipped out and the xform subsystem is not opened up / redone yet) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Hans Hagen wrote:
On 19-8-2010 9:36, linuxss wrote:
question: how to see all the nodes using callback in a shipout mode? or how to find out which hlist/vlist will be outputted?
shipout is somewhat special and we don't have a callback for the shipout itself
in a regular macro package, the page is packaged in a box (often 255 ) and you can hook in some lua code there:
- locate the \shipout command being used - see what box is shipped out - do a directlua just before \shipout and look the box
so, something:
\directlua{analyze(tex.box[255)}
(there will be a callback for this but it's not an isolated event as for instance xforms are also shipped out and the xform subsystem is not opened up / redone yet)
Hans
----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
thanks, Hans! thats a very interesting idea to find \shipout and analyze box 255. I'll try it.
Hi, Hans, I've got almost the same output, as I used 'pre_output_filter' callback and a function on a \output command. 1) \newtoks\oldoutput \oldoutput=\expandafter{\the\output} \output{ \directlua{node_check(tex.box[255], 'shipout')} \the\oldoutput } 2) callback.add('pre_output_filter', node_check, 'info') and I can't see here table and page number nodes. pre_output_filter sounds like the all output should be prepared :) if I use 'vpack_filter' i see all the nodes of the page. so that means, that 'vpack_filter' is closer to shipout then pre_output_filter? I thought is has to be in reverse :) question: when the pages and table are inserted into \box 255? Thanks, Linas
On 20-8-2010 2:16, linuxss wrote:
Hi, Hans, I've got almost the same output, as I used 'pre_output_filter' callback and a function on a \output command.
1) \newtoks\oldoutput \oldoutput=\expandafter{\the\output} \output{ \directlua{node_check(tex.box[255], 'shipout')} \the\oldoutput }
2) callback.add('pre_output_filter', node_check, 'info')
and I can't see here table and page number nodes. pre_output_filter sounds like the all output should be prepared :) if I use 'vpack_filter' i see all the nodes of the page.
so that means, that 'vpack_filter' is closer to shipout then pre_output_filter? I thought is has to be in reverse :)
question: when the pages and table are inserted into \box 255?
I have no clue what your node_check does. Anyhow, there is no concept of a page number node and table node, a pagenumber is just a bunch of glyphs and a table becomes a collection of boxes (hlist/vlist) nodes. If you recurse over the node list then you will undoubtely see them, just as regular full tex tracing can show them. When pages are inserted depends on your macro package ... normally the pagebuilder does that (regular tex code, nothing built into the engine) and the same is true for a table, once the alignment is done it becomes boxes in the mvl or wrapped into some other box and again it ends up in the mvl. So, no magic there. Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Fri, 20 Aug 2010 15:57:45 +0200 письмо от Hans Hagen
On 20-8-2010 2:16, linuxss wrote:
Hi, Hans, I've got almost the same output, as I used 'pre_output_filter' callback and a function on a \output command.
1) \newtoks\oldoutput \oldoutput=\expandafter{\the\output} \output{ \directlua{node_check(tex.box[255], 'shipout')} \the\oldoutput }
2) callback.add('pre_output_filter', node_check, 'info')
and I can't see here table and page number nodes. pre_output_filter sounds like the all output should be prepared :) if I use 'vpack_filter' i see all the nodes of the page.
so that means, that 'vpack_filter' is closer to shipout then pre_output_filter? I thought is has to be in reverse :)
question: when the pages and table are inserted into \box 255?
I have no clue what your node_check does.
Anyhow, there is no concept of a page number node and table node, a pagenumber is just a bunch of glyphs and a table becomes a collection of boxes (hlist/vlist) nodes.
If you recurse over the node list then you will undoubtely see them, just as regular full tex tracing can show them.
When pages are inserted depends on your macro package ... normally the pagebuilder does that (regular tex code, nothing built into the engine) and the same is true for a table, once the alignment is done it becomes boxes in the mvl or wrapped into some other box and again it ends up in the mvl. So, no magic there.
Hans
----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
node_check() does a simple node traversing and runs throe the hlists/vlist recursively. the function shows all the nodes (table, figure, page number, etc.) when i use a vpack_filter. but with pre_output_filter i couldn't see all the nodes (using the same function). I'll try to figure out everything after holidays. thanks a lot! (sorry for my English) Linas
On 22-8-2010 7:01, Lincikas wrote:
node_check() does a simple node traversing and runs throe the hlists/vlist recursively. the function shows all the nodes (table, figure, page number, etc.) when i use a vpack_filter. but with pre_output_filter i couldn't see all the nodes (using the same function).
after vpacking your figures probably end up as hlists in the mvl as then the page builder has done its work ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
hallo, Hans! I'm interested in "page_insert (id 41)" node. It's just mentioned in node list, but not documented (in luatexref-t.pdf (beta 0.62.0)). Is there a chance to break a page (or create a page breaking node) while traversing the nodes. Maybe "page_insert" does that? tex example: $2+2$ <---*insert page brake here * $3+3$ Node traverse example: ..... node id=hlist numb(1), node id=math, subtype=0 node id=hlist numb(2), node id=glyph, 2 node id=glyph, + node id=glyph, 2 --------->end hlist numb(2) node id=math, subtype=1 --------->end hlist numb(1) <-------*insert page brake here* .... other nodes .... thanks, Linas LuaTeX, Version beta-0.61
On 2-9-2010 3:12, linuxss wrote:
hallo, Hans! I'm interested in "page_insert (id 41)" node. It's just mentioned in node list, but not documented (in luatexref-t.pdf (beta 0.62.0)).
Is there a chance to break a page (or create a page breaking node) while traversing the nodes. Maybe "page_insert" does that?
no, nodes like that are mentioned in the manual (side effect of the fact that the list is auto generated) but not really public ... they are used in tex itself when breaking paragraphs and pages .. so they are not documented because they are not meant to be used actually there are a couple of more nodes that you can create and push in the list but even then tex has some assumptions about what node to expect where so it might give unwanted side effects the page builder is not opened up yet (the parbuilder is partially opened up) so much of that might change before luatex 1.0 concerning breaking a page: you can insert a penalty node with a high value (i.e. do at the lua end what normally happens at the tex end) (btw, 'insert' normally refers to insert nodes) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
hi, Hans! I would like to use epdf library on a current pdf file after its made. but pdf is still not closed if I use "finish_pdffile" callback. epdf returns more useful information, then pdf library. function doc_end() doc = epdf.open(tex.filename .. ".pdf") pageref = doc:getCatalog() texio.write_nl("pdfcatalog=".. tostring(pageref)) end callback.register("finish_pdffile", doc_end) maybe there could be a callback after document output? Linas
On 2-9-2010 4:03, linuxss wrote:
hi, Hans! I would like to use epdf library on a current pdf file after its made. but pdf is still not closed if I use "finish_pdffile" callback. epdf returns more useful information, then pdf library.
function doc_end() doc = epdf.open(tex.filename .. ".pdf") pageref = doc:getCatalog() texio.write_nl("pdfcatalog=".. tostring(pageref)) end
callback.register("finish_pdffile", doc_end)
maybe there could be a callback after document output?
This is unlikely to happen. When the file is closed tex is basically finished and cleans up states and so. Of course you can try to hook something in the stop_run callback, but as you want to do something after the pdf file is created a better approach is to just quit and in a next run do what you want to do (you can rename the file inbetween). Luatex is not primarily a pdf processing tool. Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
participants (3)
-
Hans Hagen
-
Lincikas
-
linuxss