Schreiben Sie ein `\tag` im mathematischen Anzeigemodus, sodass es nicht automatisch in Klammern eingeschlossen wird und Overleaf keine Beschwerden verursacht

Schreiben Sie ein `\tag` im mathematischen Anzeigemodus, sodass es nicht automatisch in Klammern eingeschlossen wird und Overleaf keine Beschwerden verursacht

Wie kann ich \tagim mathematischen Anzeigemodus ein Element schreiben, sodass es nicht automatisch in Klammern eingeschlossen wird und Overleaf keine Beschwerden verursacht? (Ich gehe davon aus, dass es keine gute Praxis ist, die Beschwerden von Overleaf zu ignorieren.)

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

Antwort1

Es ist nicht gut, dass Overleaf eine vollkommen legale LaTeX-Konstruktion ablehnt. Andererseits sollten Sie Tags für solche Fälle nicht missbrauchen, da die Bedingung Teil der Gleichung ist, Tags jedoch nicht.

Wie dem auch sei, Sie können Overleaf ruhig halten, indem Sie \ttagdefinieren durch

\newcommand{\ttag}{\tag*}

Vermeiden Sie Leerzeilen vor Anzeigen, das ist falsch. Auf eine Anzeige kann eine Leerzeile folgen, wenn der nächste Text einen neuen Absatz beginnt.

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

Bildbeschreibung hier eingeben

Im Overleaf-Fenster wird kein roter Punkt angezeigt.

Bildbeschreibung hier eingeben

verwandte Informationen