3

I am trying to collect say fruits mentioned in a page and print them at the bottom of the next page. All text is always enclosed in a frame and the frame can span multiple pages but the collected fruits always have to be printed at bottom of the next page after being mentioned in a page. The problem is that if two frames start on a page and the fruits inside second frame appear in the next page they will be printed together with that of first frame but that shouldnt be the case.

\documentclass{article}
\usepackage{blindtext}
\usepackage{atbegshi}
\usepackage{picture}
\usepackage{mdframed}
\usepackage{collect}


\newenvironment{fruit} {\begingroup\edef\x{\endgroup\noexpand\collectfruits}\x}{\endcollect}


%to print to bottom of next page after fruits named on page
\newcommand{\printbottomNext}[1]{
{\LARGE print on bottom of next page\\}
  \AtBeginShipoutNext{%
  \AtBeginShipoutUpperLeft{%
    \put(0.1\paperwidth,-0.95\paperheight){#1}%
  }%
}
}

\definecollection{fruits}

\newcommand\collectfruits{%
\collect{fruits}
{}
{}
{}%
}

\begin{document}

\begin{mdframed}[frametitle=with apple and orange]

 \blindtext[3]
 \begin{fruit}
 apple
 \end{fruit}

 \begin{fruit}
 orange
 \end{fruit}

 \printbottomNext{\includecollection{fruits}}
 \blindtext[2]

\end{mdframed}

\begin{mdframed}[frametitle=with pineaple and banana]

 \blindtext[3]
 \begin{fruit}
 pineapple
 \end{fruit}

 \begin{fruit}
  banana
\end{fruit}

 \printbottomNext{\includecollection{fruits}}
 \blindtext[2]

\end{mdframed}

\end{document}
  • I don't get the results you describe. When I compile your example, I always get the fruits printed at the bottom of the first page on which the frame appears. So, in this case, I get 'apple orange' on page 1 and 'pineapple banana' on page 2. While this is not what you want, I don't seem to be seeing the problem you are actually trying to solve. If I take the command outside the frame, I get 'apple orange pineapple banana' at the bottom of both page 2 and page 3. – cfr Jun 15 '14 at 20:34
  • Do you need to use a environment to collect the fruits, or would a macro work as well? i.e., would it be acceptable to say \Fruit{banana} instead of \begin{fruit}banana\end{fruit}? And is there a possibility of multiple fruits – Peter Grill Jun 16 '14 at 2:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.