TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This is my first post here. I can usually find what I'm looking for using questions other people have asked, but this time I'm stumped. Please can anyone help? I am very new to Latex.

I am trying to insert text into the beginning of the body section of the generated pdf file via the sty sheet. However, in the case where a paragraph spans 2 pages, I can not figure out how to place text at the beginning of the pdf body on the second page. I don't want to change the header of the file, I want to automatically change the beginning of the body section via a sty sheet.

Is there a way to position and insert text from a style sheet? I am not sure if this is possible. Or maybe add the text to the next page of the pdf file before I insert the paragraph?

Thank you in advance for any help.

Update: I inherited a very complicated latex project, and I am not sure how to give you minimalized example code.

Maybe this example of what I want the pdf to look like will help?

I want each Paragraph to start with a persons name. If the paragraph extends into the next page, I want the pdf file to have the persons name and continued before the rest of the paragraph. Like this:

JOE Paragraph ....

SALLY Paragraph ....

--- Page Break

SALLY-CONTINUED Rest of Paragraph ....

I don't want to modify any of the chapter or section documents. I want the style file to automatically add the "SALLY-CONTINUED" when a page break is shown. Is this possible?

share|improve this question
Welcome. Can you provide a small example, MWE, showing the document structure you already have. – Andrew Swann Aug 15 '12 at 14:50
I don't quite get what you are exactly trying to do. But there is \AtBeginDocument which puts something right after \begin{document}. Also you can just define macros in your sty file and use them in the document. – canaaerus Aug 15 '12 at 16:52

No, that cannot be done more or less easily.

First TeX breaks the paragraph into lines, then at a later time, if the output routine is called, the lines are put on the pages. When TeX constructs the paragraphs, it does not know, where the page breaks will be. But that influences the paragraph breaking because of the added text.

Label method

Package soul would allow to add \labels at each breakpoint of the text. Then at these labels can be checked and if a new page is reached, the continuation text can be inserted inside the paragraph. However this method have serious disadvantages:

  • Limitations of package soul, see documentation. (Less serious for simple text.)

  • The added text might increase the number of lines in the paragraph affecting the following page breaks. Thus a huge number of LaTeX runs might be necessary.

  • The added text might change the line breaking and the added text is on the wrong page in the second run. That is very difficult to handle and the document might never stabilize without manual intervention. (Package varioref has a similar problem, if the inserted reference text changes the location of the reference.)

Marks register

If you can put the continuation text somewhere else at a fixed place (in the head line, above the text body, ...), then a marks register helps:



  \MakeUppercase{#1\marks\MarksPerson{(#1 continued)}}:%









Here the continuation text is put above the text body:

enter image description here

share|improve this answer
This helped alot. Thank you. – user1599585 Aug 15 '12 at 23:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.