数式表示モードで `\tag` を記述すると、自動的に括弧で囲まれず、Overleaf がエラーを出さなくなります。

数式表示モードで `\tag` を記述すると、自動的に括弧で囲まれず、Overleaf がエラーを出さなくなります。

\tag数式表示モードで を自動的に括弧で囲まず、Overleaf がエラーを出さないようにするには、どうすればよいでしょうか? (Overleaf のエラーを無視するのは悪い習慣だと思います。)

\documentclass{article}
\usepackage{amsmath, amssymb}

\begin{document}

The following would be perfect if the automatic parentheses enclosing the tag were removed:

\[J(2^m + l) = 2l + 1 \tag{for $m \geqq 0$ and $0 \leqq l < 2^m$}\]

The following output is good

\[J(2^m + l) = 2l + 1 \tag*{for $m \geqq 0$ and $0 \leqq l < 2^m$}\]

yet Overleaf complains about it; in particular, it introduces a red warning dot in the margin of the Code Editor, whose drop-down text reads:

\begin{verbatim}
unclosed open display math \[ found at $
unclosed open group { found at $
unexpected $ after open group {
unexpected $ after open display math \[
unexpected $ after open display math \[
unexpected $ after open display math \[
unexpected $ after open display math \[
\end{verbatim}

\end{document}

答え1

Overleaf が、完全に合法な LaTeX 構造を拒否するのはよくありません。一方で、条件は方程式の一部ですが、タグは方程式の一部ではないため、このような場合にタグを乱用すべきではありません。

とにかく、Overleafを静かに保つには、次\ttagのように定義します。

\newcommand{\ttag}{\tag*}

ディスプレイの前に空行を置くのは避けてください。これは誤りです。次のテキストが新しい段落を開始する場合は、ディスプレイの後に空行を置くことができます。

\documentclass{article}
\usepackage{amsmath, amssymb}

\newcommand{\ttag}{\tag*}

\begin{document}

The following would be perfect if the automatic parentheses enclosing the tag were removed:
\[
J(2^m + l) = 2l + 1 
\tag{for $m \geqq 0$ and $0 \leqq l < 2^m$}
\]
The following output is good
\[
J(2^m + l) = 2l + 1 
\ttag{for $m \geqq 0$ and $0 \leqq l < 2^m$}
\]
But this output is much better
\[
J(2^m + l) = 2l + 1, 
\qquad\text{for $m \geqq 0$ and $0 \leqq l < 2^m$}
\]
as you can clearly see, because the conditions are part of the equation.

\end{document}

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

Overleaf ウィンドウに赤い点が表示されません。

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

関連情報