ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Automatic typesetting of catalogue entries
@ 2006-03-27 13:17 Piotr Kopszak
  2006-03-27 16:08 ` Hans Hagen
  0 siblings, 1 reply; 5+ messages in thread
From: Piotr Kopszak @ 2006-03-27 13:17 UTC (permalink / raw)


Hello list, 

This is a more general question so I'm not attaching any specific
code examples but rather will try to explain what I'm thinking
about. I'm going to typeset a catalogue of about 200 objects. Each
entry consists of two main parts: a block of text and a photograph of the
object. As we have to be economic rather than luxurious I adjust
manually the size  of each figure so that the text fills the rest of the
page entirely. That means I keep on incrementing the figure width
until the text spills onto next page, then I go back to the last value
that was OK. Sometimes I have  to squeeze two entries on one page so
that each occupies half of a page. Perfectly repetitive task at which 
computer would do much better than human. Sorry if it's something
trivial but I couldn't find any solution on my own. 

Thanks for any hints in advance

Piotr

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Automatic typesetting of catalogue entries
  2006-03-27 13:17 Automatic typesetting of catalogue entries Piotr Kopszak
@ 2006-03-27 16:08 ` Hans Hagen
  2006-03-27 17:10   ` Piotr Kopszak
  0 siblings, 1 reply; 5+ messages in thread
From: Hans Hagen @ 2006-03-27 16:08 UTC (permalink / raw)


Piotr Kopszak wrote:
> Hello list, 
>
> This is a more general question so I'm not attaching any specific
> code examples but rather will try to explain what I'm thinking
> about. I'm going to typeset a catalogue of about 200 objects. Each
> entry consists of two main parts: a block of text and a photograph of the
> object. As we have to be economic rather than luxurious I adjust
> manually the size  of each figure so that the text fills the rest of the
> page entirely. That means I keep on incrementing the figure width
> until the text spills onto next page, then I go back to the last value
> that was OK. Sometimes I have  to squeeze two entries on one page so
> that each occupies half of a page. Perfectly repetitive task at which 
> computer would do much better than human. Sorry if it's something
> trivial but I couldn't find any solution on my own. 
>
> Thanks for any hints in advance
>   
i have no time to explain the details so it's up to you to wikify this ... 

\showframe

\newcounter\WhateverCounter

% quick and dirty, each text + figure gets half a page and the 
% graphic fills the available area

\long\def\StartWhatever[#1]#2\StopWhatever
  {\blank
   #2
   \blank
   \doglobal\increment\WhateverCounter
   \startlinecorrection
   \ifodd\WhateverCounter\relax
     % first on page
     \scratchdimen\dimexpr.5\textheight-\pagetotal-\lineheight\relax
     \expanded{\externalfigure[#1][frame=on,height=\the\scratchdimen]}
   \else
     % second on page
     \scratchdimen\dimexpr\pagegoal-\pagetotal-\lineheight\relax
     \expanded{\externalfigure[#1][frame=on,height=\the\scratchdimen]}
   \fi
   \stoplinecorrection}

% distribute the graphics over the page

\long\def\StartWhatever[#1]#2\StopWhatever
  {\blank
   #2
   \blank
   \doglobal\increment\WhateverCounter
   \hpos{b:\WhateverCounter}{\strut}
   \vfill
   \scratchdimen\dimexpr\MPy{b:\WhateverCounter}-\MPy{e:\WhateverCounter}+\lineheight\relax
   \setbox\scratchbox\hbox{\expanded{\externalfigure[#1][frame=on,height=\the\scratchdimen]}}
   \ht\scratchbox\strutheight
   \hpos{e:\WhateverCounter}{\strut\box\scratchbox}
   \ifodd\WhateverCounter\relax
   \else
     \page
   \fi}

\starttext 

\dorecurse{20} {
    \StartWhatever[cow.pdf]
      \getrandomcount\scratchcounter{1}{3}
      \input \ifcase\scratchcounter tufte \or davis \or ward \or zapf \else bryson \fi \relax
    \StopWhatever
}

\stoptext

implementing solutions is not that hard; it mostly depends on preferences and boundary conditions 

Hans 


-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                             | www.pragma-pod.nl
-----------------------------------------------------------------

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Automatic typesetting of catalogue entries
  2006-03-27 16:08 ` Hans Hagen
@ 2006-03-27 17:10   ` Piotr Kopszak
  2006-03-28  8:03     ` Taco Hoekwater
  0 siblings, 1 reply; 5+ messages in thread
From: Piotr Kopszak @ 2006-03-27 17:10 UTC (permalink / raw)


