I am creating lots of letters using the scrlttr2 package and some variables that change per letter. The contents of these variables might cause the letter to take up an additional page that I would like to avoid. For example, some people have addresses that take up more lines than others, but there are other variables that can cause this to happen as well. When I have room, I want to set \KOMAoptions{parskip=full} because it looks nicer, but if I'm out of space I would like to set \KOMAoptions{parindent}. Is there a good way to do this automatically? Here are some options I thought of:

  1. Define a command with the body of the letter. Use \KOMAoptions{parskip=full} and \savebox with the address and the body command to get its height. If the height is over a certain amount, then set \KOMAoptions{parindent}. Then use the body command again to output the actual letter. I'm not sure how to get the height and switch on it, and defining the whole letter and its included environments in a single command sounds clunky.

  2. Make two versions of the document. In my Makefile, somehow identify the length in pages (how?) of the parskip version and substitute the parindent version if necessary

  3. Just set another variable to define this, and set it manually for each letter (this is what I am doing now).

Other ideas welcome.

  • If it goes over 2 pages and switching to parindent does not make it one page, do you want to stick with parskip=full?
    – StrongBad
    Oct 3, 2012 at 17:39
  • If it still goes over two pages, I am going to remove some text, but if it's easier we can assume that's not going to happen. Oct 3, 2012 at 17:45

1 Answer 1


This can be done by using the same strategy I used here. It has the same dependence on nothing screwing up \AtEndDocument.


    \ifnum\value{page} = 1%

  • Thanks, brilliant answer. For my scrlttr2 document, \value{page} called within \AtEndDocument always seems to be one more than the number of pages produced, so I had to change the code to \value{page} < 3. Oct 4, 2012 at 13:38
  • I occasionally get that problem when completely filling up the previous page in documentclasses such as article, even when I don't take up any space in the next page. Is there a way to see whether any text exists on page two at all? Oct 26, 2012 at 3:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .