Skip to content

Instantly share code, notes, and snippets.

@dettmering
Created November 9, 2012 12:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dettmering/4045392 to your computer and use it in GitHub Desktop.
Save dettmering/4045392 to your computer and use it in GitHub Desktop.
Bash: Add all EPS files in the directory to a TeX file
#!/bin/bash
# Puts all eps files in folder in figure environment
rm figures.tex
echo "\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx} % support the \includegraphics command and options
\usepackage{epstopdf}
\begin{document}
" >> figures.tex
for f in *.eps
do
g=$(echo $f | sed 's/\(.*\)\..*/\1/')
echo "\begin{figure}[p]
\centering
\includegraphics[width=\textwidth]{$f}
\caption{$f}
\label{fig:$g}
\end{figure}
" >> figures.tex
done
echo "\end{document}" >> figures.tex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment