@@ -161,8 +161,9 @@ pandocToLaTeX options (Pandoc meta blocks) = do
161161 defField "euro" (stUsesEuro st) $
162162 defField "listings" (writerListings options || stLHS st) $
163163 defField "beamer" (writerBeamer options) $
164− defField "mainlang" (maybe "" (reverse . takeWhile (/=',') . reverse)
165− (lookup "lang" $ writerVariables options)) $
164+ defField "mainlang"
165+ (maybe "" (reverse . takeWhile (/=',') . reverse)
166+ (getField "lang" metadata)) $
166167 (if stHighlighting st
167168 then defField "highlighting-macros" (styleToLaTeX
168169 $ writerHighlightStyle options )