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).
\startuseMPgraphic{tableheader}{text,rotation}
label.lft("\strut\bf\MPvar{text}",origin) rotated \MPvar{rotation} shifted (\the\strutht,0);
I guess, this one actually draws the text...
setbounds currentpicture to unitsquare
xyscaled(\the\struttotal,sin(\MPvar{rotation})*\the\widthofstring{\MPvar{text}});
and this one calculates the faked width. Doesn't the sinus here calculate the height of the rotated text? Beside from using Metapost (since I currently do not understand it and would only be able to copy paste your code), is there some kind of box construct which artificially reduces the width of the inner content? I would have expected something like \fakewidth[width=1cm, align=flushright]{\rotate[rotation=-45, location=high]{A really long text, much longer than 1cm}}. If I see it right, such a construct would also solve the problem, while less cleaner due to the fixed width. Gerion