Page LayoutInclude all Figures on single Pages in Appendix

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
gandi
Posts: 23
Joined: Tue Oct 20, 2009 2:45 pm

Include all Figures on single Pages in Appendix

Post by gandi »

I am writing a report with many figures, where usually each figure contains several graphs in one figure environment (i.e. several calls to \includegraphics per figure). I would like to keep the report itself compact, but it would be nice to have sort of an appendix where each graph (i.e. each single EPS file, not each figure with multiple graphs) is shown blown up on one full page, for better visibility.

Is there a LaTeX package that simply adds every single image that has ever been included previously by an \includegraphics command, on a separate page?

Thanks in advance.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

kaiserkarl13
Posts: 707
Joined: Tue Mar 25, 2008 5:02 pm

Include all Figures on single Pages in Appendix

Post by kaiserkarl13 »

Not one that I am aware of. However, the following shell script will probably do what you want to do:

Code: Select all

#! /bin/bash

graphicfile=allfigs.tex

if [[ ! -r "$1" && ! -r "$1.tex" ]]; then
    echo 1>&2 "Usage:  `basename $0` filename
           OR
        `basename $0` filename.tex"
    exit 1
fi

rm -f $graphicfile

if [[ -r "$1.tex" ]]; then
    infile="$1.tex"
else
    infile="$1"
fi

includedfiles=$(grep '\\\(include\|input\)\s*{' "$infile" | grep -v '%.*\\\(include\|input\)' | sed 's/.*\\\(include\|input\){//' | sed 's/}.*$//' | tr "\n" " " )

for file in "$infile" $includedfiles; do
    if [[ "$file" = `basename $graphicfile .tex` || "$file" = $graphicfile ]]; then
        true # do nothing
    elif [[ -r "$file" ]]; then
        imagefiles=$(grep "\\includegraphics" $file | grep -v "%.*\\includegraphics" | tr '\r' '\n')
        for graphic in $imagefiles; do
            echo >> $graphicfile "
                \\clearpage
                $graphic"
        done
    elif [[ -r "$file.tex" ]]; then
        imagefiles=$(grep "\\includegraphics" "$file.tex" | grep -v "%.*\\includegraphics" | tr '\r' '\n')
        for graphic in $imagefiles; do
            echo >> $graphicfile "
                \\clearpage
                $graphic
"
        done
    fi
done
Now add these lines to the end of your file, where you want the appendix to be:

Code: Select all

\appendix
\input{allfigs}
Run the script (generates "allfigs.tex"), then run LaTeX as usual.
The script is "smart" enough to handle you leaving off the extensions of included files (or not), and it also won't search through "allfigs.tex" for included graphics. All other included or inputted files will be parsed.
Post Reply