18

It seems that Pandoc is capable of dealing with references given in a .bib file. Yet, I haven't been able to simply ask Pandoc to convert a .bib file into html, markdown or other formats. Is there a way to do so?

As an example of what I mean (since I am not sure I am clear enough...), I would say the following to export myfile.bib to myfile.pdf: Create myfile.tex which contains

\documentclass{article}
\begin{document}
\nocite{*}
\bibliographystyle{abbrv} % or another bibliography style!
\bibliography{myfile.bib}
\end{document}

and compile it using pdflatex and bibtex.

Is there such a simple way to export myfile.bib to (say) myfile.html?

  • I think the accepted these day should be the one by @AlexanderVonMoll. I.e. as of version 0.4 (Aug 2014), this functionality is built in to pandoc-citeproc. – nealmcb Jan 27 at 2:54
  • Both answers are quite similar I guess: One uses a tex file as input, the other one a markdown file. But both work equally well! – Bruno Mar 15 at 13:55
17

pandoc cannot convert a .bib file into another file format1. However, it can convert a .tex file which contains references (called from a .bib file) into a pdf, odt, html, ... If your .tex file just contains the \nocite{*} command, the result is similar (you will have all your references printed).

Here is the magic command:

pandoc test.tex -o output.odt --bibliography /my/bibliography.bib 

or (for pdf)

pandoc test.tex -o output.pdf --bibliography /my/bibliography.bib 

or (for html)

pandoc test.tex -o output.html --bibliography /my/bibliography.bib

Note that several launches of the pandoc command could be necessary to obtain a correct result.

MWE

Files

\documentclass{article}
\usepackage{biblatex}
\bibliography{mybib}

\begin{document}
\autocite{author00:_title}
\printbibliography
\end{document}

mybib.bib file:

@Book{author00:_title,
  author =   {Author},
  title =    {Title},
  publisher =    {Publisher},
  year =     2000}

Outputs

Pdf

enter image description here

html

html generated by pandoc test.tex -o output.html --bibliography mybib.bib:

<p><span class="citation">(Author 2000)</span></p>
<div class="references">
<p>Author. 2000. <em>Title</em>. Publisher.</p>
</div>

1 The documentation is not very clear about this point. Some phrasings could lead one to believe it's possible to directly convert from .bib to .*. I tested it and it isn't working. You have to use a .tex file if you want to convert a .bib file (today).

13

As of pandoc-citeproc-0.4 pandoc-citeproc has support for a \nocite{*}-equivalent.

mybib.bib file:

@article{behbahani2014aircraft,
    title={Aircraft Integration Challenges and Opportunities for Distributed Intelligent Control, Power, Thermal Management, Diagnostic and Prognostic Systems},
    author={Behbahani, Alireza R and Von Moll, Alexander and Zeller, Robert and Ordo, James},
    journal={SAE Tech. Pap. 2014-01},
    volume={2161},
    year={2014}
  }
@article{jia2013emergence,
    title={Emergence of bimodality in controlling complex networks},
    author={Jia, Tao and Liu, Yang-Yu and Cs{\'o}ka, Endre and P{\'o}sfai, M{\'a}rton and Slotine, Jean-Jacques and Barab{\'a}si, Albert-L{\'a}szl{\'o}},
    journal={Nature communications},
    volume={4},
    year={2013},
    publisher={Nature Publishing Group}
 }

@article{zhu2015game,
    title={Game-theoretic methods for robustness, security, and resilience of cyberphysical control systems: games-in-games principle for optimal cross-layer resilient control systems},
    author={Zhu, Quanyan and Basar, Tamer},
    journal={Control Systems, IEEE},
    volume={35},
    number={1},
    pages={46--65},
    year={2015},
    publisher={IEEE}
 }
@inproceedings{rieger2013hierarchical,
    title={A hierarchical multi-agent dynamical system architecture for resilient control systems},
    author={Rieger, Craig and Zhu, Quanyan},
    booktitle={Resilient Control Systems (ISRCS), 2013 6th International Symposium on},
    pages={6--12},
    year={2013},
    organization={IEEE}
  }

Along with the following Markdown skeleton mybib.md:

---
bibliography: mybib.bib
nocite: '@*'
...

# Bibliography

Built using pandoc --filter=pandoc-citeproc --standalone mybib.md -o mybib.html

Produces the following output: enter image description here


The HTML that corresponds with this is:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="Content-Style-Type" content="text/css" />
  <meta name="generator" content="pandoc" />
  <title></title>
  <style type="text/css">code{white-space: pre;}</style>
</head>
<body>
<h1 id="bibliography" class="unnumbered">Bibliography</h1>
<div id="refs" class="references">
<div id="ref-behbahani2014aircraft">
<p>Behbahani, Alireza R, Alexander Von Moll, Robert Zeller, and James Ordo. 2014. “Aircraft Integration Challenges and Opportunities for Distributed     Intelligent Control, Power, Thermal Management, Diagnostic and Prognostic Systems.” <em>SAE Tech. Pap. 2014-01</em> 2161.</p>
</div>
<div id="ref-jia2013emergence">
<p>Jia, Tao, Yang-Yu Liu, Endre Csóka, Márton Pósfai, Jean-Jacques Slotine, and Albert-László Barabási. 2013. “Emergence of Bimodality in Controlling Complex Networks.” <em>Nature Communications</em> 4. Nature Publishing Group.            </p>
</div>
<div id="ref-rieger2013hierarchical">
<p>Rieger, Craig, and Quanyan Zhu. 2013. “A Hierarchical Multi-Agent Dynamical System Architecture for Resilient Control Systems.” In <em>Resilient Control Systems (ISRCS), 2013 6th International Symposium on</em>, 6–12. IEEE.</p>
</div>
<div id="ref-zhu2015game">
<p>Zhu, Quanyan, and Tamer Basar. 2015. “Game-Theoretic Methods for Robustness, Security, and Resilience of Cyberphysical Control Systems: Games-in-Games Principle for Optimal Cross-Layer Resilient Control Systems.” <em>Control Systems, IEEE</em> 35 (1). IEEE: 46–65.</p>
</div>
</div>
</body>
</html>
  • 1
    This does not work for me, I consistently get this error: pandoc-citeproc: Error in $: expected product (:*:), encountered Object – Filip Allberg Dec 12 '16 at 12:04
  • 1
    Which versions of pandoc and pandoc-citeproc are you using? Do you have your own (non) working example or were you working with the example I provided? – Alexander Von Moll Dec 13 '16 at 13:46
  • Works for me. Using pandoc-citeproc 0.10.5.1-1build4 on Ubuntu 18.04 LTS Bionic – nealmcb Jan 27 at 2:49

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.