Dear list members I think I don’t really understand the way to use a context command with luacode ! What I attempt to do is to write a function in lua which computes the position of one or several bottom tabs depending on : line number (1 is the lowest, 2 is above etc), number of tabs, horizontal position of the tab on the line. The height of the tab is a Tex value \hauteuronglet So I compute the x and y value and the width of the tab(s) After that I want to define a layer with the tab(s) in a table I can’t have the context.setlayer working properly. For sure, this code should be cleaned after testing. Here is the code I wrote \definelayer[OngletBas][x=0mm, y=0mm, width=\paperwidth, height=\paperheight] % variables \newdimen\hauteuronglet \hauteuronglet=1cm %variables onglet gauche \newdimen\vertposonglet \newdimen\hauteurzoneacouper %variables onglet bas \newdimen\largeurzoneongletsbas \newdimen\ordonneeongletsbas \newdimen\abscisseongletsbas \newdimen\largeurongletbas \startluacode function test(opt_1, arg_1) local table = lpeg.split(",",interfaces.tolist(opt_1)) local labels = lpeg.split(",",arg_1) local NumLigne = table[1] local NbTotalOnglets = table[2] local PremierOnglet = table[3] local decalage = tex.sp("6.5pt") tex.dimen.ordonneeongletsbas = tex.dimen.paperheight - tex.dimen.hauteuronglet * NumLigne tex.dimen.largeurzoneongletsbas = tex.dimen.paperwidth - tex.dimen.backspace tex.dimen.largeurongletbas = tex.dimen.largeurzoneongletsbas / NbTotalOnglets tex.dimen.abscisseongletsbas = tex.dimen.backspace + tex.dimen.largeurongletbas * (PremierOnglet - 1) local x_ongletsbas = tex.dimen.abscisseongletsbas - decalage local y_ongletsbas = tex.dimen.ordonneeongletsbas local largeurongletbas = tex.dimen.largeurongletbas context.setupbackgrounds({"page"},{background = "OngletBas"}) context.setlayer({"OngletBas"},{hoffset = x_ongletsbas, voffset = y_ongletsbas}, context.setupTABLE({c},{1,2,3,4,5,6},{width = largeurongletbas}) context.bTABLE() context.bTR() context.bTD() context(labels[1]) context.eTD() context.eTR() context.eTABLE() ) end interfaces.definecommand { name = "test", arguments = { { "option", "hash" }, { "content", "string" }, }, macro = test, } \stopluacode I have to add also (I don’t understand why) but I need to add an offset of -6.5pt to adjust the position of the table. Thanks in advance Eric Gerard
On 1/19/2015 8:58 PM, Eric Gerard wrote:
Dear list members
I think I don’t really understand the way to use a context command with luacode ! What I attempt to do is to write a function in lua which computes the position of one or several bottom tabs depending on : line number (1 is the lowest, 2 is above etc), number of tabs, horizontal position of the tab on the line. The height of the tab is a Tex value \hauteuronglet So I compute the x and y value and the width of the tab(s) After that I want to define a layer with the tab(s) in a table I can’t have the context.setlayer working properly. For sure, this code should be cleaned after testing.
Here is the code I wrote
\definelayer[OngletBas][x=0mm, y=0mm, width=\paperwidth, height=\paperheight] % variables \newdimen\hauteuronglet \hauteuronglet=1cm
%variables onglet gauche \newdimen\vertposonglet \newdimen\hauteurzoneacouper %variables onglet bas \newdimen\largeurzoneongletsbas \newdimen\ordonneeongletsbas \newdimen\abscisseongletsbas \newdimen\largeurongletbas
\startluacode function test(opt_1, arg_1) local table = lpeg.split(",",interfaces.tolist(opt_1)) local labels = lpeg.split(",",arg_1)
local NumLigne = table[1] local NbTotalOnglets = table[2] local PremierOnglet = table[3] local decalage = tex.sp("6.5pt")
tex.dimen.ordonneeongletsbas = tex.dimen.paperheight - tex.dimen.hauteuronglet * NumLigne tex.dimen.largeurzoneongletsbas = tex.dimen.paperwidth - tex.dimen.backspace tex.dimen.largeurongletbas = tex.dimen.largeurzoneongletsbas / NbTotalOnglets tex.dimen.abscisseongletsbas = tex.dimen.backspace + tex.dimen.largeurongletbas * (PremierOnglet - 1)
local x_ongletsbas = tex.dimen.abscisseongletsbas - decalage local y_ongletsbas = tex.dimen.ordonneeongletsbas local largeurongletbas = tex.dimen.largeurongletbas
context.setupbackgrounds({"page"},{background = "OngletBas"})
context.setlayer({"OngletBas"},{hoffset = x_ongletsbas, voffset = y_ongletsbas}, context.setupTABLE({c},{1,2,3,4,5,6},{width = largeurongletbas}) context.bTABLE() context.bTR() context.bTD() context(labels[1]) context.eTD() context.eTR() context.eTABLE() ) end interfaces.definecommand { name = "test", arguments = { { "option", "hash" }, { "content", "string" }, }, macro = test, } \stopluacode
I have to add also (I don’t understand why) but I need to add an offset of -6.5pt to adjust the position of the table.
you need to make a complete example, something that runs without me having to define extra tex code btw, don't overload the 'table' table ... you can't access the helpers in its namespace otherwise, 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 (2)
-
Eric Gerard
-
Hans Hagen