0

I would like square brackets to never be italicized, even in a \textit environment. That is, I would like to type [ but have it always replaced with \textup{[}, and similarly for the right bracket. Apparently \newunicodechar doesn't work for the standard ASCII characters.

Is there some other way?

  • 4
    Related tex.stackexchange.com/q/13048/35864 – moewe Jul 14 '18 at 18:45
  • 1
    Will the square brackets only ever occur in text mode? Or will some of them occur in math mode? Please advise. – Mico Jul 14 '18 at 19:24
  • 1
    It’d be pretty straightforward to support \textit{\bracket{foo} bar}, but are you looking to make [ and ] active characters and not have the other versions available at all? – Davislor Jul 14 '18 at 19:37
  • 1
    Short answer: you can't, unless you're sure to avoid to use any optional argument to your commands. – egreg Jul 14 '18 at 21:12
  • @Mico — yes, I would only use them in text mode. Does that help? – DavidLinguist Jul 14 '18 at 22:29
1

@Moewe's comment above led to the package https://ctan.org/pkg/embrac, which does exactly this. Thank you!

Not the answer you're looking for? Browse other questions tagged or ask your own question.