# Placement parameters for tables and figures in appendix

I would like to know if it exists a way to include a table (or figure) in a section and display it in the appendix, in the following example:

\section{section}
stupid text where I speak about a table printed in the appendix

\begin{table}[APPENDIX]
\input{\folder/table.tex}
\end{table}


Here I continue my article and then comes something like:

\section{Appendix}
here should be my table


In this way I will have my tables and figure in the related section and they will be displayed only if I "print the section". They will also appear in the order of inclusion...

• You could have a look at package endfloat. – Johannes_B May 8 '18 at 10:51
• You could store it as a macro and expand it in the appendix. Where you expand it determines the caption number. – John Kormylo May 8 '18 at 13:20
• One commonly used trick is to create an elaboarate label (see tex.stackexchange.com/questions/301320/…) and use \ref to print it. For example, pgfplots can put the legend into a label. OTOH, this would require things like \string\begin{table}. – John Kormylo May 8 '18 at 13:28
• @JohnKormylo Do you an example of macro which can be expanded it in the appendix? – TeYaP May 9 '18 at 19:54

This shows how to create a macro and a savebox for later use. Note that the savebox increments the table counter immediately.

This is a demonstration, not a solution.

\documentclass{article}
\usepackage{caption}

\newsavebox{\appboxB}

\begin{document}
\section{Test}

Example text.

\newcommand{\appendA}{%
\begin{table}[htp]
\caption{Macro}
\end{table}%
}

\savebox{\appboxB}{%
\begin{minipage}{\columnwidth}
\captionof{table}{Savebox}
\end{minipage}%
}

\appendix
\section{Here}
\appendA
\begin{table}[htp]
\usebox{\appboxB}
\end{table}
\end{document}


This is a solution. It saves a list of global macros to be expanded in the appendix. \appendset saves the float, and \appendlist expands all of them.

\documentclass{article}

\newcounter{appendix}
\newcommand{\appendset}[1]% #1 = float to be expanded later
{\stepcounter{appendix}%
\expandafter\gdef\csname append\theappendix\endcsname{#1}%
}
\newcommand{\appendlist}% expand previously saved floats
{\bgroup
\count1=0
\loop\ifnum\count1<\value{appendix}\relax
\csname append\the\count1\endcsname
\repeat
\egroup}

\begin{document}
\section{Test}

Example text.

\appendset{%
\begin{table}[htp]
\caption{First}
\end{table}%
}
\appendset{%
\begin{table}[htp]
\caption{Second}
\end{table}%
}

\appendix
\section{Floats}
\appendlist
\end{document}


With the exception of requiring a \clearpage at the start, one can do the same thing using the endfloat package.

\documentclass{article}
\renewcommand{\efloatseparator}{\null}

\begin{document}
\section{Test}

Example text.

\begin{table}[htp]
\caption{First}
\end{table}

\begin{table}[htp]
\caption{Second}
\end{table}

\appendix
\section{Floats}
\clearpage% required
\processdelayedfloats

\section{Optional}
\end{document}

• It is an interesting solution. Unfortunately it does not work as I would like. I have 2 problems with your answer: 1 - once printed table"appboxB" is numerated 1 while table"appendA" has the number 2. I would like them to have their number of appearance. 2 - this solution forces me to print manually the tables and figures in the appendix, which is exactly what I do not want to do. I want them to be printed automatically (only for some chosen graph) in the good order. – TeYaP May 10 '18 at 8:43
• Showing the difference between macros and saveboxes was the point of the demonstration. – John Kormylo May 10 '18 at 13:46