Basic ReLaTeX Tutorial

A Simple Document

Directory example1 contains a very simple Latex document for testing different journal templates. You can test it as follows on the PLoS template (the --email option gives the corresponding author’s email address, required by PLoS):

cd example1
python ../relatex.py plos simple.tex --email yogi@cs.technion.ac.il --extract-figures

This inserts the document’s contents into the PLoS template, and outputs it as simple_plos.tex. You can now generate a PDF in the usual way, e.g.:

pdflatex simple_plos.tex
bibtex simple_plos
pdflatex simple_plos.tex
pdflatex simple_plos.tex

A Real Paper

Directory example2 contains a full paper, generated from reStructured Text by the Python Sphinx package. We can test inserting it into the PNAS and PLoS templates as follows:

cd example2
python ../relatex.py pnas test.tex --bbl multihit.bbl --extract-figures --extract-tables

The --bbl option informs relatex of a .bbl bibliography file that the PNAS template requires (PNAS requires that the bibliography actually be inserted into the latex document itself; relatex does this for you).

For PLoS:

python ../relatex.py plos test.tex --no-subsection-numbers --email leec@chem.ucla.edu --extract-figures --extract-tables

PLoS requires the removal of subsection numbering, and also an email address for the corresponding author; the command-line options above provide this information.

You then generate PDFs from the resulting test_pnas.tex and test_plos.tex output files as usual.

Using ReLaTeX with Sphinx

Sphinx configuration: to handle cite and bibliography reStructured text commands properly (generating latex \cite and \bibliography output), you must use the bibcite Sphinx extension, which you can obtain from https://bitbucket.org/foobaron/bibcite.

  • install (or link) bibcite.py in your sphinx-ext directory.

  • edit your Sphinx conf.py config file to ensure that sphinx-ext is added to the Python path, and that bibcite is added to Sphinx’s imports, e.g.:

    # If extensions (or modules to document with autodoc) are in another directory,
    # add these directories to sys.path here. If the directory is relative to the
    # documentation root, use os.path.abspath to make it absolute, like shown here.
    sys.path.append(os.path.abspath('sphinx-ext'))
    
    # -- General configuration -----------------------------------------------------
    
    # Add any Sphinx extension module names here, as strings. They can be extensions
    # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
    extensions = ['sphinx.ext.jsmath', 'bibcite']
    

We recommend you use the howto Sphinx document style (instead of the manual style, which is more appropriate for a book format rather than an article format).

If you don’t specify an input file path, ReLaTeX will look automatically in your _build/latex directory (where Sphinx writes its latex file). So you can run ReLaTeX by just specifying the template name:

make latex
relatex.py pnas --bbl my.bbl --extract-figures --extract-tables

ReLaTeX will write its output in the same directory as the input.

ReLaTeXing a paper for arXiv

arXiv requires that papers written in LaTeX be submitted as tex files rather than as PDF. Unfortunately, if your tex file doesn’t fit arXiv’s expectations, it will be rejected. For example, tex files generated by Sphinx require special packages provided by Sphinx, so arXiv will not accept them, because arXiv’s automatic PDF creation process will fail. You can solve this problem by ReLaTeXing your tex file to a generic tex format (with no odd package requirements) that arXiv will accept:

python /path/to/relatex.py generic paper.tex --email you@biguniversity.edu

This produces paper_generic.tex, which you can upload to arXiv. (You can also pdflatex and bibtex it in the usual way).