[texhax] output routine question: index "continued" lines

Paul Isambert zappathustra at free.fr
Tue Jun 15 10:27:06 CEST 2010


Stan a écrit :
> Paul,
>
> Thanks for the recommendation about \outputpenalty.  
Which lacked the following: return a 0 penalty if \outputpenalty is 
10000, since \outputpenalty is 10000 if the break was at point without a 
penalty. The rest is ok (return the value of \outputpenalty).
> Am I correct in thinking that the problem of making the lines line up 
> would be solved by forcing any lines that are added to the top of the 
> page to have height equal to \topskip (for the first added line) or 
> \baselineskip (for any others)?  If that works, is it the best way to 
> make things line up?  (For what it's worth, \topskip and \baselineskip 
> are equal in my current situation, but I don't want to rely on that.)
That would work but that wouldn't be enough. You need to add the 
following between the added line and the unboxed 255:

\vskip\dimexpr(\baselineskip-\topskip-\prevdepth)\relax

(\dimexpr is an e-TeX primitive, whose meaning is clear, hopefully, even 
if you don't know it. Nothing crucial hinges on it, though.)
What we do here is mimick TeX's interline glue: we put the boxes' 
baselines at a distance that is \baselineskip by inserting such a glue 
minus the height of the bottom box (which we know is \topskip in height, 
since it's the first line of 255) and the depth of the top box (which is 
recorded in \prevdepth). If the added line is always the same you can 
specify the skip in advance and avoid the calculation.

But now I reread what you've written and realize you talk about the 
added "lines", with an "s". Which basically doesn't change much, except 
barring the first one there's no need to force them to anything since 
that's TeX basic job (placing lines where they should be). We had to 
take over that job above because of \unvbox. However, you never know, so 
perhaphs an example with things worked out?
(E.g. if those added lines are the result of an \unvbox then \prevdepth 
above won't work.)

Best,

Paul




>
> Stan
>
>
> On Wed, 09 Jun 2010 02:44:03 -0500, Paul Isambert 
> <zappathustra at free.fr> wrote:
>
>> To be precise: the first box of box 255 is not \topskip in height, 
>> but is preceded by a glue so that glue+box height =  \topskip. Which 
>> doesn't matter for the line of reasonning.
>> Paul
>>
>> Paul Isambert a écrit :
>>> Watch out interline glue and baseline distance.
>>> The first line (hbox) of box  255 is \topskip in height, instead of 
>>> \baselineskip, and anyway it won't adjust to the height of the added 
>>> line because \unvbox doesn't do so.
>>> On the other hand, when you \shipout box 255 with the added line, 
>>> the later has its naturel height, not \topskip, hence pages with 
>>> added lines will be shifted upward with respect to pages without.
>>> (Although \topskip will be added in the content is sent back because 
>>> \ht255>\pagegoal, reason why you might not see it on full pages.)
>>>
>>> And when you do \unvbox255 you should return the \outputpenalty (if 
>>> not 10000), otherwise the last box of box 255 will be followed by a 
>>> 10000 penalty, which will probably do no harm unless TeX rebuilds 
>>> exactly the same page plus the added line by shrinking here and 
>>> there. (I.e. \ht255 was indeed larger than \pagegoal, but then it 
>>> was built withouth shrink.)
>>>
>>> Paul
>>>
>>> Stan a écrit :
>>>> Thanks for the info, and the example.  I think I've made a macro 
>>>> that does (almost) what I want.  I'd greatly appreciate any 
>>>> comments you have, especially about possible shortcomings.  One 
>>>> thing I know it fails to do is deal properly with the spacing 
>>>> between the added "!" lines and the lines of text.
>>>>
>>>> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>>>>
>>>> \vsize=24pt%just two lines per page for this example
>>>>
>>>> \newif\iflineadded% conditional to test whether ! has been added 
>>>> already
>>>>
>>>> \output={%
>>>>     \iflineadded
>>>>         % if already added, do nothing
>>>>     \else
>>>>         \setbox255=\vbox{!\unvbox255}
>>>>         \global\lineaddedtrue
>>>>     \fi
>>>>     \ifdim\ht255>\pagegoal% if \box255 too high
>>>>         \unvbox255% send contents back to page builder
>>>>     \else
>>>>         \shipout\box255
>>>>         \global\lineaddedfalse
>>>>     \fi
>>>> }
>>>>
>>>>
>>>> Now is the time
>>>>
>>>> for all good men
>>>>
>>>> to come to the aid
>>>>
>>>> of the party.
>>>>
>>>> \bye
>>>>
>>>> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>>>>
>>>>
>>>>
>>>>
>>>> On Mon, 07 Jun 2010 03:34:43 -0500, Philip Taylor (Webmaster, 
>>>> Ret'd) <P.Taylor at rhul.ac.uk> wrote:
>>>>
>>>>>
>>>>>
>>>>> Stan wrote:
>>>>>> I'm trying to set up a basic output routine that will handle 
>>>>>> automatic
>>>>>> insertion of "continued" lines at the top of pages where 
>>>>>> appropriate.
>>>>>
>>>>> Let me address your final example first (I have to leave shortly) --
>>>>>
>>>>>> All of my attempts have resulted in the same type of error that 
>>>>>> results,
>>>>>> for example, from changing
>>>>>>
>>>>>> \output={\plainoutput}
>>>>>>
>>>>>> to
>>>>>>
>>>>>> \output={\plainoutput!}
>>>>>>
>>>>>> In other words, pages were ejected until some limitation was hit. 
>>>>>> (In my
>>>>>> case, I got a "TeX capacity exceeded, sorry [main memory 
>>>>>> size=2500000]"
>>>>>> message.)
>>>>>
>>>>> Because every time \output is threaded, it tries to append
>>>>> a shriek marker to the current page; you would want to
>>>>> look into the guts of \plainoutput to see how you could
>>>>> intercalate additional  material without causing this
>>>>> infinite loop.  A simple example is as follows; this
>>>>> shews the simplest output routine, followed by one that
>>>>> append a single line containing "!".
>>>>>
>>>>> \output = {\shipout \box 255 }
>>>>> Now is the time \eject
>>>>> for all good men \eject
>>>>> to come to the aid \eject
>>>>> of the party.
>>>>> \end
>>>>>
>>>>> \output = {\setbox 255 = \vbox {\unvbox 255 \centerline 
>>>>> {!}}\shipout \box 255 }
>>>>> Now is the time \eject
>>>>> for all good men \eject
>>>>> to come to the aid \eject
>>>>> of the party.
>>>>> \end
>>>> _______________________________________________
>>>> TeX FAQ: http://www.tex.ac.uk/faq
>>>> Mailing list archives: http://tug.org/pipermail/texhax/
>>>> More links: http://tug.org/begin.html
>>>>
>>>> Automated subscription management: 
>>>> http://tug.org/mailman/listinfo/texhax
>>>> Human mailing list managers: postmaster at tug.org
>>>
>>> _______________________________________________
>>> TeX FAQ: http://www.tex.ac.uk/faq
>>> Mailing list archives: http://tug.org/pipermail/texhax/
>>> More links: http://tug.org/begin.html
>>>
>>> Automated subscription management: 
>>> http://tug.org/mailman/listinfo/texhax
>>> Human mailing list managers: postmaster at tug.org



More information about the texhax mailing list