29.05.2014 Views

The history of luaTEX 2006–2009 / v 0.50 - Pragma ADE

The history of luaTEX 2006–2009 / v 0.50 - Pragma ADE

The history of luaTEX 2006–2009 / v 0.50 - Pragma ADE

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

function lua.delay(f)<br />

delayed[#delayed+1] = f<br />

end<br />

function lua.flush_delayed(...)<br />

local t = delayed<br />

delayed = { }<br />

for _, fun in ipairs(t) do<br />

fun(...)<br />

end<br />

end<br />

function lua.flush(...)<br />

tex.sprint("\\directlua 0 {lua.flush_delayed(" ..<br />

table.concat({...},',') .. ")}")<br />

end<br />

end<br />

Usage is similar:<br />

function test(n)<br />

lua.delay(function(...)<br />

tex.sprint(string.format("pi: %s %s %s\\par",...))<br />

end)<br />

tex.sprint(string.format("\\setbox0=\\hbox{%s}",math.pi*n))<br />

lua.flush(tex.wd[0],tex.ht[0],tex.dp[0])<br />

end<br />

Dirty tricks 77

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!