11

Background

I would like to add a thick rule centered between two columns.

Example Code

A minimum working example that illustrates the issue:

\setupcolors[state=start]

\startuseMPgraphic{StyleVerticalRule}
  thickness := 6.50pt;

  if CurrentColumn < NOfColumns :
    setbounds currentpicture to OverlayBox
      shifted( -3*thickness, 0 );

    draw rightboundary OverlayBox
      withpen pensquare scaled thickness
      withcolor \MPcolor{red};
  fi
\stopuseMPgraphic

\defineoverlay[StyleVerticalRule][
  \useMPgraphic{StyleVerticalRule},
]

\definecolumnset[StyleColumns][
  n=2,
  background=StyleVerticalRule,
]

% Horizontal line below the section header.
\define[2]\StyleSection{%
  \framed[
    frame=off,
    bottomframe=on,
    framecolor=pink,
    rulethickness=1.0pt,
    width=local,
  ]{\vbox{#2}}}


\setuphead[section][
  command=\StyleSection,
  after={\startcolumnset[StyleColumns]},
  aftersection={\stopcolumnset},
]

\starttext
\startbodymatter
  \startchapter[title={Chapter}, reference=sec:my-chapter,]
  \startsection[title={Section}, reference=sec:my-section,]
  \startsubsection[title={Equipment},reference=sec:my-equipment,]
    \input knuth
    \input knuth
  \stopsubsection
  \stopsection
  \stopchapter
\stopbodymatter

\stoptext

Problem

The vertical rule height appears to be \textheight, rather than height of the columns. The code above produces:

Over Extended Rule

The vertical rule extends beyond the subsection header because, I think, it references OverlayBox. I would like to use the column height, not the text height, to produce:

Perfectly Extended Rule

Questions

With respect to multi-column layouts:

  • How do you restrict the height of the vertical rule so that it respects the column height (i.e., how do you determine the column height)?
  • How would you add sufficient space to the section's column margins so that the vertical rule does not overlap any text?
  • What is the required calculation to ensure the vertical rule is centered between the columns (i.e., -3*thickness seems... incorrect)?

I also could not find any definition for OverlayBox, although I found a few examples.

Related

Information that is somewhat related:

8
+250

When using columnsets, your entire page design must be done using columnsets. So, if you want chapter or section heads to span the entire page, you will have to define a columnspan.

For simple two column documents, you can use \startcolumns ... \stopcolumns, or its MkIV replacement \startmixedcolumns ... \stopmixedcolumns. Here is an example:

\setupcolors[state=start]

\startuseMPgraphic{StyleVerticalRule}
  draw OverlayBox;
\stopuseMPgraphic

\defineoverlay[StyleVerticalRule][\useMPgraphic{StyleVerticalRule}]

\definemixedcolumns
  [sectioncolumns]
  [
    n=2, 
    separator=rule,
    rulecolor=red,
    rulethickness=6.5pt,
    balance=yes,
  ]

\setupalign[verytolerant,stretch,hanging]

% Horizontal line below the section header.
\defineframed[sectionframed]
             [
               frame=off,
               bottomframe=on,
               framecolor=pink,
               rulethickness=1.0pt,
               width=local,
               align=normal, % to get a vbox
             ]

\define[2]\StyleSection{\sectionframed{#2}}

\setuphead
    [section]
    [
      command=\StyleSection,
      after={\startsectioncolumns},
      aftersection={\stopsectioncolumns},
    ]

\starttext
\startchapter[title={Chapter}, reference=sec:my-chapter,]
  \startsection[title={Section}, reference=sec:my-section,]
      \startsubsection[title={Equipment},reference=sec:my-equipment,]
        \input knuth
        \input knuth
      \stopsubsection
  \stopsection
\stopchapter

\stoptext

which gives

enter image description here

  • 1
    Use distance=<dim> to change the distance between columns. BTW, "significantly" overflows the column width because TeX cannot find a good spot to hyphenate the word. You can get a slightly better hyphenation by using align=tolerant. To add space before the columns use before={\blank[medium]}. – Aditya Sep 1 '13 at 17:42
  • Mixed columns do not accept a align key. You have to set the alignment using \setupalign. – Aditya Sep 27 '13 at 3:12
  • Is there a key to specify the width of a specific column? (\setupmixedcolumns[mycolumns][1][width=5em] doesn't work.) – Maggyero Jun 8 '15 at 8:31

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.