6

I can't imagine this isn't covered elsewhere, but for the life of my I can't find it. (Forgive me, I'm very new to LaTeX.)

I'm running pandoc to generate PDFs based on a markdown document, but right now my bibliography is being formatted just like another other paragraph: leading indent, no space between entries. I'd like to format it with hanging indents and a slight space between sections. It seems like that should be default behavior, but even when I strip away the LaTeX template to bare bones, I can't get the bibliography to behave properly.

I'm running the memoir class, and using the chicago-fullnotes-bibliography style. I'm wondering if there's either a way to change default bibliography behavior, or hack a different indent pattern for that section of the document.

10

I'm not sure what 'chicago-fullnotes-bibliography' is, but if it is based on biblatex, the following lengths are probably what you want to redefine to your liking:

\setlength{\bibhang}{11pt}% the hanging indent
\setlength{\bibitemsep}{6pt}% the separation b/w basic items
\setlength{\bibinitsep}{\baselineskip}% insert blank line between different initial letters

These will work with the memoir class; change the lengths to suit your needs.

If you are not using biblatex, but need to follow the Chicago style, I recommend you switch sooner rather than later to biblatex and biber, and use the biblatex-chicago contributed style. It implements CMS 16th ed., and is under active development. The author is also responsive to feedback about potential problems.

  • I'm accepting the answer because that definitely should fix it, but unfortunately I'm realizing that pandoc doesn't actually let the LaTeX template do much with the bibliography. chicago-fullnotes-bibliography is a CSL style, and pandoc does all the bibliography formatting as per its specifications. (Unfortuately, it doesn't seem to be responding to those, either--but that's a question for the pandoc listserve.) Thanks for your help! – Brian Hamilton May 29 '12 at 10:14
  • Indeed. There is nothing in the .csl that gives formatting directives about the bibliography. I guess that makes sense, but the Chicago style can be pretty picky about things. As for pandoc, my limited experience suggested that it couldn't (then; yet?) handle all of biblatex's capabilities. (But I'm an emacs user, so org-mode would be my starting point for simple documents; and of course real LaTeX when I want to write something complicated....) – jon May 29 '12 at 17:33
  • 1
    Brain, I think pandoc leaves most of the bibliography work to LaTeX (instead of doing it itself) if you supply the --biblatex switch. – loevborg Aug 21 '12 at 21:53
1

The answer provided by @jon just gives me an error message.

But I found the following workaround to be working nicely. If your bibliography should appear at the end of the document (the default), just add the following lines at the very end of the Markdown document:

\noindent
\vspace{-2em}
\setlength{\parindent}{-0.5in}
\setlength{\leftskip}{0.5in}
\setlength{\parskip}{15pt}

However, if you're manually defining the position of the bibliography (using the tag <div id="refs"></div>), you have to wrap the above lines and the <div> tag in a Latex group to limit the formatting changes to the bibliography only:

\begingroup
\noindent
\vspace{-2em}
\setlength{\parindent}{-0.5in}
\setlength{\leftskip}{0.5in}
\setlength{\parskip}{15pt}

<div id="refs"></div>

\endgroup

Explanation of the commands:

  • \setlength{\parindent} and \setlength{\leftskip} define the hanging indentation of the bibiography entries.
  • \setlength{\parskip} defines the spacing between bibliography entries.
  • \noindent is needed in order to also have the very first bibliography entry correctly hanging indented.
  • \vspace{-2em} reduces the vertical spacing between the bibliography and the last paragraph before it (because \noindent adds a blank paragraph).

source: https://groups.google.com/d/msg/pandoc-discuss/4SKA5E11rO4/fDGiNSOsIMkJ

  • Welcome, this does seem ro be a very strange answer. Can you extend it so people can understand it better? – Johannes_B Sep 23 '17 at 4:56
  • @Johannes_B I tried my best; I'm a complete (La)Tex novice, it's the best I can provide :) – Salim B Sep 23 '17 at 22:27
1

(I don't have the reputation to simply make this a comment, but I also wanted to concatenate both replies above for future googlers like me)

Pandoc’s built-in bibliography formatting uses citeproc to generate the “bibliography.” That is, although it reads a .bib file and generates a .pdf through an engine like XeLaTeX, it never actually calls biber, etc.

If you output a pandoc-generated bibliography to a .tex file, you get something like this at the very end:

\hypertarget{refs}{}
\leavevmode\hypertarget{ref-nightwood}{}%
Barnes, Djuna. 1936. \emph{Nightwood}. New York: New Directions.

\leavevmode\hypertarget{ref-fama_melancholic_2014}{}%
Fama, Katherine A. ``Melancholic Remedies: Djuna Barnes's
\emph{Nightwood} as Narrative Theory.'' \emph{Journal of Modern
Literature} 37, no. 2 (2014): 39--58.
\url{https://doi.org/10.2979/jmodelite.37.2.39}.

As a result, @jon’s solution cannot fix the inherent problem in Pandoc, because the resulting output is not marked in such a way to react to something like \bibhang.

Hence the “easiest” solution is to force a change in formatting, akin to what @salim-b suggests.

A similar solution to the one offered is to install pandoc-citeproc-preamble, which inserts a short .tex file before where the bibliography would be created. The basic version of that is:

\section*{References}
\setlength{\parindent}{-0.2in}
\singlespacing
\small
\setlength{\leftskip}{0.2in}
\setlength{\parskip}{8pt}
\vspace*{-0.4in}
\noindent

In my own practice (as indicated in the template simple-essay), I simply append a file similar to the quoted bit above when summoning Pandoc:

pandoc -sr markdown+yaml_metadata_block+citations \
  --pdf-engine=xelatex --template=template.tex \
  --filter pandoc-citeproc \
  ./metadata.yml ./tmp/main.md ./bibliography-preamble.tex \
  -o output.pdf

Pandoc does have a feature, however, to convert its citation syntax into BibLaTeX commands. Adding the flag --biblatex at compile time will fill the resulting .tex file with all the \autocites and so on one would want. As the documentation clearly notes, however:

This option is not for use with the pandoc-citeproc filter or with PDF output. It is intended for use in producing a LaTeX file that can be processed with bibtex or biber.

In that case, the full incantation is something like:

pandoc -sr markdown+yaml_metadata_block+citations \
  --biblatex ./metadata.yml ./tmp/main.md \
  -o output.tex ; xelatex output.tex ; biber output ; xelatex output.tex ; xelatex output.tex

And, in fact, this is, I believe, the solution I will personally use moving forward. I get a properly formatted bibliography using a tool reacting properly/semantically to its environment, not the kind of kludge that Citeproc produces.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.