[NTG-context] How to center with picture taken into consideration

2013-04-27 Thread Cecil Westerhof
I keep bugging the list. ;-)

I center some text on a place where I also place a picture on the
right site. Is it possible to center on the part that is not taken up
by the picture?

The picture is placed with:
  \definelayer[picture][
preset=righttop,
width=\textwidth,
  ]

  \setlayer[picture]{\externalfigure[graphics/pasfoto]}

  \setupbackgrounds[text][text][background=picture]
  \setupbackgrounds[state=repeat]

To make things a little more complicated, the placing of the picture
is conditional. So it is not always done.

-- 
Cecil Westerhof
___
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
___


Re: [NTG-context] How to center with picture taken into consideration

2013-04-27 Thread Sietse Brouwer
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
___


Re: [NTG-context] How to center with picture taken into consideration

2013-04-27 Thread Peter Münster
On Sat, Apr 27 2013, Sietse Brouwer wrote:

 how to obtain the an image's width and/or height from Lua.

Here an example:
http://modules.contextgarden.net/dl/grph-downsample.lua/tex/context/third/grph-downsample/grph-downsample.lua

-- 
   Peter
___
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
___