As I see it, documentclass needs to know about \UserProvidedText before the document source is itself read (I am presuming that TeX simply reads documentclass, and then goes on with reading the rest of the source).

You might want to rephrase your questions, especially 1. You want to have user macros which stores their content in boxes which are then displayed in certain points of the template by the class code, don't you?
–
Martin Scharrer♦Feb 28 '11 at 11:37

Could you be more specific? I think I understand the problem, but we can't tell what challenges you're encountering. Can you post a minimal example of what you've done so far and the undesired output? The answer to the question "Is this possible" is usually "Yes, if you do it right;" but that may not be the right question.
–
Matthew LeingangFeb 28 '11 at 13:00

I added a small code snippet with an explanation of what I am troubled with. I lack the knowledge to be able to explain it better without further questions or guidance.
–
ipavlicFeb 28 '11 at 13:31

1 Answer
1

The document class itself shouldn't produce any output, which is what your tikzpicture environment is attempting to do. One way to get around that is to save that code in an \AtBeginDocument command. For example, here is a class file, which I have named ipavlic.cls:

The \LoadClass{article} command makes this class basically a “derived class” of the standard article.cls; probably a good idea to not start from scratch. :D The article class provides the \title command with the exact same functionality that I renewed it to; I just did that to show you what it does. It saves its input in a macro \@title (the @ sign is a just a convention for class/package-internal macros. It somewhat protects this text from being overwritten accidentally.) The \AtBeginDocument macro saves its input for execution right after \begin{document}.

Note also that it's TikZ nodes that contain text, not rectangles. And you don't need to save the title in a box then put it in a node—TikZ will probably take care of that for you.

A disadvantage to this implementation is that because it relies on TikZ's remember picture mechanism, you have to run LaTeX twice to get the title in the right place.

Another method would be to alter the shipout routines which are executed at the end of every page. Your custom routine would place all of the rules and extra info outside of the regular type block. If it were me doing that I would use the pgfpages package but there are methods with less overhead I'm sure.

That's very helpful! I know the basics of TikZ but am calculating box sizes in order to draw a "table" grid (tex.stackexchange.com/questions/11937/…). Just to clarify, it is my understanding that TikZ needs two runs for remember picture. So if I want to use TikZ, I am forced to run it twice. Is that so?
–
ipavlicFeb 28 '11 at 14:14

@ipavlic: That's correct. Perhaps you can get away with using the anchors that TikZ attaches to its nodes to draw the grid lines. But in the end you will need to define the size of the type block based on the sizes of all your little nodes--which sounds like a headache to me. Knock yourself out, but if I were doing this I would fix the grid (maybe relative to the font size) and leave it up to the user to make sure his text fit in the grid. That's how real-world, paper, templated forms work.
–
Matthew LeingangFeb 28 '11 at 14:31