summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Gass <gass@search.ch>2010-12-15 13:50:21 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2010-12-15 10:21:56 -0800
commita312d2a8aec49343ec9e8353098a2142a7c7851f (patch)
treec41a3048f868677830111381b532acd7cea4abcc
parent8f60176511d006cc1c9fb8146f4e38cb9b760dc6 (diff)
Use top-level header at end as bibliography title for natbib and biblatex output.
-rw-r--r--src/Text/Pandoc/Writers/LaTeX.hs17
-rw-r--r--templates/latex.template17
-rw-r--r--tests/biblatex-citations.latex3
-rw-r--r--tests/natbib-citations.latex2
4 files changed, 27 insertions, 12 deletions
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs
index ca7446994..1afc55f4a 100644
--- a/src/Text/Pandoc/Writers/LaTeX.hs
+++ b/src/Text/Pandoc/Writers/LaTeX.hs
@@ -74,15 +74,23 @@ pandocToLaTeX options (Pandoc (Meta title authors date) blocks) = do
titletext <- liftM render $ inlineListToLaTeX title
authorsText <- mapM (liftM render . inlineListToLaTeX) authors
dateText <- liftM render $ inlineListToLaTeX date
- body <- blockListToLaTeX blocks
+ let (blocks', lastHeader) = if writerCiteMethod options == Citeproc then
+ (blocks, [])
+ else case last blocks of
+ Header 1 il -> (init blocks, il)
+ _ -> (blocks, [])
+ body <- blockListToLaTeX blocks'
+ biblioTitle <- liftM render $ inlineListToLaTeX lastHeader
let main = render body
st <- get
- let biblio = intercalate "," $ map dropExtension $ writerBiblioFiles options
+ let biblioFiles = intercalate "," $ map dropExtension $ writerBiblioFiles options
citecontext = case writerCiteMethod options of
- Natbib -> [ ("biblio", biblio)
+ Natbib -> [ ("biblio-files", biblioFiles)
+ , ("biblio-title", biblioTitle)
, ("natbib", "yes")
]
- Biblatex -> [ ("biblio", biblio)
+ Biblatex -> [ ("biblio-files", biblioFiles)
+ , ("biblio-title", biblioTitle)
, ("biblatex", "yes")
]
_ -> []
@@ -102,6 +110,7 @@ pandocToLaTeX options (Pandoc (Meta title authors date) blocks) = do
[ ("numbersections", "yes") | writerNumberSections options ] ++
[ ("lhs", "yes") | stLHS st ] ++
[ ("graphics", "yes") | stGraphics st ] ++
+ [ ("book-class", "yes") | stBook st] ++
citecontext
return $ if writerStandalone options
then renderTemplate context template
diff --git a/templates/latex.template b/templates/latex.template
index 371484ffc..e1dbdae83 100644
--- a/templates/latex.template
+++ b/templates/latex.template
@@ -19,8 +19,8 @@ $if(natbib)$
$endif$
$if(biblatex)$
\usepackage{biblatex}
-$if(biblio)$
-\bibliography{$biblio$}
+$if(biblio-files)$
+\bibliography{$biblio-files$}
$endif$
$endif$
$if(lhs)$
@@ -104,13 +104,20 @@ $if(toc)$
$endif$
$body$
-$if(biblio)$
+$if(biblio-files)$
$if(natbib)$
-\bibliography{$biblio$}
+$if(biblio-title)$
+$if(book-class)$
+\renewcommand\bibname{$biblio-title$}
+$else$
+\renewcommand\refname{$biblio-title$}
+$endif$
+$endif$
+\bibliography{$biblio-files$}
$endif$
$endif$
$if(biblatex)$
-\printbibliography
+\printbibliography$if(biblio-title)$[title=$biblio-title$]$endif$
$endif$
$for(include-after)$
diff --git a/tests/biblatex-citations.latex b/tests/biblatex-citations.latex
index 05fe00f48..7ac680fa4 100644
--- a/tests/biblatex-citations.latex
+++ b/tests/biblatex-citations.latex
@@ -64,7 +64,6 @@ a locator \autocite*[p.~44]{item2}.}
With some markup \autocite[\emph{see}][p. \textbf{32}]{item1}.
\end{itemize}
-\section{References}
-\printbibliography
+\printbibliography[title=References]
\end{document}
diff --git a/tests/natbib-citations.latex b/tests/natbib-citations.latex
index 00787584e..373ccc2e6 100644
--- a/tests/natbib-citations.latex
+++ b/tests/natbib-citations.latex
@@ -66,7 +66,7 @@ with a locator \citeyearpar[p.~44]{item2}.}
With some markup \citep[\emph{see}][p. \textbf{32}]{item1}.
\end{itemize}
-\section{References}
+\renewcommand\refname{References}
\bibliography{biblio}
\end{document}