diff --git a/services/web/frontend/js/features/source-editor/languages/latex/linter/latex-linter.worker.ts b/services/web/frontend/js/features/source-editor/languages/latex/linter/latex-linter.worker.ts index bb8589406b..20e1e9860c 100644 --- a/services/web/frontend/js/features/source-editor/languages/latex/linter/latex-linter.worker.ts +++ b/services/web/frontend/js/features/source-editor/languages/latex/linter/latex-linter.worker.ts @@ -1107,12 +1107,24 @@ const InterpretTokens = function ( seq === 'intertext' || seq === 'shortintertext' || seq === 'textnormal' || - seq === 'tag' || seq === 'reflectbox' || seq === 'textrm' ) { // next group will be in text mode regardless nextGroupMathMode = false + } else if (seq === 'tag') { + // next group will be in text mode regardless + nextGroupMathMode = false + // \tag* (unnumbered tag) - skip over the '*' so it doesn't reset + // nextGroupMathMode before the argument group is reached + const nextToken = Tokens[i + 1] + if ( + nextToken && + nextToken[1] === 'Text' && + text.substring(nextToken[2], nextToken[3]) === '*' + ) { + i = i + 1 + } } else if (seq === 'tikz') { // try to read any optional params [BAR]...., advance if found const newPos = readOptionalGeneric(TokeniseResult, i) diff --git a/services/web/test/frontend/features/source-editor/languages/latex/latex-linter.test.ts b/services/web/test/frontend/features/source-editor/languages/latex/latex-linter.test.ts index ea4c7e8e15..a6a78762c9 100644 --- a/services/web/test/frontend/features/source-editor/languages/latex/latex-linter.test.ts +++ b/services/web/test/frontend/features/source-editor/languages/latex/latex-linter.test.ts @@ -350,6 +350,18 @@ describe('LatexLinter', function () { assert.equal(errors.length, 0) }) + it('should accept math tag* commands', function () { + const { errors } = Parse( + '\\begin{align}\n\\pi=3 \\tag*{\\(\\dagger\\)}\n\\end{align}\n' + ) + assert.equal(errors.length, 0) + }) + + it('should accept math tag* commands with $ math mode', function () { + const { errors } = Parse('$\\tag*{$abc$}$\n') + assert.equal(errors.length, 0) + }) + it('should accept math \\def commands', function () { const { errors } = Parse( '\\def\\peb[#1]{{\\left\\lfloor #1\\right\\rfloor}}'