Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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}

like image 631
Davoud Taghawi-Nejad Avatar asked Jul 14 '12 10:07

Davoud Taghawi-Nejad


3 Answers

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)

like image 153
Davoud Taghawi-Nejad Avatar answered Oct 24 '22 18:10

Davoud Taghawi-Nejad


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}
like image 26
Tim Avatar answered Oct 24 '22 18:10

Tim


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!

like image 1
Yukun Chen Avatar answered Oct 24 '22 18:10

Yukun Chen