I've been trying to add brackets around cross-references in a more automatic manner in my recent report, but haven't been able to do so just yet. A simple \newcommand-macro does not seem to work. I've tried the \eqref{fig:label} from the amsmath package, but I want brackets '[#1]' and not paranthesis '(#1)'. Another solution was trying \let\oldref\ref followed by \AtBeginDocument\renewcommand{\ref}[1]{[\oldref{#1}]} to combat hyperref controlling the \ref command, but this did not seem to work.

My question is, is there a way to create a macro with brackets around \ref (or a similar command that does this) instead of writing [\ref{fig:label}] everytime?

I am a relatively new user, so pardon any inconveniences.

  • 2
    You should probably be a bit more explicit about what it is you are going to use this for. To me, having Theorem~\ref{key} returning Theorem~[2.3] looks very strange. – daleif Sep 12 '19 at 10:41
  • 1
    What is the problem with hyperref redefining \ref? You want to remove the link? Cleveref might be useful, lots of customisation possible – Sybil Sep 12 '19 at 11:26

Your Answer

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

Browse other questions tagged or ask your own question.