From: Sietse Brouwer <sbbrouwer@gmail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: How to center with picture taken into consideration
Date: Sat, 27 Apr 2013 14:35:03 +0200 [thread overview]
Message-ID: <CAF=dkzwoJfp3pbKQesfKsCKULGFswZzabEk-72a8ZR3npdq2RQ@mail.gmail.com> (raw)
In-Reply-To: <CAG-LmmAHAMp_tMAbcx4DSyryjQWTdsoVvux4SygeRHV2PLP=uQ@mail.gmail.com>
Hello Cecil,
I have a LuaTeX-based start for you, but there is one important thing
I do not know: how to obtain the an image's width and/or height from
Lua. Although that would also depend on whether you want to resize
images to a fixed with, etc. Anyway, now that the typesetting code is
Lua-based, working out the conditional stuff you need will hopefully
be trivial (for 'if you know Lua or have an hour to learn the basics'
values of trivial).
Cheers,
Sietse
% 2013-04-27
\useMPlibrary[dum]
\showframe
\defineparagraphs[persoon]
\setupparagraphs[persoon][1]
[width=\dimexpr \textwidth - 3.5cm\relax,
distance=0.5cm,
align=middle,
]
\setuplines[align=middle]
\setupparagraphs[persoon][2][width=3cm]
\starttext
\startluacode
-- a table containing the material we want to typeset
local contents = {
{
text = [[
Naam:
Adres:
Burgerservicenummer:
]],
image = "pic1"
},
{
text = [[
Naam: Aapje aapje aapje aapje
Adres: Olifantje
Burgerservicenummer: En nu jij
]],
image = "pic2"
}
}
-- typeset each text-image pair
for k,v in ipairs(contents) do
-- calculate or specify how wide you want the image and the
paragraphs to be
imagecolwidth = string.todimen("3cm")
coldistance = string.todimen("0.5cm")
textcolwidth = tex.dimen.textwidth - imagecolwidth - coldistance
-- setup the text column
context.setupparagraphs(
{ "persoon" },
{ 1 },
{ width = textcolwidth .. "sp" })
-- setup the image column (possibly to width 0?)
context.setupparagraphs(
{ "persoon" },
{ 2 },
{ width = imagecolwidth .. "sp" })
-- the actual typesetting code
context.startpersoon()
context.startlines()
context(v.text)
context.stoplines()
context.nextpersoon()
context.externalfigure(
{ v.image},
{
width = imagecolwidth .. "sp",
height = "4cm",
factor = "fit"
}
)
context.stoppersoon()
end
\stopluacode
\stoptext
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
next prev parent reply other threads:[~2013-04-27 12:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-27 9:50 Cecil Westerhof
2013-04-27 12:35 ` Sietse Brouwer [this message]
2013-04-27 19:24 ` Peter Münster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAF=dkzwoJfp3pbKQesfKsCKULGFswZzabEk-72a8ZR3npdq2RQ@mail.gmail.com' \
--to=sbbrouwer@gmail.com \
--cc=ntg-context@ntg.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).