Am Donnerstag, 19. September 2024, 09:35:49 MESZ schrieb Hans Hagen via ntg-context:
On 9/19/2024 7:54 AM, Mikael Sundqvist wrote:
Hi,
On Thu, Sep 19, 2024 at 12:23 AM Gerion Entrup
wrote: Am Mittwoch, 18. September 2024, 22:53:55 MESZ schrieb Wolfgang Schuster:
Gerion Entrup schrieb am 18.09.2024 um 14:44:
Am Dienstag, 17. September 2024, 20:36:23 MESZ schrieb Gerion Entrup:
Hi,
I want to typeset a table where some of the column headings are really long, while in the columns itself consists only of numbers. Therefore, my idea was to rotate the column headings but not 90 degrees (I found some solutions for that) but 45 degree.
It then would be beneficial to push together the rotated cells, so the text of one cell actually starts above the previous cell. Do you know, how to achieve that?
Here is a minimal example: ``` \startsetups[table:rotated] \setupTABLE[frame=off] \setupTABLE[row][first][bottomframe=on, style=bf, align={center, low}] \setupTABLE[row][2][align=flushright] \stopsetups
\starttext \define\tablerotate{\dontleavehmode\rotate[rotation=-45, location=high]} \bTABLE[setups=table:rotated] \bTR \bTD \eTD \bTD \tablerotate{Water buffalo} \eTD \bTD \tablerotate{Mexican redknee tarantula} \eTD \bTD \tablerotate{European turtle dove} \eTD \eTR \bTR \bTD Amount of legs \eTD \bTD \digits{4} \eTD \bTD \digits{8} \eTD \bTD \digits{2} \eTD \eTR \eTABLE \stoptext ``` I would like to achieve that the text "Mexican redknee tarantula" is typeset right and above of "Water buffalo" so that the single columns have a width that is similar to the width of the single digit coming in the second row.
To visualize this, I patched the PDF of the above example to the desired result. See the attachment.
You can use Metapost.
Thanks for this solution. It, however, seems to fail with any other angle than 315° (I tested 305, 325 and 314).
Try
xyscaled(\the\struttotal,abs(sind(\MPvar{rotation}))*\the\widthofstring{\MPvar{text}});
with sind instead of sin. And maybe with abs around it, but one can think of improvements for smaller angles. It all depends on what one wants.
here is an alternative
\bTABLE[frame=off] \bTR[align={middle,low}] \bTH \eTH \bTH \dontleavehmode\kern1.5em\llap{\rotate[rotation=315,frame=on]{\strut Water buffalo}\hss} \eTH \bTH \dontleavehmode\kern1.5em\llap{\rotate[rotation=315,frame=on]{\strut Mexican redknee tarantula}\hss} \eTH \bTH \dontleavehmode\kern1.5em\llap{\rotate[rotation=315,frame=on]{\strut European turtle dove}\hss} \eTH \eTR \bTR[frame=on,align=middle] \bTD Amount of legs \eTD \bTD[width=3em] 4 \eTD \bTD[width=3em] 8 \eTD \bTD[width=3em] 2 \eTD \eTR \eTABLE
What is the meaning of \hss here? It seems to work just fine without it. Gerion