#TableX - Remove Lines on header only

38 messages · Page 1 of 1 (latest)

vagrant panther
#

I would like to have a header with a solid color background and then normal cells thereafter.

I have attached an image of the expected result (produced with the default table) and of the current result (produced with tablex).
In the second case white lines appear where the color should be solid.

The code for the tablexcase is:

  // Print the table
  tablex(
    columns: (1fr, 1fr, 2fr, 2fr, 1fr, 1fr),
    align: center + horizon,
    header-rows: 1,
    // Color the headers
    map-cells: cell => {
      // Color the cells of the first row
      if cell.y == 0 {
        cell.fill = colors.red
        cell.stroke = none
        cell.outset = 2pt
        cell.content = {
          set text(fill: white, weight: "bold", size: 0.95em)
          cell.content
        }
      }
      return cell
    },
    // Remove the lines on the header cells
    map-hlines: h => {
      if h.y in (0, 1) {
        h.stroke = none
      }
      return h
    },
    map-vlines: v => {
      v.start = calc.max(1, v.start)
      return v
    },
    // Add the content
    ..content.flatten(),
  )
}
#

@lament badge As requested I have set up a support thread.

lament badge
#

i think thats an artifact which depends on your zoom level and on your viewer

#

i dont think theres much you can do about that

#

there's no actual white line there, worth saying

#

thats why map-vlines does nothing here

#

theres really nothing there

#

it's just a visual thing with the juxtaposition of red rectangles

#

if you zoom out or use PDF export they should disappear

vagrant panther
#

You're right, opening with Chrome the issue is not there

#

So it's how the viewer is rendering them, interesting

lament badge
#

yeah

#

not sure if there's much you can do here

#

you could try to somehow draw a single rectangle across all of them

#

but idk how that would go

vagrant panther
#

Ah it's not worth it, if it's ok on chrome and other pdf viewers I will sleep at night

lament badge
#

in general though people will never see or let alone notice that

vagrant panther
#

It's only in the preview

#

Thank you for the support!

lament badge
#

yea i think you're fine

#

no problem

#

and by the way

#

in #discussions i meant to say that the tablex features are coming to typst built-in tables in the next typst version

#

so yay for that

vagrant panther
#

I was about to suggest it

#

They are so useful and generic that they should be built in

lament badge
#

lol yea

vagrant panther
#

Thank you for the contributions, I'm guessing you opened the pull requests

lament badge
#

yep

#

it's been like a month or so since it all started

#

and so far we've had great progress

#

though theres still a bit of stuff left

#

hopefully i'll be able to get all of the basic stuff in

vagrant panther
#

It's going to be a great release

lament badge
#

for sure

#

you can keep track of the discussions at #1182377294682128445

vagrant panther
#

Will do, thank you!