Davoud Taghawi-Nejad
Davoud Taghawi-Nejad

Reputation: 16796

bibtex citations in rst2latex

Usind rst2latex, which command allows me to include a citation key, that references a bibtex database? In latex I would have achieved this with \cite{Rumpelstielzchen2003}

Upvotes: 9

Views: 2670

Answers (4)

G. Milde
G. Milde

Reputation: 897

In rST you may use

the standard citation syntax Rumpelstielzchen2003]_.

and translate with rst2latex --use-bibtex=unsrt,grimm.bib to generate

...
the standard citation syntax \cite{Rumpelstielzchen2003}.

\bibliographystyle{unsrt}
\bibliography{grimm.bib}
...

Upvotes: 0

Yukun Chen
Yukun Chen

Reputation: 26

There is a very handy tool called bib2reSTcitation to convert bibtex style references file to reStructuredText Markup style citation style.

just run:

$ python bib2reSTcitation.py -i tex.bib -o references.txt

And you get what you want. Hope it helps!

Upvotes: 1

Tim
Tim

Reputation: 221

Another way (though also LaTeX specific) is to make it nicer in editing.

.. role:: cite

.. raw:: latex

   \providecommand*\DUrolecite[1]{\cite{#1}}

This way you can use

:cite:`key`

And also at the end of your document:

.. raw:: latex

   \bibliographystyle{plain}
   \bibliography{/home/path/library}

Upvotes: 12

Davoud Taghawi-Nejad
Davoud Taghawi-Nejad

Reputation: 16796

The solution I found is inlineing latex into the rst document:

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

The role definition at the beginning of the text allows us to put pure latex inline. With :raw-tex:\cite{Kutschinski2003} we index a latex reference from the bibtex file. At the end of the document we put a raw latex paragraph, started with .. raw: latex that references the library.bib file. (as created by bibtex or mendeley) The rst file can be compiled with:

rst2latex paper.rst > build/paper.tex && cd build/ && latex paper.tex && bibtex paper.aux && latex paper.tex && pdflatex paper.tex && evince paper.pdf & cd .. 

Or create a paper.sh file with following compilation command:

rst2latex paper.rst > build/paper.tex 
cd build/
latex paper.tex
bibtex paper.aux
latex paper.tex
pdflatex paper.tex
evince paper.pdf
cd .. 

(if latex causes trouble with pictures substitute it with pdflatex)

Upvotes: 12

Related Questions