@@ -1521,6 +1521,7 @@ defmacro = try $
15211521 Tok _ (CtrlSeq name) _ <- anyControlSeq
15221522 argspecs <- many (argspecArg <|> argspecPattern)
15231523 contents <- bracedOrToken
1524+ doMacros -- after all this verbatim mode
15241525 return (name, Macro ExpandWhenUsed argspecs Nothing contents)
15251526
15261527argspecArg :: PandocMonad m => LP m ArgSpec
@@ -1541,23 +1542,25 @@ newcommand = do
15411542 controlSeq "renewcommand" <|>
15421543 controlSeq "providecommand" <|>
15431544 controlSeq "DeclareRobustCommand"
1544− Tok _ (CtrlSeq name) txt <- withVerbatimMode $ do
1545− optional (symbol '*')
1546− anyControlSeq <|>
1547− (symbol '{' *> spaces *> anyControlSeq <* spaces <* symbol '}')
1548− spaces
1549− numargs <- option 0 $ try bracketedNum
1550− let argspecs = map (\i -> ArgNum i) [1..numargs]
1551− spaces
1552− optarg <- option Nothing $ Just <$> try bracketedToks
1553− spaces
1554− contents <- withVerbatimMode bracedOrToken
1555− when (mtype == "newcommand") $ do
1556− macros <- sMacros <$> getState
1557− case M.lookup name macros of
1558− Just _ -> report $ MacroAlreadyDefined (T.unpack txt) pos
1559− Nothing -> return ()
1560− return (name, Macro ExpandWhenUsed argspecs optarg contents)
1545+ withVerbatimMode $ do
1546+ Tok _ (CtrlSeq name) txt <- do
1547+ optional (symbol '*')
1548+ anyControlSeq <|>
1549+ (symbol '{' *> spaces *> anyControlSeq <* spaces <* symbol '}')
1550+ spaces
1551+ numargs <- option 0 $ try bracketedNum
1552+ let argspecs = map (\i -> ArgNum i) [1..numargs]
1553+ spaces
1554+ optarg <- option Nothing $ Just <$> try bracketedToks
1555+ spaces
1556+ contents <- bracedOrToken
1557+ when (mtype == "newcommand") $ do
1558+ macros <- sMacros <$> getState
1559+ case M.lookup name macros of
1560+ Just _ -> report $ MacroAlreadyDefined (T.unpack txt) pos
1561+ Nothing -> return ()
1562+ doMacros -- after all this verbatim mode
1563+ return (name, Macro ExpandWhenUsed argspecs optarg contents)
15611564
15621565newenvironment :: PandocMonad m => LP m (Text, Macro, Macro)
15631566newenvironment = do