85

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.

1
  • 5
    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
    Commented Apr 19, 2016 at 15:43

3 Answers 3

109

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.

8
  • 63
    You need to escape them in some way if it comes after a LaTeX command accepting options. @Qaswed's suggestion, {[ ]}, works nicely then.
    – Eusebius
    Commented Aug 21, 2017 at 12:37
  • 5
    @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
    Commented Aug 21, 2017 at 13:17
  • 1
    To whoever downvoted; why?
    – sodd
    Commented Aug 22, 2017 at 8:30
  • 1
    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.
    – user6853
    Commented Dec 27, 2017 at 22:49
  • 2
    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.
    – Mr. Tao
    Commented Jul 15, 2018 at 11:13
71

You also could try this: {[2007]}

5
  • 7
    It works, but the braces { and } are redundant unless this comes first in a row of a tabular.
    – egreg
    Commented Jul 14, 2017 at 12:53
  • 7
    It is also useful after other commands, for instance if you want to add square brackets right after an \item.
    – Eusebius
    Commented Aug 21, 2017 at 12:35
  • 1
    @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.
    – Mr. Tao
    Commented Jul 15, 2018 at 11:18
  • 1
    @Mr.Tao “It comes first in a row”, not “it starts the first row”.
    – egreg
    Commented Jul 15, 2018 at 11:28
  • 1
    This is also useful in a Beamer \structure environment Commented Jul 13, 2020 at 16:31
26

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

2
  • 1
    Only in math mode!
    – basseur
    Commented Apr 8, 2019 at 12:53
  • 3
    @basseur Works perfectly fine in text mode for me.
    – Egor Hans
    Commented Dec 24, 2019 at 9:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .