[texhax] creating a summary document

Susan Dittmar Susan.Dittmar at gmx.de
Fri Feb 24 10:56:36 CET 2012


Quoting Fehd, Ronald J. (CDC/OCOO/ITSO) (rjf2 at cdc.gov):
> ** two docs with input
> 
> - - - MyDoc-long.tex
> %etc
> \begin{document}
> \input(MyDoc-claim1)
> \input(MyDoc-claim1-rationale)
> 
> \input(MyDoc-claim2)
> \input(MyDoc-claim2-rationale)
> \end{document}
> 
> - - - MyDoc-short.tex
> %etc
> \begin{document}
> \input(MyDoc-claim1)
> %\input(MyDoc-claim1-rationale)
> 
> \input(MyDoc-claim2)
> %\input(MyDoc-claim2-rationale)
> \end{document}
> 
> summary: two complete documents, with differing number of pages
> 
> Ron Fehd {SAS} macro maven

Alternative with the same result, but with three documents, two of which
will *not* be touched after first creation, even when adding new claims and
rationales:

------- MyDoc-long.tex    <--- run latex with this to generate whole document
\newcommand{\claim}[1]{\input{#1}}
\newcommand{\rationale}[1]{\input{#1}}
\input{MyDoc}
------- MyDoc-short.tex   <--- run latex with this to generate short document
\newcommand{\claim}[1]{\input{#1}}
\newcommand{\rationale}[1]{}
\input{MyDoc}
------- MyDoc.tex         <--- this one will be edited
\documentclass{...}
...
\begin{document}
\claim{MyDoc-claim1}
\rationale{MyDoc-claim1-rationale}

\claim{MyDoc-claim2}
\rationale{MyDoc-claim2-rationale}
...
\end{document}
-------


Another version, allowing for keeping claim and rationale in the same
(sub-)document, using an environment for the rationale. Except from that,
the same usage as above:

------- MyDoc-long.tex    <--- run latex with this to generate whole document
% take enclosed material as is:
\newenvironment{rationale}{}{}
\input{MyDoc}
------- MyDoc-short.tex   <--- run latex with this to generate short document
% after working through enclosed material, throw it away:
\newenvironment{rationale}{\begingroup\setbox2=\vbox\bgroup}{\egroup\setbox2=\hbox{}\endgroup}
\input{MyDoc}
------- MyDoc.tex         <--- this one will be edited
\documentclass{...}
...
\begin{document}
claim 1
\begin{rationale}
rationale 1
\end{rationale}

claim 2
\begin{rationale}
rationale 2
\end{rationale}
...
\end{document}
-------

This way you still *can* create files per rationale (makes editing and
reordering much easier), but you need not. And you can keep claim and
rationale together in one document.

I have to admit I do not completely understand how the rationale
environment does what it does. I copied the idea from songbook.sty (see
CTAN) and use it a lot. Maybe the \begingroup and \endgroup are
unnessessary. If so, I hope one of those more familiar with TeX internals
will chime in.

I would recommend creating a command (common or different between the two
documents) for typesetting the claim too, to make sure they are always
typeset in the same way thoughout the whole document. Common formatting for
the rationale can be included in the rationale environment definition in
the MyDoc-long.tex file.

Hope that helps,

	Susan



More information about the texhax mailing list