How to suppress space between affiliation superscript name and comma in custom template?

Hi @danborek,
I marked the lines where you have the problem:

      let author_string = [ // <-- Here
        #box[
          #if authors.len() > 1 {
            a.name
            super(author_affiliation)
          } else {
            a.name
          }
        ]
      ] // <-- And here is your problem

To demonstrate your problem I created a minimal example.

Example
#repr(
[// <-- Here
  #box()[test]
]// <-- And here
)

Which results in the following:
test
Notice the single space content [ ] before and after the block.

To fix it in your example you can either replace the square brackets with curly braces and remove the hash symbol of the block or simply remove the brackets and start with the block directly after the equal, like you did five lines above with the if.

let author_string = box[
  #if authors.len() > 1 {
    a.name
    super(author_affiliation)
  } else {
    a.name
  }
]

I would generally recommend to use curly braces while scripting and use square brackets only when they make sense.

Edit: I just noticed you don’t even need the box.
Edit Edit: added the box back in to keep the name and affiliation together.

let author_string = if authors.len() > 1 {
  box(a.name + super(author_affiliation))
} else {
  a.name
}
2 Likes