[NTG-context] Automatic typesetting of catalogue entries

Hans Hagen pragma at wxs.nl
Mon Mar 27 18:08:04 CEST 2006


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



More information about the ntg-context mailing list