Skip to content

Instantly share code, notes, and snippets.

@mihids
Last active August 29, 2015 14:09
Show Gist options
  • Save mihids/94160a67d6e59232d69c to your computer and use it in GitHub Desktop.
Save mihids/94160a67d6e59232d69c to your computer and use it in GitHub Desktop.
#!/bin/bash
print_usage (){
echo “USAGE:”
echo -e “\t $figtex2ps inputfile.fig”
}
#Compile Xfig figures with LaTeX commands
if [ "$1" = "" ]; then
print_usage
exit
fi
#fig=$1:r
fig=$1
echo $fig
##Convert fig -> pstex
fig2dev -L pstex $fig.fig $fig.pstex
fig2dev -L pstex_t -p $fig.pstex $fig.fig > $fig.tex_1
##We create the tex document c
echo creation de $fig.tex
cat << EOF > $fig.tex
\documentclass[10pt]{report}
\usepackage{graphicx,color,epsfig,subfigure}
\usepackage{amsmath,amsfonts,amssymb}
\usepackage{bm}
\pagestyle{empty}
\begin{document}
EOF
cat $fig.tex_1 >> $fig.tex
echo '\end{document}' >> $fig.tex
##Compilation
latex $fig.tex
dvips $fig.dvi -o -E
epstopdf $fig.ps
## For a PDF export, add the line : “epstopdf $fig.ps”
#Cleanup
\rm $fig.pstex $fig.tex_1 $fig.aux $fig.log $fig.dvi $fig.tex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment