Skip to content

Commit 64fe8d6

Browse files
authored
fix issue with two rowspans next to each other (#139)
1 parent 6bcb1e0 commit 64fe8d6

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

filter/tabularx.lua

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,14 @@ function TabularRow(height, colspecs, skips, rows_with_rowspans, row, i, plain,
8686
local clines_code = ''
8787
local any_skips = false
8888
if not plain and (i > 1 or not no_first_hline) then
89-
for j = 1,width do
89+
local j = 1
90+
while j <= width do
9091
if skips[(i-1)*width + j] then
9192
any_skips = true
93+
j = j + skips[(i-1)*width + j]
9294
else
9395
clines_code = clines_code .. string.format("\\cline{%d-%d}", j, j)
96+
j = j + 1
9497
end
9598
end
9699
-- Simplify a whole row of clines as just an hline.
@@ -115,10 +118,7 @@ function TabularRow(height, colspecs, skips, rows_with_rowspans, row, i, plain,
115118
-- Even more complicated: We may need to put a multicolumn here (in the event that there are multiple
116119
-- skipped cells in a row).
117120
local skipstart = j
118-
local skipend = j
119-
while skips[(i-1)*width + skipend+1] do
120-
skipend = skipend + 1
121-
end
121+
local skipend = j + skips[(i-1)*width + j] - 1
122122
if skipstart == skipend then
123123
table.insert(row_code, ' ')
124124
else
@@ -177,9 +177,7 @@ function TabularRow(height, colspecs, skips, rows_with_rowspans, row, i, plain,
177177
-- tabularx/multirow/multicolumn want us to NOT provide empty "& &" cells after a multicolumn.
178178
-- Multirow cells DO need empty "& &" cells populated.
179179
for skipi=i+1,i+cell.row_span-1 do
180-
for skipj=j,j+cell.col_span-1 do
181-
skips[(skipi-1)*width + skipj] = true
182-
end
180+
skips[(skipi-1)*width + j] = cell.col_span
183181
end
184182
end
185183

guide.tcg

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,6 +1363,20 @@ Table: Informative {#tbl:informative-grid}
13631363
| Banana | Yellow | No |
13641364
+-------------+--------+----------------------------+
13651365

1366+
Table: Two Rowspans {#tbl:two-rowspans}
1367+
1368+
+----------------------+----------------------------+
1369+
| Fruit and Color | Mistaken for Vegetable |
1370+
+=============+========+============================+
1371+
| | Red | No |
1372+
| Apple + +----------------------------+
1373+
| | | No |
1374+
+-------------+--------+----------------------------+
1375+
| Tomato | Red | Yes |
1376+
+-------------+--------+----------------------------+
1377+
| Banana | Yellow | No |
1378+
+-------------+--------+----------------------------+
1379+
13661380
Table: Equation {#tbl:equation-grid}
13671381

13681382
+----------------------+----------------------------+

0 commit comments

Comments
 (0)