如何将用 Latex 编写的出版物转换为 markdown?

如何将用 Latex 编写的出版物转换为 markdown?

我正在尝试将 Latex 文件转换为 markdown 格式,pandoc 3.1但生成的 markdown 文件无法正确生成标题和参考资料。我有点束手无策了,因为我所做的一切似乎都没有正确的输出。我不确定如何继续。我将在下面提供一个最小示例:

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}
}

我正在使用以下 pandoc 命令: pandoc -o output.md main.tex --bibliography=references.bib

我也尝试过在 pandoc 命令中添加apa.csl和添加--csl=apa.csl。没有成功。输出始终是以下内容,没有标题或参考:

# Summary

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

我想要如下内容:

---
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>

答案1

你想要的不是转换为 markdown,而是 markdown 与 HTML 的混合,据我所知,这在 pandoc 中是无法实现的。你得到的是 markdowm,而不是完整的 (独立) 文档,但使用-s

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

你将获得:

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

Summary
=======

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

这是一份完整的文件。

姆韦

请注意,由于参数为空,\affil因此不会导出日期和作者,而是一个未定义的命令......

请注意,使用 的参考书目没有自动标题citeproc。您可以简单地将其添加到 markdown 文本的末尾(例如,# References修改模板,或稍微更改标题并使用四开本(使用扩展名保存.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

相关内容