83

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.

sodd
  • 5,771
  • 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 Apr 19 '16 at 15:43

3 Answers3

107

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.

sodd
  • 5,771
  • 60
    You need to escape them in some way if it comes after a LaTeX command accepting options. @Qaswed's suggestion, {[ ]}, works nicely then. – Eusebius Aug 21 '17 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 Aug 21 '17 at 13:17
  • 1
    To whoever downvoted; why? – sodd Aug 22 '17 at 08: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. –  Dec 27 '17 at 22:49
  • @Eusebius True, added clarification about this. Thanks :) – sodd Dec 28 '17 at 12:33
  • @BenCrowell Added clarification about this, but I object to your statement about my answer being "basically wrong". If you stand by this wording, I would very much like you to point out where my answer is factually wrong. You downvoted my answer because it may fail in hypothetical special cases, which in my opinion is borderline on-topic at best. – sodd Dec 28 '17 at 12:34
  • 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 Jul 15 '18 at 11:13
  • The curly brackets are also needed after \\ even if not in a tabular environment. – Toivo Säwén Sep 19 '23 at 14:40
69

You also could try this: {[2007]}

Qaswed
  • 981
26

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

daviewales
  • 1,313