3

I have a table in ConTeXt. It has fixed width. The first row has some grouping. And I get strange extra newline in there. I can tell the text perfectly fits yet there is this extra space.

Here is my code:

\setuppapersize[A4]

\startdocument


{\bTABLE[width=.2\textwidth]
\bTR \bTD[nc=2]  Vasdasdsa asdasdasdsda asda \eTD \bTD[nc=2] Vasdasdsa asdasdasdsda asda \eTD \eTR
\bTR \bTD sdeefdf \eTD \bTD sdeefdf \eTD \bTD sdeefdf \eTD \bTD sdeefdf \eTD \eTR
\eTABLE}

\stopdocument

Here is what I get: enter image description here

Why this is happening and how to prevent this?

I have a lot of very complex tables with fancy colorful designs. I am tasked to implement them with a TeX-like markup language to auto-generate PDFs in batches. I was trying to use LaTeX and faced lots of issues. So I tried ConTeXt thinking it may be more robust. It feels like I am doing something wrong. I used to use HTML/CSS a lot. With CSS I could have implemented this long ago.

2
  • Welcome to tex.sx. It's very likely that this is caused by the space between the last asdf} \eTD and the extra space was just too wide to fit on the line, going instead to a visually blank line below. Mar 10, 2021 at 21:45
  • @barbarabeeton I tried removeing it and I even removed one 'asda' word at the end of both cells. Yet the problem is still there. I suspect that \definedfont requires some form of termination to properly recalc line heights/widths but don't know how to do it.
    – Gherman
    Mar 10, 2021 at 21:51

1 Answer 1

4

This is due to an interference caused by width=0.2\textwidth. I don't completely remember the algorithm used by ConTeXt for determining height and width of the table, but what is happening is that the height of the cell is calculated before nc=2 is applied (or that is how it appears to me).

To work around that, add width=fit (which is the default value) for cells where you specify nc=2. So, the following works (and continues to work correctly when the first line does not fit in a single line):

\starttext

\bTABLE[width=0.2\textwidth]
\bTR 
  \bTD[nc=2,width=fit] Vasdasdsa asdasdasdsda asda \eTD 
  \bTD[nc=2,width=fit] Vasdasdsa asdasdasdsda asda \eTD 
\eTR
\bTR 
  \bTD sdeefdf \eTD 
  \bTD sdeefdf \eTD 
  \bTD sdeefdf \eTD 
  \bTD sdeefdf \eTD 
\eTR
\eTABLE

\stoptext
2
  • It solves the problem for a moment. However if I start using setupTABLE to change widths of individual columns then it starts crumbling apart again. It starts to work fine again if I set width of every cell and stop using setupTABLE.
    – Gherman
    Mar 11, 2021 at 13:28
  • Could you post a minimal example showing the issue
    – Aditya
    Mar 12, 2021 at 6:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .