Suppose I want to create an in-class text. Suppose further that as a lecturer I want my copy of the text to have copious amounts of ancillary material (notes, solutions to exercises, blackboard examples, etc.) included. The mass of additional material won't fit comfortably in the margins, so what I'd want to do is have additional insert pages that appear at the end of each section, such that if I removed them from my version of the text the resulting pages would be identical to the students' version (so that the page numbers correspond exactly).
Here's a minimum working example that simply adds or removes material in an ancillary environment:
\documentclass{article}
\usepackage{lipsum}
\usepackage{verbatim}
\newif\ifshowancil \showanciltrue
\ifshowancil
\newenvironment{ancillary}%
{\itshape
\newpage
%And other stuff...
}%
{\newpage
%And other stuff...
}
\else
\newenvironment{ancillary}{\comment}{}
\fi
\begin{document}
\lipsum[1-20]
\begin{ancillary}
\textbf{Here is the beginning.}
\lipsum[21-30]
\textbf{And the end.}
\end{ancillary}
\lipsum[31-40]
\end{document}
What I would like is for the anciltrue version to compile identical to the ancilfalse version, but with the stuff in the ancillary environment typeset independently of the rest of the document, beginning on the next page (like a float), with "temporary'' page numbering (e.g. 30a, 30b, etc. if it follows page 30).
Is such a scheme possible without too much labor? I'm thinking a solution would require tinkering with the output routine, hence the tag.

afterpageor something andpageslts. – cfr Jul 25 '16 at 03:26\color{white}inside that environment when the boolean is false, so that the pagination does not change. – Jagath Jul 25 '16 at 03:36afterpage. I must investigate further... – Jon Jul 25 '16 at 11:20afterpagemight allow you to do without this, though I'm not certain. – cfr Jul 25 '16 at 11:26afterpageis showing lots of promise. – Jon Jul 25 '16 at 11:59