git.iko.soy/typeable/pandoc
on master help sign in
LaTeX writer: Don't print biblio if --natbib or --biblatex option used.
commite135955b1e37b4bee72ffc6d7f4dc60e99dcecae authorJohn MacFarlane <fiddlosopher@gmail.com> dateThu 19 Sep 2013, 10:08 (13 years ago) parentd27e5a6
1 file changed+17−10
src/Text/Pandoc/Writers/LaTeX.hs+17−10
src/Text/Pandoc/Writers/LaTeX.hs+17−10
@@ -82,10 +82,17 @@ writeLaTeX options document =
8282
8383pandocToLaTeX :: WriterOptions -> Pandoc -> State WriterState String
8484pandocToLaTeX options (Pandoc meta blocks) = do
85+ -- Strip off final 'references' header if --natbib or --biblatex
86+ let method = writerCiteMethod options
87+ let blocks' = if method == Biblatex || method == Natbib
88+ then case reverse blocks of
89+ (Div (_,["references"],_) _):xs -> reverse xs
90+ _ -> blocks
91+ else blocks
8592 -- see if there are internal links
8693 let isInternalLink (Link _ ('#':xs,_)) = [xs]
8794 isInternalLink _ = []
88− modify $ \s -> s{ stInternalLinks = query isInternalLink blocks }
95+ modify $ \s -> s{ stInternalLinks = query isInternalLink blocks' }
8996 let template = writerTemplate options
9097 -- set stBook depending on documentclass
9198 let bookClasses = ["memoir","book","report","scrreprt","scrbook"]
@@ -107,15 +114,15 @@ pandocToLaTeX options (Pandoc meta blocks) = do
107114 (fmap (render colwidth) . blockListToLaTeX)
108115 (fmap (render colwidth) . inlineListToLaTeX)
109116 meta
110− let (blocks', lastHeader) = if writerCiteMethod options == Citeproc then
111− (blocks, [])
112− else case last blocks of
113− Header 1 _ il -> (init blocks, il)
114− _ -> (blocks, [])
115− blocks'' <- if writerBeamer options
116− then toSlides blocks'
117− else return blocks'
118− body <- mapM (elementToLaTeX options) $ hierarchicalize blocks''
117+ let (blocks'', lastHeader) = if writerCiteMethod options == Citeproc then
118+ (blocks', [])
119+ else case last blocks' of
120+ Header 1 _ il -> (init blocks', il)
121+ _ -> (blocks', [])
122+ blocks''' <- if writerBeamer options
123+ then toSlides blocks''
124+ else return blocks''
125+ body <- mapM (elementToLaTeX options) $ hierarchicalize blocks'''
119126 (biblioTitle :: String) <- liftM (render colwidth) $ inlineListToLaTeX lastHeader
120127 let main = render colwidth $ vsep body
121128 st <- get