@@ -321,16 +321,19 @@ inlineCommand = try $ do
321321 parseRaw <- stateParseRaw `fmap` getState
322322 star <- option "" (string "*")
323323 let name' = name ++ star
324+ let rawargs = withRaw (skipopts *> option "" dimenarg
325+ *> many braced) >>= applyMacros' . snd
326+ let raw = if parseRaw
327+ then (rawInline "latex" . (('\\':name') ++)) <$> rawargs
328+ else mempty <$> rawargs
324329 case M.lookup name' inlineCommands of
325− Just p -> p
330+ Just p -> p <|> raw
326331 Nothing -> case M.lookup name inlineCommands of
327− Just p -> p
328− Nothing ->
329− if parseRaw
330− then (rawInline "latex" . (('\\':name') ++)) <$> rawargs
331− else mempty <$> rawargs
332− where rawargs = withRaw (skipopts *> option "" dimenarg
333− *> many braced) >>= applyMacros' . snd
332+ Just p -> p <|> raw
333+ Nothing -> raw
334+
335+unlessParseRaw :: LP ()
336+unlessParseRaw = getState >>= guard . not . stateParseRaw
334337
335338isBlockCommand :: String -> Bool
336339isBlockCommand s = maybe False (const True) $ M.lookup s blockCommands
@@ -350,8 +353,8 @@ inlineCommands = M.fromList $
350353 , ("dots", lit "…")
351354 , ("mdots", lit "…")
352355 , ("sim", lit "~")
353− , ("label", inBrackets <$> tok)
354− , ("ref", inBrackets <$> tok)
356+ , ("label", unlessParseRaw >> (inBrackets <$> tok))
357+ , ("ref", unlessParseRaw >> (inBrackets <$> tok))
355358 , ("(", mathInline $ manyTill anyChar (try $ string "\\)"))
356359 , ("[", mathDisplay $ manyTill anyChar (try $ string "\\]"))
357360 , ("ensuremath", mathInline $ braced)