This question is connected with How to put figures at the end of pdf file. As one can see from @cfr's and mine comments, I hoped, that it was a question, how to put a code of figures, wich are lying in the middle of text, at the end of file.
I have some ideas, how it could be realized. Some commands may be of the form \ifundefined... before they are defined to prevent errors. Additionally commands from the end of a file could be written to external files and read near \begin{document}. As I understand, graphic files are in TikZ/PGF, PostScript, PSTricks or some other tool, which produces graphics during a TeX compilation.
There is no MWE, because I wish rather to be warned by experienced users about potential pitfalls of solving the problem with help of external files. It is also possible, that my idea is naive and there exists completely different solution. For example, the problem Going through permutations of nouns and verbs, which seemed to be really difficult for me, was solved in thirty minutes.
I understand that I might be more precise, but the most important for me is all, what I cannot predict, hence even the sketch of my idea is only a suggestion of a starting point.
boxhandlerpackage to defer figures (and/or tables) to a later point in the document, including the end. – Steven B. Segletes Nov 07 '14 at 03:18\ifundefinedfor? Again, is it really the code you want at the end or the figures typeset or both? If I had to guess, I'd guess you want the figures typeset in the middle of the text but the code for the figures at the end of the file. – cfr Nov 07 '14 at 03:29\newcommandconditionally and then use\providecommandto cover the first run. Or you could use\newcommandand then input the file containing\renewcommandconditionally. (\IfFileExists) – cfr Nov 07 '14 at 03:45