Changes

Jump to navigation Jump to search
1,475 bytes added ,  15:52, 31 August 2012
Add section about diagonal rules
See the corresponding thread on the list: [http://www.ntg.nl/pipermail/ntg-context/2011/058549.html rules with different thickness]
 
== Diagonal rules ==
 
Sometimes a diagonal rule is required in the top left corner cell of a table to create two fields, one for the left column and one for the top row.
 
 
<context mode="mkiv" source="yes" text="Gives:">
\startuseMPgraphic{DiagonalRule}
rulethickness := \frameddimension{rulethickness};
 
drawoptions(
withpen pencircle scaled rulethickness
withcolor \MPcolor{\framedparameter{framecolor}});
 
pair leftcorner, rightcorner;
leftcorner := (rulethickness, \overlayheight-rulethickness);
rightcorner := (\overlaywidth-rulethickness, rulethickness);
 
draw leftcorner -- rightcorner;
\stopuseMPgraphic
 
\defineoverlay
[DiagonalRule]
[\useMPgraphic{DiagonalRule}]
 
\define[2]\DiagonalLabel{%
\setuptabulate [after={\blank[\frameddimension{offset}]}]
\starttabulate [|p|r|]
\NC \NC #2 \NC\NR
\NC #1 \NC \NC\NR
\stoptabulate
}
 
\starttext
\setupTABLE [row] [1] [width=2cm]
\bTABLE
\bTR
\bTD [background=DiagonalRule]
\DiagonalLabel{Foo}{Bar}
\eTD
\bTD Second \eTD
\bTD Third \eTD
\eTR
\bTR
\bTD Alpha \eTD
\bTD Beta \eTD
\bTD Gamma \eTD
\eTR
\eTABLE
\stoptext
</context>
 
This solution has (at least) one caveat: Because the first
tabulate column is set in paragraph mode, it will eat up as much
space as <em>possible</em>, in contrast to occupying as much space as
</em>necessary</em>. That is why the width of the column has to be set
explicitly.
== Using character alignment ==
69

edits

Navigation menu