Skip to content

Format table based on caption #4004

Answered by Mc-Zen
lettuceDestroyer asked this question in Q&A
Discussion options

You must be logged in to vote

This can be achieved with the following code

#show figure.where(kind: table) : it => {
  if it.caption.body.text.contains("TableType 1") {
      show table.cell.where(y: 0): strong
      // set align(center) // this is what we need to omit 
      it.body
      v(it.gap, weak: true)
      it.caption
  } else {
    it
  }
}
  1. First, we select upon the caption containing "TableType 1".
  2. Now we employ a show rule that will make the table headers bold.
  3. Finally, we build up the figure by recreating almost the original figure setup. We just omit the alignment.

Note that this code has one caveat: Now, figure(placement: auto/top/bottom) will not work anymore for this table. This is unfortunate but …

Replies: 1 comment 8 replies

Comment options

You must be logged in to vote
8 replies
@Mc-Zen
Comment options

@Mc-Zen
Comment options

@lettuceDestroyer
Comment options

@Mc-Zen
Comment options

Answer selected by lettuceDestroyer
@Mc-Zen
Comment options

@lettuceDestroyer
Comment options

@Mc-Zen
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants