[texhax] LaTeX programming question

tom sgouros tomfool at as220.org
Sat Apr 26 16:19:06 CEST 2008

Josh:

You have asked a hard question, which is why no one is answering much.
In order to do what you want to do, you'll need to get into the \output
routines, which is a confusing and odd sort of place, since they are
called asynchronously from everything else.  The approach I've used in
the past is to take the latex \output routine (it's in latex.ltx) copy
it into your own package, and modify it carefully.

\documentclass{article}
\usepackage{fancyhdr}
\usepackage{testing}

\global\newbox\parflag
\global\newbox\parflagnext
\setbox\parflag=\hbox{}

\pagestyle{fancy}
\raisebox{-50pt}[0pt][0pt]{\unhcopy\parflagnext}}
\unhbox\parflagnext%
\global\setbox\parflagnext=\hbox{\unhbox\parflag}}

\newenvironment{special1}{\global\setbox\parflag=\hbox{\textbf{P1}}%
\global\setbox\parflagnext=\hbox{\unhcopy\parflag}%
\noindent\hspace{-\wd\parflag}\unhcopy\parflag\hspace{\parindent}}{}

You'll need to do some more work to get it right, but I think something
like this will work for you.

There's a box here called \parflag and a friend called \parflagnext.  I
think you can use the \output routines to load them appropriately with
the data you want, but I am going to leave you to come up with the
arrangement of flags to make it work.  The nonintuitive things you have
to watch out for are that the headers are applied to the page *last*,
and the paragraph in your special environment has all been typeset
before the page is broken.  (So you can't use the closing of the
environment to erase any of the boxes, because they'll be missing when
the page breaks.)

Hope this helps, and good luck,

-tom

--
------------------------
tomfool at as220 dot org
http://sgouros.com
http://whatcheer.net