3

How can one create a diagonal separator in a table corner in ConTeXt (like the package slashbox for LaTeX)?

3

Here is a solution based on natural tables:

\startuseMPgraphic{DiagonalRule}
draw (0,OverlayHeight) -- (OverlayWidth,0);
clip currentpicture to OverlayBox; % otherwise the rule overlaps the table frame
\stopuseMPgraphic

\defineoverlay
  [DiagRule]
  [\useMPgraphic{DiagonalRule}]

\setupTABLE [1] [1] [background=DiagRule]

\starttext
\bTABLE
\bTR \bTD   \eTD   \bTD col   \eTD \eTR
\bTR \bTD row \eTD \bTD value \eTD \eTR
\eTABLE
\stoptext

The nice thing about natural tables is that the background of a cell can be just about anything. In this case, I am using a simple metapost graphic that draws a diagonal line.

3
  • There is an anonymous edit suggestion for this answer which states to add clip currentpicture to OverlayBox; just before \stopuseMPgraphic because "otherwise the rule overlaps the table frame". Instead if approving it I add it here as comment so you can decide it for yourself.
    – Martin Scharrer
    Mar 2 '11 at 12:09
  • @martin: yes, that makes sense, will edit Mar 2 '11 at 12:24
  • thanks, that's nice. Is it possible to add headings to be separated by the diagonal too? Like having row\col in in top left table corner only.
    – urso
    Mar 3 '11 at 16:25

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.