0

Returning to this example, I would like to change the "Left 1" \heading to a \subheading while keeping the two "Left 1", "Right 1" headings vertically lined-up. And assuming ConTeXt: uniform handling of whitespace in margin and text is solved, also keeping the subsequent paragraphs aligned. I've been playing around with vertical \heading struts to no avail, but perhaps line correction could also work. Though not clear, the documentation suggests it 'snaps' its argument to the nearest baseline.

\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]%
}

\define[1]\subheading{%
    \dontleavehmode{\bfa\setupinterlinespace\strut#1}%
    \blank[small,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

Edit:

I was trying to achieve something like this:

columns after

Or like this:

before-after (non-column)

In retrospect I have no problem implementing a simpler approach:

\define[1]\headinghmode{%
    \bfc\setupinterlinespace\strut#1%
}

\define[1]\subheadinghmode{%
    \bfa\setupinterlinespace\strut#1%
}

\define[1]\heading{%
    \dontleavehmode{\headinghmode{#1}}%
    \blank[big,samepage]%
}

\define[1]\subheading{%
    \dontleavehmode{\subheadinghmode{#1}}%
    \blank[small,samepage]%
}

And using it like:

\heading{\subheadinghmode{Interlude}}

Before I was trying to avoid any reuse of my original (see above) heading definitions. For example I would insert either \blank[back] or \blank[disable] in all possible locations of the following lines, where ... represents non-TeX text:

\heading{}\subheading{...}
\heading{\subheading{...}
\subheading{\heading{}...}

For example:

\heading{\blank[back]}\subheading{...}
\heading{}\blank[back]\subheading{...}
\heading{}\subheading{\blank[back]...}
\heading{}\subheading{...\blank[back]}
\heading{}\subheading{...}\blank[back]

\blank[disable]\heading{}\subheading{...}
...
\heading{}\subheading{...\blank[disable]}

\heading{\blank[back]\subheading{...}}
...
\heading{\subheading{...}\blank[disable]}

\subheading{\heading{}\blank[back]...}
...
\subheading{\heading{}...}\blank[disable]

Now this (mostly) didn't work, probably because they're stacked vertically outside of h-mode. That's fine because who wants to remember to place that extra \blank[back] or \blank[disable]? That said I did test them all because accidentally I came across one that works, but only in a margin block (first picture):

\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,
    ]

\showframe

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

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

\define[1]\subheading{%
    \dontleavehmode{\bfa\setupinterlinespace\strut#1}%
    \blank[small,samepage]%
}


\starttext
    \startmarginblock
        %\heading{Left 1}
        \heading{\subheading{Left 1}}
        \samplefile{ward}
    \stopmarginblock

    \heading{Right 1}
    \samplefile{ward}
\stoptext

That makes no sense... Why would this work, and only in a margin block?

\heading{\subheading{...}}

Anyway of all possible combinations I tested this is the only other one to work, and in either the main text or the margin:

\heading{\subheading{...\blank[back]}}

I don't understand, given all the other possible and likely combinations, why only that worked.

I also tried some even more extreme approaches. This one can't work without a second "disable \blank" parameter, and I didn't feel like digging through ConTeXt to figure out how to implement optional parameters:

\define[1]\heading{%
    ...
    \if\relax\detokenize{#1}\relax \else \blank[big,samepage] \fi%
}

And this one can't reproduce the vertical position of the heading, but the before/after whitespace should remain unchanged. Something's not working:

\heading{...}
\setbox0=\vbox{\heading{...}}
\vrule height 0.7\ht0 depth 0.3\ht0 width 1pt\subheading{...}

Though I'm curious how my two exceptions manage to work, the simpler approach is best.

  • 3
    How about just using grid typesetting? – Henri Menke Dec 7 '18 at 8:04
  • @HenriMenke I looked into "It's in the Details" and I couldn't find any information on enabling grid typesetting for select elements. I don't want grid typesetting enabled for the entire document as it would ruin inter-paragraph and itemgroup spacing. – user19087 Dec 10 '18 at 1:31
3

If you want the exact same spacing in the margin block as in the main vertical list, then you have to “simulate” a page in the margin. What do I mean by this? The content in the margin is typeset in a vbox at natural height. This means that vertical glue has neither be stretched nor shrunk, whereas the main vertical list is constrained by \vsize. Thus, to simulate the main vertical list in the margin you have to wrap its contents in \vbox to \textheight {...\strut\par\vfill}. The \strut ensures that the last line has strut depth, \par switches to vertical mode, and \vfill fills up the box to the bottom if the content is shorter than \textheight.

\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]%
}

\define[1]\subheading{%
  \dontleavehmode{\bfa\setupinterlinespace\strut#1}%
  \blank[small,samepage]%
}

\showframe

\starttext
\startmarginblock
  \vbox to \textheight {
    \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

enter image description here

  • How do I replace \heading{Left 1} with \subheading{Left 1} without changing the vertical whitespace of that specific line? – user19087 Dec 11 '18 at 4:23
  • @user19087 By using \subheading{{\bfc\setupinterlinespace\strut}Left 1}. – Henri Menke Dec 11 '18 at 4:28
  • That uses \blank from subheading rather than heading - I literally want to make the "Left 1" text the size of a subheading without changing any vertical whitespace, either before or after. That also requires synchronizing with the definition of \heading. – user19087 Dec 11 '18 at 22:21
  • I've tried many combinations of \heading and \subheading with \blank[back] or \blank[disable] (these two either introduce much more vertical space before the heading, or discard only the smaller \blank) and \strut and even ifx\relax\detokenize{#1}\relax {} \else \blank[small,samepage] \fi... but it turns out all along the solution is \heading{\subheading{Left 1}}, which makes no sense! Why are the adjacent \blanks collapsed? Adjacent \vskips don't behave this way at all - they're added, not collapsed. (this was my main question actually) – user19087 Dec 11 '18 at 22:23
  • By the way very nice solution, I extended it to: \definestartstop[marginpage][before={\startmarginblock\vbox to \textheight\bgroup},after={\strut\par\vfill\egroup\stopmarginblock}] – user19087 Dec 11 '18 at 22:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.