角括弧内の方程式の番号付け

角括弧内の方程式の番号付け

方程式に番号を付けるときに、括弧の代わりに角括弧を使用する方法を知っている人はいますか?

次のコマンドを使用しました:

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

ここに画像の説明を入力してください

(1)のように右側に数字が出てきますので、[1]にしたいです。

誰か何かアイデアはありますか?

答え1

mathtoolsamsmath のアドオン パッケージをロードすると、これははるかに簡単になります。

\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}

結果: ここに画像の説明を入力してください

答え2

パッケージamsmathがロードされている場合、\tagform@方程式番号の書式設定に以下が使用されます。

\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}

結果

標準的な LaTeX では、\@eqnumこの目的のために以下を使用します。

\makeatletter
\renewcommand*{\@eqnnum}{{\normalfont \normalcolor [\theequation]}}
\makeatother

関連情報