NEW VERSION to respond to revised OP requirements. EDITED to use a \protected@edef
as part of \problem
to facilitate the use of braces \{...\}
in the footnotes.
It uses the syntax \problem[]{question}{answer}
. At this stage, the user must invoke the footnotes in one of two ways:
\showpageanswers
following the final \problem
on any given page; or
provide anything (other than \relax
) as an optional argument to the last \problem
on any given page.
I tried to automate this on a page-by-page basis, but was unsuccessful.
The problem counter will carry over page to page.
I modified \showpageanswers
so than its invocation without any answers to show will be ignored.
To get the footnote to be able to extend past a single line in length (i.e., paragraph style), I put it in a \parbox
. I also kerned -18pt before the rotated \parbox
, to account for the footnote indent, and added a \strut
to end of inverted footnote definition (\revfootnote
), for subsequent vertical spacing.
Note however, if multiple answer sets appear on the same page, saving all the answers for one single footnote invocation per page will prevent the "appearance of" misordered footnotes (since turning them upside down changes the sense of first and last).
Here is the MWE
\documentclass[12pt]{article}
\usepackage{graphicx,lipsum}
\usepackage{enumitem}\newsavebox\fnbox
\def\pageanswers{}
\newcounter{problemNo}
\makeatletter
\newcommand\problem[3][\relax]{%
\stepcounter{problemNo}%
\par\smallskip%
\theproblemNo.~~#2?%
\par\smallskip%
\protected@edef\pageanswers{\pageanswers$^{\theproblemNo}$#3\ \quad}%
\ifx\relax#1\else\showpageanswers\fi%
}
\makeatother
\newcommand\showpageanswers{\if\relax\pageanswers\relax\else%
\revfootnote{\pageanswers}\def\pageanswers{}\fi}
\newcommand\revfootnote[1]{\renewcommand{\thefootnote}{}%
\footnotetext{\savebox\fnbox{\parbox{%
\dimexpr\textwidth\relax}{#1\strut}}\kern-18pt%
\rotatebox{180}{\usebox{\fnbox}}}}
\begin{document}
Solve these problems.
\problem{What is 1+1}{two $\{abc\}$}
\problem{What is 1+2}{three}
\problem{What is 1+3}{four}
\problem{What is 1+4}{five}
\problem{What is 1+5}{six}
\problem{What is 1+6}{seven}
\problem{What is 1+7}{eight}
\problem{What is 1+8}{nine}
\lipsum[1]
\problem{What is 2+1}{three}
\problem{What is 2+2}{four}
\problem{What is 2+3}{five}
\problem[x]{What is 2+4}{six}
\lipsum[2-4]
Solve these problems.
\problem{What is 1+1}{two}
\problem{What is 1+2}{three}
\problem{What is 1+3}{four}
\problem{What is 1+4}{five}
\problem{What is 1+5}{six}
\problem{What is 1+6}{seven}
\problem{What is 1+7}{eight}
\problem[x]{What is 1+8}{nine}
\lipsum[5-8]
\end{document}


\documentclass{...}
and ending with\end{document}
.