How can I remove parens around specific citations?

I’ve got a document using this citation style, which has references in parentheses. eg:

But sometimes, when citations are within existing parentheses, I’d prefer to not add additional parentheses, eg

Is there a way to accomplish this? I thought there might be a way to hijack the supplement argument to put the other text (eg “as reviewed in”), but couldn’t figure it out.

Usually one the form parameters of #cite() could achieve this but it seems not with this particular style. The easiest way right now then would be wrapping the normal citation in a function and remove the parentheses with a regex.

#let no-paren-cite(label) = {
  show regex("\(|\)"): none
  cite(label, form: "normal") 
}

See @xyz (reviewed in #no-paren-cite(<abc>)
#no-paren-cite(<def>))
1 Like

Ooh, clever idea, but it doesn’t seem to work. I wonder if the outer parens are getting added after the regex processing (I’m on the development version if that matters - I need the new line numbers functionality).

I also tried

#let no-paren-cite(cites) = {
  show regex("\(|\)"): none
  for c in cites {
    cite(c, form: "normal")
  }
}

and then cited as no-paren-cite((<abc>, <def>))
just to see if it was something about the combination, but I’m still getting the same result.

Hmm - actually this does seem to matter. I just tried it on 0.10.1 0.11.1 and it works (both your version and my loop).

Edit: On the development version, even putting #show regex("\(|\)"): none outside a function removes all of the manually entered parens, but all of the citation parens remain intact.

Is this a known issue?

Yeah I could’ve told you that it’s a new issue since I tested it before answering ^^ It is suspicious though and a million things could be the reason for it. New text show rules, internal layout reworks and citation group changes — probably best to create an issue.

1 Like

Looks like a bug with the new text show rule processing. Minimized:

#show "[": none
@netwok A
#bibliography("works.bib")
2 Likes

I’ve opened Text show rules on citations are broken · Issue #5090 · typst/typst · GitHub

2 Likes

Amazing, thanks! This is an initial submission, so i think I can live with the doubled up parentheses while this gets worked out. Thank you!

That’s probably me projecting - I have not infrequently answered questions on similar forums, certain I know how something should behave and being wrong about it :smile:. Appreciate the help!

1 Like

Typst doesn’t have a 0.10.1 version, only 0.10, 0.11, 0.11.1. This is probably a typo for 0.11.1.

1 Like

There is now a fix for this issue in the most recent development version.

2 Likes

Correct, edited.

Amazing, thanks for the rapid response everyone!

Edit: confirming that @xkevio 's original answer now works on the latest development version :pray:. There doesn’t seem to be a way to mark an answer as answer like there is on some discourse forums - is that because I asked in General instead of Questions, or is that feature just not enabled?

There should be a way to mark an answer as a Solution as you can see in the Questions category but yeah maybe it’s because of the category this is in — this thread should probably be moved anyway.

1 Like

Because the topic is in the General category.

1 Like