# ConTeXt: uniform handling of whitespace in margin and text

Why does whitespace handle differently in the margins than the text body?

\setuppapersize[letter]

\setupwhitespace[medium]

\setuplayout
[backspace=4.375in,
width=3.625in,
leftmargin=3.625in,
rightmargin=0in,
leftmargindistance=0.25in,
%
topspace=0.25in,
height=10.5in,
header=0.25in,
headerdistance=0.25in,
footer=0.25in,
footerdistance=0.25in,
]

\setupmarginblock
[location=left,
width=\leftmarginwidth,
]

\define[1]\heading{%
\dontleavehmode{\bfc\setupinterlinespace\strut#1}%
\blank[big,samepage]%
}

\showframe

\showallmakeup

\starttext
\startmarginblock
\heading{Left 1}
\samplefile{ward}

\heading{Left 2}
\samplefile{knuth}

\samplefile{weisman}

\heading{Left 3}
\startitemize
\item 1
\item 2
\item 3
\stopitemize
\samplefile{ward}
\stopmarginblock

\heading{Right 1}
\samplefile{ward}

\heading{Right 2}
\samplefile{knuth}

\samplefile{weisman}

\heading{Right 3}
\startitemize
\item 1
\item 2
\item 3
\stopitemize
\samplefile{ward}
\stoptext


How do I increase the space above \heading without introducing unnecessary whitespace at the top of the page text, below the header? A \blank at the start of \heading isn't collapsed in the margin, \vbox to 2ex{} is only collapsed in the margin and \vbox to 2ex{\strut} is never collapsed. What can I do?

How do I keep the space below \heading uniform in both the margin and the page text without removing \setupinterlinespace? Right now there is extra space in the margin headings keeping both columns out of alignment. It's a slight effect that eventually causes the left column to be about a sentence longer than the right column

This is an extension of Implement Friggeri in ConTeXt. I'm using margins rather than columns for a reason - mainly to have text flow between pages rather than between columns.

Note: I don't want grid typesetting as I intend the lines to become un-aligned as the column contents differ. That and I prefer non-grid standard-TeX typesetting for the main content in the text area.

Overall I would like a result along the lines of:

\setuppapersize[letter]

\setuplayout
[backspace=0.5in,
width=7.5in,
%
topspace=0.25in,
height=10.5in,
header=0.25in,
headerdistance=0.25in,
footer=0.25in,
footerdistance=0.25in,
]

\setupwhitespace[medium]

\define[1]\heading{%
\blank[big,samepage]%
\dontleavehmode{\bfc\setupinterlinespace\strut#1}%
\blank[medium,samepage]%
}

\definecolumnset[TwoColumns][n=2]

\showframe

\starttext
\startcolumnset[TwoColumns]

\heading{Left 1}
\samplefile{ward}

\heading{Left 2}
\samplefile{knuth}

\samplefile{weisman}

\heading{Left 3}
\startitemize
\item 1
\item 2
\item 3
\stopitemize
\samplefile{jojomayer}

\column

\heading{Right 1}
\samplefile{ward}

\heading{Right 2}
\samplefile{knuth}

\samplefile{weisman}

\heading{Right 3}
\startitemize
\item 1
\item 2
\item 3
\stopitemize
\samplefile{jojomayer}

\stopcolumnset
\stoptext

• If I wrap the margin text into a vbox the space above \heading is discarded. That means TeX is not in vmode after \startmarginblock because of the \begstrut therein. If I wrap the body text into a vbox as well, I also get consistent spacing between margin and main text (code, screenshot). I guess this comes from a difference between vertical mode and internal vertical mode but I don't know any more details. – Henri Menke Dec 7 '18 at 3:49
• I also browsed the implementation of marginblock and it is not entirely clear to me what is going on. The vbox inside the margin is unvboxed and re-vboxed multiple times. That might mess with interline spacing. – Henri Menke Dec 7 '18 at 4:03

## 1 Answer

This is essentially the same as my answer to ConTeXt: uniform line height, but with a \blank[disable,nowhite] in the beginning.

\setuppapersize[letter]

\setupwhitespace[medium]

\setuplayout
[backspace=4.375in,
width=3.625in,
leftmargin=3.625in,
rightmargin=0in,
leftmargindistance=0.25in,
%
topspace=0.25in,
height=10.5in,
header=0.25in,
headerdistance=0.25in,
footer=0.25in,
footerdistance=0.25in,
]

\setupmarginblock
[location=left,
width=\leftmarginwidth,
]

\define[1]\heading{%
\blank[big,samepage]%
\dontleavehmode{\bfc\setupinterlinespace\strut#1}%
\blank[medium,samepage]%
}

\showframe

\showallmakeup

\starttext
\startmarginblock
\vbox to \textheight {
\blank[disable,nowhite]
% discard leading vertical space
\heading{Left 1}
\samplefile{ward}

\heading{Left 2}
\samplefile{knuth}

\samplefile{weisman}

\heading{Left 3}
\startitemize
\item 1
\item 2
\item 3
\stopitemize
\samplefile{ward}
% fill up the box
\strut\par\vfill
}
\stopmarginblock

\heading{Right 1}
\samplefile{ward}

\heading{Right 2}
\samplefile{knuth}

\samplefile{weisman}

\heading{Right 3}
\startitemize
\item 1
\item 2
\item 3
\stopitemize
\samplefile{ward}
\stoptext