Automatic typesetting of catalogue entries
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
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 -----------------------------------------------------------------
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
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
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 -----------------------------------------------------------------
participants (3)
-
Hans Hagen
-
Piotr Kopszak
-
Taco Hoekwater