Is possible to instruct LaTeX to surround all cross-references with square brackets? For example when I write a command like some text \ref{some label} then when compiled I would like the output to be some text [12] without manually placing square brackets in the LaTeX input, as though I had entered some text [\ref{some label}].

  • 1
    Welcome to TeX.SE. Do you want all cross-references to be surrounded by square brackets? Or just selected ones? And, do you load any cross-referencing packages (such as as varioref, hyperref, and cleveref)? – Mico Jul 3 '18 at 5:58

The \ref command is a low-level LaTeX instruction, and it is modified heavily by various packages, including hyperref and cleveref. I therefore wouldn't modify \ref directly, mainly to avoid all kinds of unpredictable conflicts with packages that a user may load. Instead, I suggest setting up a new macro called, say, \sbref (short for "square brackets \ref, I suppose) that invokes \ref:


If all cross-references generated by \ref in your document should be surrounded by square brackets, simply perform a global search and replace operation in your text editor, changing \ref to \sbref.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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