# Ensuring non-italicization of a character [duplicate]

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?

• – moewe Jul 14 '18 at 18:45
• 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
• 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
• 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