rst2latex中的bibtex引用

Dav*_*jad 9 restructuredtext

Usind rst2latex,哪个命令允许我包含一个引用密钥,引用一个bibtex数据库?在乳胶中我会用\ cite {Rumpelstielzchen2003}来实现这个目标.

Dav*_*jad 11

我发现的解决方案是将乳胶内联到第一个文档中:

.. role:: raw-tex(raw)
    :format: latex html

Introduction
============
A profit maximizing agent in an environment with a finite number of buyers
following :raw-tex:`\cite{Kutschinski2003}` investigates price setting by 
reinforcement learning agent.

# at the end of the document
.. raw:: latex

    \bibliographystyle{plain}
    \bibliography{/home/path/library}
Run Code Online (Sandbox Code Playgroud)

文本开头的角色定义允许我们将纯乳胶内联.使用:raw-tex:\cite{Kutschinski2003}我们从bibtex文件索引一个乳胶参考.在文档的最后,我们放置了一个原始乳胶段,以.. raw:latex开头,引用了library.bib文件.(由bibtex或mendeley创建)第一个文件可以编译为:

rst2latex paper.rst > build/paper.tex && cd build/ && latex paper.tex && bibtex paper.aux && latex paper.tex && pdflatex paper.tex && evince paper.pdf & cd .. 
Run Code Online (Sandbox Code Playgroud)

或者使用以下编译命令创建paper.sh文件:

rst2latex paper.rst > build/paper.tex 
cd build/
latex paper.tex
bibtex paper.aux
latex paper.tex
pdflatex paper.tex
evince paper.pdf
cd .. 
Run Code Online (Sandbox Code Playgroud)

(如果乳胶导致图片出现问题,请用pdflatex代替)


Tim*_*Tim 11

另一种方式(虽然也是特定于LaTeX)是为了使编辑更好.

.. role:: cite

.. raw:: latex

   \providecommand*\DUrolecite[1]{\cite{#1}}
Run Code Online (Sandbox Code Playgroud)

这样你就可以使用了

:cite:`key`
Run Code Online (Sandbox Code Playgroud)

还在文档的最后:

.. raw:: latex

   \bibliographystyle{plain}
   \bibliography{/home/path/library}
Run Code Online (Sandbox Code Playgroud)


小智 1

有一个非常方便的工具,称为bib2reSTitation,可以将 bibtex 样式参考文件转换为 reStructuredText 标记样式引用样式。

赶紧跑:

$ python bib2reSTcitation.py -i tex.bib -o references.txt
Run Code Online (Sandbox Code Playgroud)

你会得到你想要的。希望能帮助到你!