Напишите `\tag` в режиме отображения математики так, чтобы он не был автоматически заключен в скобки и Overleaf не выдал ошибку

Напишите `\tag` в режиме отображения математики так, чтобы он не был автоматически заключен в скобки и Overleaf не выдал ошибку

Как мне написать a \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 красная точка не отображается.

введите описание изображения здесь

Связанный контент