> i have no time to explain the details so it's up to you to wikify this ... 
> 
> \showframe
> 
> \newcounter\WhateverCounter
> 
> % quick and dirty, each text + figure gets half a page and the 
> % graphic fills the available area
> 
> \long\def\StartWhatever[#1]#2\StopWhatever
>   {\blank
>    #2
>    \blank
>    \doglobal\increment\WhateverCounter
>    \startlinecorrection
>    \ifodd\WhateverCounter\relax
>      % first on page
>      \scratchdimen\dimexpr.5\textheight-\pagetotal-\lineheight\relax
>      \expanded{\externalfigure[#1][frame=on,height=\the\scratchdimen]}
>    \else
>      % second on page
>      \scratchdimen\dimexpr\pagegoal-\pagetotal-\lineheight\relax
>      \expanded{\externalfigure[#1][frame=on,height=\the\scratchdimen]}
>    \fi
>    \stoplinecorrection}
> 
> % distribute the graphics over the page
> 
> \long\def\StartWhatever[#1]#2\StopWhatever
>   {\blank
>    #2
>    \blank
>    \doglobal\increment\WhateverCounter
>    \hpos{b:\WhateverCounter}{\strut}
>    \vfill
>    \scratchdimen\dimexpr\MPy{b:\WhateverCounter}-\MPy{e:\WhateverCounter}+\lineheight\relax
>    \setbox\scratchbox\hbox{\expanded{\externalfigure[#1][frame=on,height=\the\scratchdimen]}}
>    \ht\scratchbox\strutheight
>    \hpos{e:\WhateverCounter}{\strut\box\scratchbox}
>    \ifodd\WhateverCounter\relax
>    \else
>      \page
>    \fi}
> 
> \starttext 
> 
> \dorecurse{20} {
>     \StartWhatever[cow.pdf]
>       \getrandomcount\scratchcounter{1}{3}
>       \input \ifcase\scratchcounter tufte \or davis \or ward \or zapf \else bryson \fi \relax
>     \StopWhatever
> }
> 
> \stoptext
> 
> implementing solutions is not that hard; it mostly depends on preferences and boundary conditions 
> 
> Hans 

That's superb! Certainly worth wikifying, maybe someone better versed
in ConTeXt than me cared also to explain what's going on in here. 

Great thanks!!!

Piotr

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Automatic typesetting of catalogue entries
  2006-03-27 17:10   ` Piotr Kopszak
@ 2006-03-28  8:03     ` Taco Hoekwater
  2006-03-28  8:16       ` Hans Hagen
  0 siblings, 1 reply; 5+ messages in thread
From: Taco Hoekwater @ 2006-03-28  8:03 UTC (permalink / raw)




Piotr Kopszak wrote:
> That's superb! Certainly worth wikifying, maybe someone better versed
> in ConTeXt than me cared also to explain what's going on in here. 

The first definition simply puts two on a page, using a counter
to decide whether it is processing the top one or the bottom one,
and using half of the page for each of them.

The second definition also has two per page, but it uses the height
of the typeset text to scale the images instead of using a fixed
value based on the page dimension. It pdftex's positioning extensions
to do so (that is the source the \hpos and \MPy commands). It has to
disregard the actual size of the placed graphic to prevent it from
interfering, and that is the reason for \ht\scratchbox\strutheight
line (consider it a vertical version of \llap).

Cheers, Taco

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Automatic typesetting of catalogue entries
  2006-03-28  8:03     ` Taco Hoekwater
@ 2006-03-28  8:16       ` Hans Hagen
  0 siblings, 0 replies; 5+ messages in thread
From: Hans Hagen @ 2006-03-28  8:16 UTC (permalink / raw)
  Cc: Steve Peter

Taco Hoekwater wrote:
> Piotr Kopszak wrote:
>   
>> That's superb! Certainly worth wikifying, maybe someone better versed
>> in ConTeXt than me cared also to explain what's going on in here. 
>>     
>
> The first definition simply puts two on a page, using a counter
> to decide whether it is processing the top one or the bottom one,
> and using half of the page for each of them.
>
> The second definition also has two per page, but it uses the height
> of the typeset text to scale the images instead of using a fixed
> value based on the page dimension. It pdftex's positioning extensions
> to do so (that is the source the \hpos and \MPy commands). It has to
> disregard the actual size of the placed graphic to prevent it from
> interfering, and that is the reason for \ht\scratchbox\strutheight
> line (consider it a vertical version of \llap).
>   
thanks 

such samples + explanations are also nice for the practex journal or maps or tugboat or ... 

Hans  

-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                             | www.pragma-pod.nl
-----------------------------------------------------------------

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-03-28  8:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-27 13:17 Automatic typesetting of catalogue entries Piotr Kopszak
2006-03-27 16:08 ` Hans Hagen
2006-03-27 17:10   ` Piotr Kopszak
2006-03-28  8:03     ` Taco Hoekwater
2006-03-28  8:16       ` Hans Hagen

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).