10

Does anyone knows how can I use square brackets instead of parenthesis when numbering my equations?

I used this command:

\begin{equation}
y = 2x
\end{equation}

enter image description here

The number appears on the right hand side like (1) I want to make it [1].

Does anyone have any ideas?

2 Answers2

15

This is much simpler if you load mathtools, an add-on package for amsmath:

\documentclass{article}

\usepackage{mathtools}

\newtagform{brackets}{[}{]}
\usetagform{brackets}

\begin{document}

  \begin{equation}\label{eq:test}
    y = 2x
  \end{equation}

  See eq~\eqref{eq:test}.
\end{document}

Result: enter image description here

MaxNoe
  • 6,136
4

If package amsmath is loaded, then it uses \tagform@ for the formatting of the equation number:

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\def\tagform@#1{\maketag@@@{[\ignorespaces#1\unskip\@@italiccorr]}}
\makeatother

\begin{document}
\begin{equation}
  \label{eq:y=2x}
  y = 2x
\end{equation}
Equation \eqref{eq:y=2x}.
\end{document}

Result

Standard LaTeX uses \@eqnum for this purpose:

\makeatletter
\renewcommand*{\@eqnnum}{{\normalfont \normalcolor [\theequation]}}
\makeatother
Heiko Oberdiek
  • 271,626