diff --git a/src/latexparser/latexparsing.cpp b/src/latexparser/latexparsing.cpp index 3e8cbc548b..a1cbc5be35 100644 --- a/src/latexparser/latexparsing.cpp +++ b/src/latexparser/latexparsing.cpp @@ -582,6 +582,10 @@ bool latexDetermineContexts2(QDocumentLineHandle *dlh, TokenStack &stack, Comman tk.subtype=tk1.subtype; level=tk1.level; // restore original level lexed.append(tk); + // clean up command stack (unrealized arguments) + while (!commandStack.isEmpty() && commandStack.top().level > level) { + commandStack.pop(); + } } if (!commandStack.isEmpty() && commandStack.top().level == level) { CommandDescription cd = commandStack.top();