PgBiel / typst-tablex

More powerful and customizable tables in Typst
Apache License 2.0
371 stars 13 forks source link

Double-stroked lines #37

Open s-henao-castellanos opened 1 year ago

s-henao-castellanos commented 1 year ago

(This is not a bug, so I don't know if this is the place for feature requests. My apologies if it isn't)

In LaTeX, when one writes together several\hlines, a multiple stroked line is created. On some journal style I was trying to reproduce on typst, a double stroke is used to denote the end of the header column of the tables. Here's a minimal example:

\begin{tabular}{c|cc}
    A & B & C \\\hline\hline 
    a & b & c \\ 
    1 & 2 & 3
\end{tabular}

I was wondering if that was possible to do with tablex, as it is not possible with typst's plain #table.

I tried (...),hlinex(),hlinex(),(...) to no avail. The creation of an empty row, such as hlinex(),[],[],[],hlinex() for a 3 column table, is the only workaround I've found, but the two lines are spaced according to the inset:

#tablex(
  columns: 3,
  row-gutter: (0pt,10pt,0pt),
  auto-lines: false,
  (),vlinex(),(),
  [A],[B],[C],
  hlinex(),
  [],[],[],
  hlinex(),
  [a],[b],[c],
  [1],[2],[3]
)

which is less than desirable.

So, is this possible to do with the current tablex implementation? Or is it planned as addition in a future release?

PgBiel commented 1 year ago

Hi! This is indeed not possible yet, but is planned. (Can't say I can give you a time estimate, however, unfortunately.)

I'm not sure if that would work, but, regarding your workaround of adding an empty row, you could maybe try to change the inset of the cells inside it (though that doesn't always work very well).

Andrew15-5 commented 1 year ago

I've tried using block for outer 2nd stroke, and it only works without repeating the headers (they disappear), which is fine for someone/some tables. I've tried nesting in table instead, and it works the same way, but the bottom stroke can be at a different inset. Nesting in tablex doesn't break long table. I want to try the empty row method.

Update: No, I couldn't do it. I can't "unstroke" vertical strokes in an empty row (I think I can draw a background color stroke, but this would be even more ugly). I also couldn't add vertical strokes to all rows except 1st.

tonyddg commented 1 month ago

I tried to create a multiple stroked line by an empty colspanx occupied a whole row with a given height. My attempt seemed to be worked:

#tablex(
    columns: 3, 
    rows: (auto, ) + (2pt, ) + (auto, ) * 2, 
    auto-lines: false,

    (), vlinex(), (),
    [A], [B], [C], 

        // a double stroked
    hlinex(),
    colspanx(3)[], 
    hlinex(),

    [a], [b], [c],
    [1], [2], [3]
)

Snipaste_2024-09-11_15-13-12

Here is another example:

#tablex(
    columns: 6, 
    rows: (2pt, ) + (auto, ) * 4 + (2pt, ), 
    auto-vlines: false, auto-hlines: false, 
    align: center + horizon,

    hlinex(),
    colspanx(6)[],
    hlinex(),

    colspanx(2)[Symbol], [Value], colspanx(2)[Symbol], [Value], 
    hlinex(), 
    rowspanx(3)[Damping\ $(N dot m"/"s)$], 
    [$c_(1,2)$], [35], 
    rowspanx(3)[Stiffness\ $(N dot m)$], 
    [$k_(1,2)$], [63.66], 
    (), [$c_(3,4)$], [15], (), [$k_(3,4)$], [79.57], 
    (), [$c_(5,6)$], [3], (), [$k_(5,6)$], [33.66], 

    hlinex(),
    colspanx(6)[],
    hlinex(),
)

Snipaste_2024-09-11_15-30-32