tags:

views:

185

answers:

3

I am writing a document that has a set of "task lists" scattered throughout. I want to have a single list of all of the tasks at the end. It seems to me that I should be able to do this with the same sort of intermediate files that are used for the table of contents, list of tables, and list of figures. But I just can't figure out any way to do it --- I've tried adding \addtocontents with a different extension, but that doesn't seem to work. Does anybody have an idea of how to do this?

+2  A: 

You can do:

\newwrite\tempfile

in your preamble to declare a new file writer.

Then, to open a file when you want to, you can assign the writer to a file and open it:

\immediate\openout\tempfile=lists.txt

To write to the file:

\immediate\write\tempfile{this is interesting}

Finally, close the file with:

\immediate\closeout\tempfile

To read a file, it could be as simple as \input, or you can use \newread, \openin, \read and \closein combination.

Is this what you want to do?

Edit: This "works for me":

\documentclass{minimal}
\newwrite\tempfile
\begin{document}
\immediate\openout\tempfile=lists.tex
\immediate\write\tempfile{this is interesting}
\immediate\write\tempfile{}
\immediate\write\tempfile{this too}
\immediate\closeout\tempfile
\input{lists}
\end{document}
Alok
This is what I want to do. The problem I am having is that when I `\input` the the tempfile it is blank. I need to move it to another file to get the input to work. Any idea how to open the file in the same context, the way that the lot and lof files are done?
vy32
@vy32: please see my edit.
Alok
That's great. My code didn't have the \closeout. Thanks again. I've tried to find good documentation for these TeX internals and just can't find them. I really appreciate the help!
vy32
+2  A: 

I haven't had much luck with the \addtocontents mechanism. I have much better luck writing arbitrary LaTeX code to the .aux file. The examples are really too big to post in an SO answer, but you can find one in the noweb in the way "subpage labels" are handled, and you can find something similar in my technical report Teach Technical Writing in Two Hours Per Week, which accumulates some lists of principles and practices. The noweb source is public (and in Debian), and if anyone wants to the the other, send me an email.

For stuff like this, I encourage you strongly to dig under the LaTeX layer and study The TeXbook by Donald Knuth. That's the place where the mechanisms available are really explained.

If your list of tasks is really going to come at the end, you can avoid all the nonsense and just allocate a global tokens register which you accumulated throughought the document. You'll find some helpful ideas and examples in Appendix D of The TeXbook (Dirty tricks).

Norman Ramsey
A: 

you would want the todonotes package for LaTeX:

\usepackage{todonotes}

\begin{document}

\todo{This will be a note typeset in the margin}
\todo[inline]{This will be an in-line todo}
\missingfigure{This will give me a box indicating a pic should go here}

\listoftodos % will give you all of your todos from the document.

http://www.tex.ac.uk/tex-archive/help/Catalogue/entries/todonotes.html

Mica
I don't think that this is actually what the OP had in mind, but I'll look at it. I've been using a little, hand-hacked "fixme" package for this purpose, but it's a little fragile.
dmckee
yeah I figured that, but if you get the .sty file, you could easily strip out all the tikz commands (that provide the colored blurbs and background) and still leave the functionality to get the list that he wanted. I realize now that I wasn't that clear about that. It was early in the morning when I answered :D ... I'm trying to develop ISO compliant warning and caution labels based on the \missingfigure command that this package provides. I suspect he coudl do similar with the \todo command. It's not complete, but with minimal effort, i'm sure it could work.
Mica
OMG that is an amazing package, I am so glad that you told me about it, but it's not what I need here.
vy32
lol... glad I could be of help, and sorry it's not the help you needed. But this package is quite good, I use it all the time...
Mica