@@ -82,12 +82,15 @@ writeLaTeX options document =
8282pandocToLaTeX :: WriterOptions -> Pandoc -> State WriterState String
8383pandocToLaTeX options (Pandoc (Meta title authors date) blocks) = do
8484 let template = writerTemplate options
85− let templateLines = lines template
86− let usesBookClass x = "\\documentclass" `isPrefixOf` x &&
87− ("{memoir}" `isSuffixOf` x || "{book}" `isSuffixOf` x ||
88− "{report}" `isSuffixOf` x)
89− when (any usesBookClass templateLines) $
90− modify $ \s -> s{stBook = True}
85+ -- set stBook depending on documentclass
86+ let bookClasses = ["memoir","book","report","scrreprt","scrbook"]
87+ case lookup "documentclass" (writerVariables options) of
88+ Just x | x `elem` bookClasses -> modify $ \s -> s{stBook = True}
89+ | otherwise -> return ()
90+ Nothing | any (\x -> "\\documentclass" `isPrefixOf` x &&
91+ (any (`isSuffixOf` x) bookClasses))
92+ (lines template) -> modify $ \s -> s{stBook = True}
93+ | otherwise -> return ()
9194 -- check for \usepackage...{csquotes}; if present, we'll use
9295 -- \enquote{...} for smart quotes:
9396 when ("{csquotes}" `isInfixOf` template) $