Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 3 down vote accepted

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.

share|improve this answer
    
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 –  Taco Hoekwater 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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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