2

I'm trying to convert a Latex file to a markdown format with pandoc 3.1 but the resulting markdown file doesn't generate the title nor the references properly. I'm kind of at my wits end here as nothing I do seems to have the correct output. I'm not sure how to proceed. I'll provide a minimal example below:

main.tex

\documentclass{article}

\title{title}
\author{}
\affil{}
\date{}

\begin{document}

\maketitle

\section{Summary}
Sentence one \cite{gavison1980privacy, martin2017role}. \cite{westin1968privacy} sentence two.

\bibliographystyle{apa}
\bibliography{references}

\end{document}

references.bib

@article{gavison1980privacy,
  title={Privacy and the Limits of Law},
  author={Gavison, Ruth},
  journal={The Yale law journal},
  volume={89},
  number={3},
  pages={421--471},
  year={1980},
  publisher={JSTOR}
}

@article{martin2017role,
  title={The role of data privacy in marketing},
  author={Martin, Kelly D and Murphy, Patrick E},
  journal={Journal of the Academy of Marketing Science},
  volume={45},
  pages={135--155},
  year={2017},
  publisher={Springer US}
}

@article{westin1968privacy,
  title={Privacy and freedom},
  author={Westin, Alan F},
  journal={Washington and Lee Law Review},
  volume={25},
  number={1},
  pages={166},
  year={1968}
}

I'm using the following pandoc command: pandoc -o output.md main.tex --bibliography=references.bib

I've also tried adding the apa.csl and adding a --csl=apa.csl in the pandoc command. No dice. The output is always the following with no title or references:

# Summary

Sentence one [@gavison1980privacy; @martin2017role]. @westin1968privacy
sentence two.

I'd want something like the following:

---
title: "titl"
author: ""
date: ""
bibliography: references.bib
csl: apa.csl
---

# Privacy Metrics

## Summary

Sentence one (Gavison, 1980; Martin & Murphy, 2017). Westin (1968) sentence two.

## References

<div id="refs" class="references">

<div id="ref-gavison1980privacy">

Gavison, R. (1980). Privacy and the Limits of Law. *The Yale law journal*, *89*(3), 421–471. https://doi.org/10.2307/795662

</div>

<div id="ref-martin2017role">

Martin, K. D., & Murphy, P. E. (2017). The role of data privacy in marketing. *Journal of the Academy of Marketing Science*, *45*, 135–155. https://doi.org/10.1007/s11747-016-0496-x

</div>

<div id="ref-westin1968privacy">

Westin, A. F. (1968). Privacy and freedom. *Washington and Lee Law Review*, *25*(1), 166.

</div>

</div>
2
  • What you want is not markdown, but a mix of markdown with HTML.
    – Fran
    Feb 22 at 5:49
  • 1
    Use --standalone to get the title and bib information in a header.
    – Aditya
    Feb 22 at 5:54

1 Answer 1

3

What you want is not convert to markdown, but a mix of markdown with HTML, that is not possible with pandoc, AFAIK. What you obtain is markdowm, but not a complete (standalone) document, but using -s:

$ pandoc -s -t markdown -f latex main.tex

You will obtain this:

---
bibliography:
- references.bib
title: title
---

Summary
=======

Sentence one [@gavison1980privacy; @martin2017role].
[@westin1968privacy] sentence two.

That is a complete document.

mwe

Note that date and author are not exported because the argument is empty, whereas \affil, well, is an undefined command ...

Note that there are not automatic title for the bibliography using citeproc. You can simply add this at the end of the markdown text (e.g., # References, modify the template, or change a bit the header and render it with Quarto (save it with extension .qmd):

---
title: "title"
bibliography: references.bib
format:
  pdf: 
    cite-method: biblatex # or natbib
biblio-style: apa # for biblatex only
---

Summary
=======

Sentence one [@gavison1980privacy; @martin2017role].
[@westin1968privacy] sentence two.

wme2

1
  • Thank you--it was very informative. Will accept as answer.
    – user290664
    Feb 23 at 6:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .