Use top-level header at end as bibliography title for natbib and biblatex output.

This commit is contained in:
Nathan Gass 2010-12-15 13:50:21 +01:00 committed by John MacFarlane
parent 8f60176511
commit a312d2a8ae
4 changed files with 27 additions and 12 deletions

View file

@ -74,15 +74,23 @@ pandocToLaTeX options (Pandoc (Meta title authors date) blocks) = do
titletext <- liftM render $ inlineListToLaTeX title titletext <- liftM render $ inlineListToLaTeX title
authorsText <- mapM (liftM render . inlineListToLaTeX) authors authorsText <- mapM (liftM render . inlineListToLaTeX) authors
dateText <- liftM render $ inlineListToLaTeX date 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 let main = render body
st <- get st <- get
let biblio = intercalate "," $ map dropExtension $ writerBiblioFiles options let biblioFiles = intercalate "," $ map dropExtension $ writerBiblioFiles options
citecontext = case writerCiteMethod options of citecontext = case writerCiteMethod options of
Natbib -> [ ("biblio", biblio) Natbib -> [ ("biblio-files", biblioFiles)
, ("biblio-title", biblioTitle)
, ("natbib", "yes") , ("natbib", "yes")
] ]
Biblatex -> [ ("biblio", biblio) Biblatex -> [ ("biblio-files", biblioFiles)
, ("biblio-title", biblioTitle)
, ("biblatex", "yes") , ("biblatex", "yes")
] ]
_ -> [] _ -> []
@ -102,6 +110,7 @@ pandocToLaTeX options (Pandoc (Meta title authors date) blocks) = do
[ ("numbersections", "yes") | writerNumberSections options ] ++ [ ("numbersections", "yes") | writerNumberSections options ] ++
[ ("lhs", "yes") | stLHS st ] ++ [ ("lhs", "yes") | stLHS st ] ++
[ ("graphics", "yes") | stGraphics st ] ++ [ ("graphics", "yes") | stGraphics st ] ++
[ ("book-class", "yes") | stBook st] ++
citecontext citecontext
return $ if writerStandalone options return $ if writerStandalone options
then renderTemplate context template then renderTemplate context template

View file

@ -19,8 +19,8 @@ $if(natbib)$
$endif$ $endif$
$if(biblatex)$ $if(biblatex)$
\usepackage{biblatex} \usepackage{biblatex}
$if(biblio)$ $if(biblio-files)$
\bibliography{$biblio$} \bibliography{$biblio-files$}
$endif$ $endif$
$endif$ $endif$
$if(lhs)$ $if(lhs)$
@ -104,13 +104,20 @@ $if(toc)$
$endif$ $endif$
$body$ $body$
$if(biblio)$ $if(biblio-files)$
$if(natbib)$ $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$
$endif$ $endif$
$if(biblatex)$ $if(biblatex)$
\printbibliography \printbibliography$if(biblio-title)$[title=$biblio-title$]$endif$
$endif$ $endif$
$for(include-after)$ $for(include-after)$

View file

@ -64,7 +64,6 @@ a locator \autocite*[p.~44]{item2}.}
With some markup \autocite[\emph{see}][p. \textbf{32}]{item1}. With some markup \autocite[\emph{see}][p. \textbf{32}]{item1}.
\end{itemize} \end{itemize}
\section{References} \printbibliography[title=References]
\printbibliography
\end{document} \end{document}

View file

@ -66,7 +66,7 @@ with a locator \citeyearpar[p.~44]{item2}.}
With some markup \citep[\emph{see}][p. \textbf{32}]{item1}. With some markup \citep[\emph{see}][p. \textbf{32}]{item1}.
\end{itemize} \end{itemize}
\section{References} \renewcommand\refname{References}
\bibliography{biblio} \bibliography{biblio}
\end{document} \end{document}