Hello Henning,
On Tue, 06 Feb 2018 13:13:12 +0100, Henning Hraban Ramm <[email protected]> wrote:
I’ll try as soon as I get some time, since algorithmic image placement is a
recurring problem for me, as I try to replace InDesign in my workflow.
I thought about providing a module, but each of my projects has so differing
needs that either every macro would need a bunch of options, or I need a lot of
similar macros. We’ll see...
my experience in these situations:
I'm usually implementing complicated solutions via Lua, with functions with
obligatory arg(s) first followed by one optional argument of table type:
- it's easy to investigate this optional argument and alter the algorithm
depending on table keys (presence and/or value),
- you don't have to be afraid of optional arg(s) rearrangement.
To be more concrete:
---- Sample Lua code
MyPlaceFigure = function(figname,
opts) -- Optional; .scale = .sc, .rotation = .rot,
.label, ...
opts = opts or {} -- To simplify code bellow
local scale, rot, lab =
opts.scale or opts.sc, -- I.e. more keys are allowed in long/short
alternative
opts.rotation or opts.rotate or opts.rot, -- dtto
opts.label or opts.lab,
nil
if label then
-- E.g. use context.placefloat(...)
else
context.externalfigure({figname}, {scale = 1000 * scale, orientation = rot,
})
end
end
----
Best regards,
Lukas
Greetlings, Hraban
--
Ing. Lukáš Procházka | mailto:[email protected]
Pontex s. r. o. | mailto:[email protected] | http://www.pontex.cz |
IDDS:nrpt3sn
Bezová 1658
147 14 Praha 4
Mob.: +420 702 033 396
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the
Wiki!
maillist : [email protected] / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________