I want to make an Appendixpage which shows a simple minimal picture of all the appendices in the document. What I want is, that every time there is used \chapter{} after the \appendix command, there should be shown a picture of the appendix. Fx. if there is 5 appendices A, B, C, D and E on the Appendixpage there should be this: Perhaps with the title of the appendix if possible. I'm using report as the \documentclass.
- 157
1 Answers
Not a fully automated solution...some scripting would be required for that, but this a start. The basic idea is to compile your document, save the resulting pdf as a separate file, then, using tikz, create nodes with the first pages of the appendices.
Best demonstrated by an example (following the above approach, the resulting pdf was saved as file.pdf; see \pdfforappximgs):
\documentclass{report}
\usepackage[left=1in,top=1in,bottom=1in,right=1in]{geometry}
\usepackage{tikz}
\usepackage{graphicx}
\usepackage{etoolbox}
%File path for pdf used to provide the images for the appendices. Must be a separate document from \jobname for access.
\def\pdfforappximgs{file}
%The rotation angle of the last appendix (drawn first)
\def\appxcardsinitialangle{40}
%The angle by which each successive appendix is rotated clockwise from the previous one
\def\appxcardsanglestep{15}
%Multiplier to get the x coordinate from the index
\def\appxcardxfactor{0.25}
%Multiplier to get the y coordinate from the index
\def\appxcardyfactor{0.25}
%The scale factor for the page
\def\appxcardscale{0.125}
%Numer of cards in a single row
\def\appxcardperrow{7}
\makeatletter
% Array for appendices
\newcounter{appxpagecount}%
\newcommand\setappxpage[2]{\csgdef{appxpage#1}{#2}}%
\newcommand\addappxpage[1]{\stepcounter{appxpagecount}\setappxpage{\theappxpagecount}{#1}}%
\newcommand\getappxpage[1]{\csuse{appxpage#1}}%
%command to draw the appendix cards. Intened to be after \appendix.
\def\appxcoverpage{%
\chapter*{Appendices}%Add the heading to the cover page
%Redefine \chapter and \chapter* to reference the page
\let\old@chapter\@chapter%previous definition for the unstarred chapter
\let\old@schapter\@schapter%\previous definition for the starred chapter
\def\appendtochptexec{\protect\immediate\write\@auxout{\string\addappxpage{\thepage}}}%write to aux file the reference for the page
\gdef\@chapter[##1]##2{\old@chapter[##1]{##2}\appendtochptexec}
\gdef\@schapter##1{\old@schapter{##1}\appendtochptexec}
%Draw the cards
\expandafter\ifx\expandafter\relax\pdfforappximgs\relax\else
\IfFileExists{\pdfforappximgs.pdf}{}{\gdef\pdfforappximgs{\relax}}%Check that the file exists
\fi
\expandafter\ifx\expandafter\relax\pdfforappximgs\relax\wlog{No pdf file provided for appendix card display}\else%verify that the file is given and exists
\pdfximage{\pdfforappximgs.pdf}%Get the number of pages in said pdf
\edef\availpgs{\pdflastximagepages}
\ifnum\theappxpagecount=0\wlog{No appendices for appendix card display}\else%do nothing if there are no appendices
\expandafter\ifnum\getappxpage{\theappxpagecount}>\pdflastximagepages\wlog{Update the appendix pdf file...insufficient pages}\else%do nothing if there are not enough pages
%initialize the ranges
\newcounter{cmini}
\newcounter{cmaxi}
\setcounter{cmini}{1}
\setcounter{cmaxi}{\appxcardperrow}
\ifnum\thecmaxi>\theappxpagecount\relax\setcounter{cmaxi}{\theappxpagecount}\else\fi
%upper limit for the loop must be 1 greater than the count to ensure all are included
\newcounter{cexclup}
\setcounter{cexclup}{\theappxpagecount}
\addtocounter{cexclup}{1}
\loop\ifnum\thecmini<\thecexclup
\begin{center}
\begin{tikzpicture}
\foreach \x in {\thecmaxi,...,\thecmini}{
\pgfmathsetmacro\revx{\thecmaxi-\x+1};
\node[fill=white,draw,anchor=south west,rotate=\appxcardsinitialangle-\appxcardsanglestep*(\revx-1)] at (\appxcardxfactor*\revx,\appxcardyfactor*\revx) {\includegraphics[page=\getappxpage{\x},scale=\appxcardscale]{\pdfforappximgs.pdf}};}
\end{tikzpicture}
\end{center}
%advance the counters to the next row
\setcounter{cmini}{\thecmaxi}
\addtocounter{cmini}{1}
\setcounter{cmaxi}{\appxcardperrow}
\addtocounter{cmaxi}{-1}
\addtocounter{cmaxi}{\thecmini}
\ifnum\thecmaxi>\theappxpagecount\relax\setcounter{cmaxi}{\theappxpagecount}\else\fi
\repeat
\fi
\fi
\fi
}
\makeatother
\begin{document}
\chapter{Introduction}
Some text.
\chapter{Literature Review}
Some more text.
\chapter{Results and Discussion}
Even more text.
\appendix
\appxcoverpage
\chapter*{Supplementary Material 1}
Some text.
\chapter[shorter title]{Supplementary Material 2}
Some text.
\chapter{Supplementary Material 3}
Some text.
\chapter{Supplementary Material 4}
Some text.
\chapter{Supplementary Material 5}
Some text.
\chapter{Supplementary Material 6}
Some text.
\chapter{Supplementary Material 7}
Some text.
\chapter{Supplementary Material 8}
Some text.
\chapter{Supplementary Material 9}
Some text.
\chapter{Supplementary Material 10}
Some text.
\chapter{Supplementary Material 11}
Some text.
\chapter{Supplementary Material 12}
Some text.
\chapter{Supplementary Material 13}
Some text.
\end{document}
Some rough error checking is included in \appxcoverpage to ensure that the file name is provided (should be defaulted to \relax, there are appendices avaiable to draw, and that the referenced pdf is long enough.
The above example yields the following on the appendix cover page:
The \appxcardperrow command sets the maximum number of appendix cards shown in a group. As the number of appendices in a group increases, alternative effects are achieved:
-
Thanks for answer. I have inserted the above code, and it doesn't work for me. I have run the code. I had to uncomment the line " \appxcoverpage", otherwise it will not show anything. After that there are generated a pdf. and I rename it as "file.pdf" and runs the code again. It now displays alle the above, but not the picture with the appendices. Any idea what I does wrong ? – Simon Oct 18 '15 at 07:09
-
@Simon: I have updated the answer. Please try the revised code and let me know what you find. – Guho Oct 18 '15 at 07:13
-
Same problem as before. I have tried it a few times to be sure. Do you also have to uncomment the \appxcoverpage the first time to get something ? It's very sad, because I like your solutions a lot. – Simon Oct 18 '15 at 07:23
-
@Simon: Try putting
\relaxin place offilein\def\pdfforappximgs{file}. That should let it run. If it completes, save the resultingpdfasfile.pdfand replace\relaxwithfile. I'll add a check to prevent this error. – Guho Oct 18 '15 at 07:26 -
I have done something, which apperently works. I'm not sure, what I has done, but I think, that I had to create just a random file and name it file.pdf the first time I runs it, and then delete this file and rename the created file as file.pdf. When I run the code agin. The above is shown. – Simon Oct 18 '15 at 07:36
-
@Simon: Great to hear! I have updated the code to include a check to see if the file exists, which should prevent the error you encountered. – Guho Oct 18 '15 at 07:39
-
Create. It works even better. I think my solution would be a little enoying with time. Thanks a lot for the help. Good day. – Simon Oct 18 '15 at 07:42
-
@Simon: It's hard to say this, but you should really consider to accept the answers to your questions -- so far you ask questions only, requesting help by others here but haven't neither upvoted nor accepted the answers. I know who upvoted this answer so far ;-) – Oct 18 '15 at 10:07
-
Arh okay, thaks for the tip. I'm new at this forum, so I didn't knew. I try to remember next time :) – Simon Oct 18 '15 at 11:54
-
I have a problem with including the above code. The code can't handle this code, which produces page numbers of the appendices. \apptocmd\appendix{% \clearpage \pretocmd{\chapter}{% \clearpage \pagenumbering{arabic}% \renewcommand*{\thepage}{\thechapter\arabic{page}}% }{}{} }{}{}
Is there a way to solve this problem. Perhaps with another code to produces the page numbers.
– Simon Oct 31 '15 at 18:21



Appendix? Something like the playing cards above? – Oct 17 '15 at 20:30