-
I would like to define a table template where the first two and the last hlines are black while the rest of the hlines are grey, like in the screenshot: This is how I've been able to achieve that: #import "@preview/tablex:0.0.7": tablex, hlinex, cellx
#let ktable(..cells) = tablex(
auto-vlines: false,
map-hlines: v => (
if v.y > 1 and v.y < 5 {
return (..v, stroke: color.rgb("#CCC"))
}
else {
return (..v, stroke: color.rgb("#000"))
}
),
columns: (auto, auto, auto),
header-rows: 1,
[*Col 1*],
[*Col 2*],
[*Col 3*],
..cells,
)
#ktable(
[#lorem(2)],
[#lorem(2)],
[#lorem(2)],
[#lorem(2)],
[#lorem(2)],
[#lorem(2)],
[#lorem(2)],
[#lorem(2)],
[#lorem(2)],
[#lorem(2)],
[#lorem(2)],
[#lorem(2)],
) This piece of code works, but only if there are exactly five rows in the table, or else the condition I tried replacing it with a method like |
Beta Was this translation helpful? Give feedback.
Answered by
PgBiel
Jan 11, 2024
Replies: 1 comment 1 reply
-
Try this: #let ktable(..cells) = tablex(
auto-vlines: false,
map-hlines: h => {
if h.stroke == auto {
h.stroke = color.rgb("#CCC")
}
h
},
columns: (auto, auto, auto),
header-rows: 1,
[*Col 1*],
[*Col 2*],
[*Col 3*],
..cells,
hlinex(stroke: color.rgb("#000"))
) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
maxigaz
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try this: