Changes

Jump to navigation Jump to search
1,473 bytes added ,  18:26, 18 August 2014
New section to point out an alignment issue
[[Category:XML]]
tt>\bTD
 
= An alignment issue =
 
In some cases the alignment of cell contents may not behave as you might expect. Here is an illustrative example. The following code
 
<context source=yes mode=mkiv text="gives us:">
\define[3]\Glyphbox
{\framed[frame=on,align=middle]\bgroup
#1\\
#2\\
#3%
\egroup}
 
\starttext
\setupTABLE[frame=on,align=middle]
\bTABLE
\bTR \bTD \Glyphbox{I}{a}{1} \eTD
\bTD \Glyphbox{I}{a}{1} \eTD
\eTR
\bTR \bTD \Glyphbox{III}{aaa}{111} \eTD
\bTD \Glyphbox{III}{aaa}{111} \eTD
\eTR
\eTABLE
\stoptext
</context>
 
Note that in the first row the cells are not middle-aligned. As Wolfgang Schuster pointed out on the list, we need *two* things to fix this:
 
1. You need <tt>\dontleavehmode</tt> in front of the <tt>\framed</tt>.
2. You need <tt>\setupTABLE[start][..,..=..,..]</tt> because <tt>\bTABLE</tt> sets a default value for the align key which can’t be overwritten with a simple <tt>\setupTABLE[..,..=..,..]</tt>.
 
Implementing this <context source=yes mode=mkiv text="we now get the following correct output with centered cells in the first row:">
\define[3]\Glyphbox
{\dontleavehmode
\framed[frame=on,align=middle]\bgroup
#1\\
#2\\
#3%
\egroup}
 
\starttext
\setupTABLE[start][frame=on,align=middle]
\bTABLE
\bTR \bTD \Glyphbox{I}{a}{1} \eTD
\bTD \Glyphbox{I}{a}{1} \eTD
\eTR
\bTR \bTD \Glyphbox{III}{aaa}{111} \eTD
\bTD \Glyphbox{III}{aaa}{111} \eTD
\eTR
\eTABLE
\stoptext
</context>
67

edits

Navigation menu