Created
April 15, 2012 06:34
-
-
Save henrikh/2390445 to your computer and use it in GitHub Desktop.
Take all figures from a LaTeX document and make a new document with only them.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#It's a shell script that should work on all Unix systems with pdflatex and pdfpages installed. You use by giving it the file name of the tex file (no .tex ending!) and the offset in pages (caused by front matter) as the second argument: | |
# | |
# ./only-figures.sh document 1 | |
# | |
# | |
#First we load the .aux and prepare to store it in a variable. | |
STR=$(cat $1.aux |\ | |
#We only care about the lines with figures. | |
grep figure |\ | |
#And of these lines we only care about the number referring to unique pages. | |
sed 's/.*}}{\([1-9]*\)}}/\1/' | uniq |\ | |
#We then add the offset to the page numbers. | |
awk '{print $0+'$2'}' |\ | |
#And finally pack them all up in a comma-separated list. | |
sed ':a;N;$!ba;s/\n/,/g') | |
#A template file is used for the new temporary document. | |
cat template.tex | sed s/@@@/$STR/ > only-figures-tmp.tex | |
#We call pdfLaTeX on the temporary file, move the new PDF and cleans up. | |
pdflatex only-figures-tmp | |
mv -f only-figures-tmp.pdf $1-only-figures.pdf | |
rm only-figures-tmp.* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass{article} | |
\usepackage{pdfpages} | |
\begin{document} | |
\includepdf[pages={@@@}]{document} | |
\end{document} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment