[NTG-context] Irregularity in a topspace a bottomspace?

Wolfgang Schuster schuster.wolfgang at googlemail.com
Fri Jun 11 11:50:44 CEST 2010


Am 11.06.10 07:45, schrieb Jaroslav Hajtmar:
> Hi all.
> I was surprised that when I set up (in the MKII and MKIV too) topspace
> parameter to a nonzero value and the value of the bottomspace parameter
> to zero value, then the size of bottomspace is the same as topspace size.
> On the other side, if I set topspace to zero value and the bottomspace
> to nonzero value, ConTeXt behaves as I expected.
> Is this a normal behavior ConTeXt?
> Ie. when bottomspace is zero, then the paper has only the tops and not
> bottoms?


As told in my other mail that's not possible with a calculated text 
height but here is a patch:

\unprotected\def\dorecalculatelayout
   {%\the\everybeforelayout
    \setups[\layoutparameter\c!preset]%
    \global\leftmarginwidth \layoutparameter\c!leftmargin
    \global\rightmarginwidth\layoutparameter\c!rightmargin
    \global\leftedgewidth   \layoutparameter\c!leftedge
    \global\rightedgewidth  \layoutparameter\c!rightedge
    \global\headerheight    \layoutparameter\c!header
    \global\footerheight    \layoutparameter\c!footer
    \global\bottomheight    \layoutparameter\c!bottom
    \global\topheight       \layoutparameter\c!top
    \global\backspace       \layoutparameter\c!backspace
    \global\topspace        \layoutparameter\c!topspace
    \setlayoutdimensions % the rest of the `dimensions'
    \docheckgridsnapping
    \doprocesslocalsetups{\layoutparameter\c!setups}% depends on 
gridsnapping !
    \simplesetupwhitespace
    \simplesetupblank
    \setupinterlinespace[\v!reset]% \synchronizegloballinespecs
    \global\cutspace\layoutparameter\c!cutspace
    \relax
    \doifelse{\layoutparameter\c!width}\v!middle
      {\ifdim\cutspace=\zeropoint
         \global\cutspace\backspace
       \fi
       \global\makeupwidth\dimexpr\paperwidth-\backspace-\cutspace\relax}
      {\doifelse{\layoutparameter\c!width}\v!auto
         {\global\makeupwidth\dimexpr\paperwidth-\backspace-\cutspace\relax}
         {\doifelse{\layoutparameter\c!width}\v!fit
            {\ifdim\cutspace=\zeropoint
               \global\cutspace\backspace
             \fi
             \global\makeupwidth\dimexpr\paperwidth-\cutspace\relax
             \scratchdimen\dimexpr\backspace
               -\leftedgewidth  -\leftedgedistance
               -\leftmarginwidth-\leftmargindistance\relax
             \ifdim\scratchdimen<\zeropoint
               \scratchdimen\zeropoint
             \fi
             \global\advance\makeupwidth\dimexpr
               -\rightmargindistance-\rightmarginwidth
               -\rightedgedistance  -\rightedgewidth
               -\scratchdimen\relax}
            {\global\makeupwidth\layoutparameter\c!width\relax
             \ifdim\cutspace=\zeropoint
 
\global\cutspace\dimexpr\paperwidth-\makeupwidth-\backspace\relax
            % \else
                % A kind of inconsistent specification, but used
                % in for instance s-pre-19.tex; the cutspace is
                % used only for determining some kind of right
                % margin; don't use this in doublesided mode
             \fi}}}%
    \scratchdimen\layoutparameter\c!bottomspace\relax
   %\ifdim\scratchdimen=\zeropoint
   %  \scratchdimen\topspace
   %\fi
    \global\bottomspace\layoutparameter\c!bottomspace\relax
    \global\layoutlines0\number\layoutparameter\c!lines\relax % may be empty
    \ifcase\layoutlines
      \doifelse{\layoutparameter\c!height}\v!middle
        {\ifdim\bottomspace=\zeropoint
           \global\bottomspace\topspace
         \fi
 
\global\makeupheight\dimexpr\paperheight-\topspace-\bottomspace\relax}
        {\doifelse{\layoutparameter\c!height}\v!auto
 
{\global\makeupheight\dimexpr\paperheight-\topspace-\bottomspace\relax}
           {\doifelse{\layoutparameter\c!height}\v!fit
              {\ifdim\bottomspace=\zeropoint
                 \global\bottomspace\topspace
               \fi
               \global\makeupheight\dimexpr\paperheight-\bottomspace\relax
               \scratchdimen\dimexpr\topspace-\topheight-\topdistance\relax
               \ifdim\scratchdimen<\zeropoint
                 \scratchdimen\zeropoint
               \fi
 
\global\advance\makeupheight\dimexpr-\bottomdistance-\bottomheight-\scratchdimen\relax}
              {\global\makeupheight\layoutparameter\c!height\relax
               \ifdim\bottomspace=\zeropoint
 
\global\bottomspace\dimexpr\paperheight-\makeupheight-\topspace\relax
               \else
                 % inconsistent specification
               \fi}}}%
    \else
      % beware, when the bodyfont changes (switched) this will change as 
well; implementing
      % a global lineheight is tricky: should we take the bodyfont 
interlinespace or the one set
      % independent of the bodyfont (before or after a layout spec); way 
too fuzzy, so we
      % stick to the current method (after a night of experimenting 
...2003/10/13)
      \global\makeupheight\dimexpr
         \layoutparameter\c!lines\lineheight-\strutheight+\topskip+
         \headerdistance+\headerheight+\footerdistance+\footerheight\relax
    \fi
    \backoffset\layoutparameter\c!horoffset
    \topoffset \layoutparameter\c!veroffset
    \global\setdimentoatleast\makeupwidth\onepoint
    \global\setdimentoatleast\makeupheight \onepoint
    % \checkcurrentlayout % here ?
    % \the\everyafterlayout
    \calculatelayoutextras
    \calculatehsizes
    \calculatevsizes
    \calculatepseudocolumns
    \recalculatebackgrounds}

\definelayout[middleheight][topspace=4cm,bottomspace=0cm,height=middle]
\definelayout[autoheight]  [topspace=4cm,bottomspace=0cm,height=auto]

\definelayout[middlewidth] [backspace=4cm,cutspace=0cm,width=middle]
\definelayout[autowidth]   [backspace=4cm,cutspace=0cm,width=auto]

\setuppapersize[A4][A3]\setuplayout[location=middle]

\showframe

\starttext

\setuplayout[middleheight]\page[empty]
\setuplayout[autoheight]  \page[empty]
\setuplayout[reset]       \page[empty]

\setuplayout[middlewidth] \page[empty]
\setuplayout[autowidth]   \page[empty]
\setuplayout[reset]       \page[empty]

\stoptext

Wolfgang
-------------- next part --------------
A non-text attachment was scrubbed...
Name: auto.tex
Type: application/x-tex
Size: 5376 bytes
Desc: not available
URL: <http://www.ntg.nl/pipermail/ntg-context/attachments/20100611/2abf63d0/attachment-0001.tex>


More information about the ntg-context mailing list