# Using square bracket in text mode

I would like to include text like the following in a latex document [2007] EWCA Civ 1042.

Unfortunately if I use $2007$ EWCA Civ 1042 the number within the square brackets is typeset on a separate line. $ must mean something I don't know. How do I escape a square bracket? I realise this may be a stupid question, but the only way to escape things I know of is backslash. • You don't have to escape square brackets in text mode, just write [2007] EWCA Civ 1042. \[ and $ start and end a displayed math equation, similar to \begin{equation*} and \end{equation*}.
– sodd
Apr 19 '16 at 15:43

You don't escape square brackets in LaTeX if you want them typeset. $ and $ are basically synonyms for \begin{displaymath} and \end{displaymath}, (or \begin{equation*} and \end{equation*} with amsmath loaded), and will make the enclosed content typeset in a unnumbered displayed math equation on a separate line, which is clearly not what you want.

In conclusion you should simply write

[2007] EWCA Civ 1042


verbatim to get the output

[2007] EWCA Civ 1042

Edit: As noted in the comments, this will not work in the special cases where the brackets follow a macro (as in \item [2007] EWA) or if it comes first in a row in a tabular. In these situations one should group the brackets inside braces as {[2007]} EWA.

• You need to escape them in some way if it comes after a LaTeX command accepting options. @Qaswed's suggestion, {[ ]}, works nicely then. Aug 21 '17 at 12:37
• @Eusebius Technically, that's not escaping the square brackets, as they are not special characters. Placing them inside a {} group effectively hides them from the TeX token scanner, which can be necessary in certain situations. But I agree, it's a valid point when it comes to tabular or after macros.
– sodd
Aug 21 '17 at 13:17
• To whoever downvoted; why?
– sodd
Aug 22 '17 at 8:30
• This answer is basically wrong, for the reasons given by Eusebius. If you don't surround the square brackets with curly brackets, you end up with something that may work originally, but then when you make a change (e.g., defining a new command) will end up failing with one of tex's notoriously unhelpful error messages. Dec 27 '17 at 22:49
• I think that stressing out hypothetical and special cases together with putting it in a footnote does not quite reflect solid tangibility of this issue. I’ve hit it just now while trying to typeset regex class [:alnum:] in a tabular environment and I would have missed it here if it would not be for @Eusebius much-upvoted comment. Jul 15 '18 at 11:13

You also could try this: {[2007]}

• It works, but the braces { and } are redundant unless this comes first in a row of a tabular. Jul 14 '17 at 12:53
• It is also useful after other commands, for instance if you want to add square brackets right after an \item. Aug 21 '17 at 12:35
• @egreg It does not necessarily have to be the first line of tabular. I’ve encountered this issue with booktabs having [:alnum:] in the second row of the table. Jul 15 '18 at 11:18
• @Mr.Tao “It comes first in a row”, not “it starts the first row”. Jul 15 '18 at 11:28
• This is also useful in a Beamer \structure environment Jul 13 '20 at 16:31

If [ and ] are causing trouble, just switch them out for \lbrack and \rbrack.

• Only in math mode! Apr 8 '19 at 12:53
• @basseur Works perfectly fine in text mode for me. Dec 24 '19 at 9:48