latex to pdf in a nautilus script

September 15th, 2006

The vast majority of my writting is done using gedit and latex. I have often thought it would be great to have a gedit plugin that would allow for a one button solution to converting the latex document into a pdf file and opening it in evince. I do not have enough time at this moment to develop such a solution, though I did find a good way of scratching my itch. I chose to write a nautilus script in bash that would accomplish the same task. First create the script in your nautilus script directory.

gedit ~/.gnome2/nautilus-scripts/latex\ to\ pdf

Next paste in the following script.

#!/bin/bash

# Runs the file through pdflatex and opens it in evince if the pdf file exists

if echo $1 | grep -i “.tex”; then
pdflatex $1
PF=${1/tex/pdf}
if [ -f $PF ]; then
evince $PF
else
zenity –info –title=”latex to pdf” –text=”Failed to create the PDF file.”
fi
else
zenity –warning –title=”latex to pdf” –text=”File must be a latex file with the extension .tex”
fi

Then make the script executable.

chmod +x ~/.gnome2/nautilus-scripts/latex\ to\ pdf

Now you are able to right click on a latex file and select the “latex to pdf” script to convert it to a pdf file and open it up in evince.

Entry Filed under: Gnome

1 Comment Add your own

  • 1. fallino  |  September 16th, 2009 at 1:41 pm

    Thanks dude !

Leave a Comment

hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


Calendar

September 2010
M T W T F S S
« Aug    
 12345
6789101112
13141516171819
20212223242526
27282930  

Most Recent Posts