git.iko.soy/typeable/pandoc
on master help sign in
Use top-level header at end as bibliography title for natbib and biblatex output.
commita312d2a8aec49343ec9e8353098a2142a7c7851f authorNathan Gass <gass@search.ch> dateWed 15 Dec 2010, 13:50 (16 years ago) parent8f60176
4 files changed+27−12
src/Text/Pandoc/Writers/LaTeX.hs+13−4 templates/latex.template+12−5 tests/biblatex-citations.latex+1−2 tests/natbib-citations.latex+1−1
src/Text/Pandoc/Writers/LaTeX.hs+13−4
@@ -74,15 +74,23 @@ pandocToLaTeX options (Pandoc (Meta title authors date) blocks) = do
7474 titletext <- liftM render $ inlineListToLaTeX title
7575 authorsText <- mapM (liftM render . inlineListToLaTeX) authors
7676 dateText <- liftM render $ inlineListToLaTeX date
77− body <- blockListToLaTeX blocks
77+ let (blocks', lastHeader) = if writerCiteMethod options == Citeproc then
78+ (blocks, [])
79+ else case last blocks of
80+ Header 1 il -> (init blocks, il)
81+ _ -> (blocks, [])
82+ body <- blockListToLaTeX blocks'
83+ biblioTitle <- liftM render $ inlineListToLaTeX lastHeader
7884 let main = render body
7985 st <- get
80− let biblio = intercalate "," $ map dropExtension $ writerBiblioFiles options
86+ let biblioFiles = intercalate "," $ map dropExtension $ writerBiblioFiles options
8187 citecontext = case writerCiteMethod options of
82− Natbib -> [ ("biblio", biblio)
88+ Natbib -> [ ("biblio-files", biblioFiles)
89+ , ("biblio-title", biblioTitle)
8390 , ("natbib", "yes")
8491 ]
85− Biblatex -> [ ("biblio", biblio)
92+ Biblatex -> [ ("biblio-files", biblioFiles)
93+ , ("biblio-title", biblioTitle)
8694 , ("biblatex", "yes")
8795 ]
8896 _ -> []
@@ -102,6 +110,7 @@ pandocToLaTeX options (Pandoc (Meta title authors date) blocks) = do
102110 [ ("numbersections", "yes") | writerNumberSections options ] ++
103111 [ ("lhs", "yes") | stLHS st ] ++
104112 [ ("graphics", "yes") | stGraphics st ] ++
113+ [ ("book-class", "yes") | stBook st] ++
105114 citecontext
106115 return $ if writerStandalone options
107116 then renderTemplate context template
templates/latex.template+12−5
@@ -19,8 +19,8 @@ $if(natbib)$
1919$endif$
2020$if(biblatex)$
2121\usepackage{biblatex}
22−$if(biblio)$
23−\bibliography{$biblio$}
22+$if(biblio-files)$
23+\bibliography{$biblio-files$}
2424$endif$
2525$endif$
2626$if(lhs)$
@@ -104,13 +104,20 @@ $if(toc)$
104104
105105$endif$
106106$body$
107−$if(biblio)$
107+$if(biblio-files)$
108108$if(natbib)$
109−\bibliography{$biblio$}
109+$if(biblio-title)$
110+$if(book-class)$
111+\renewcommand\bibname{$biblio-title$}
112+$else$
113+\renewcommand\refname{$biblio-title$}
114+$endif$
115+$endif$
116+\bibliography{$biblio-files$}
110117$endif$
111118$endif$
112119$if(biblatex)$
113−\printbibliography
120+\printbibliography$if(biblio-title)$[title=$biblio-title$]$endif$
114121$endif$
115122$for(include-after)$
116123
tests/biblatex-citations.latex+1−2
@@ -64,7 +64,6 @@ a locator \autocite*[p.~44]{item2}.}
6464 With some markup \autocite[\emph{see}][p. \textbf{32}]{item1}.
6565
6666\end{itemize}
67−\section{References}
68−\printbibliography
67+\printbibliography[title=References]
6968
7069\end{document}
tests/natbib-citations.latex+1−1
@@ -66,7 +66,7 @@ with a locator \citeyearpar[p.~44]{item2}.}
6666 With some markup \citep[\emph{see}][p. \textbf{32}]{item1}.
6767
6868\end{itemize}
69−\section{References}
69+\renewcommand\refname{References}
7070\bibliography{biblio}
7171
7272\end{document}