4

Is it possible to have diverging values for \textwidth on the first page and all other pages.

On the first page I would like to set the width of the text to 12cm, on the following pages to 16cm.

\documentclass[ngerman,12pt]{scrlttr2}
\usepackage{babel,blindtext}

\setlength{\textwidth}{12cm}

\setkomavar{fromname}{Just me}
\setkomavar{fromaddress}{Just some place}

\begin{document}
\begin{letter}{Some one \\ Some Place}
\opening{fsdfsdafs}

\blindtext[5]

\closing{Best wishes}
\end{letter}
\end{document}
9
  • why do you want to change \textwidth (which is hard to coordinate with the output routine) rather than just change the width of the text (which is trivial, eg using an environment based on quote using a different, possibly negat?ive, indent) Commented Nov 3, 2013 at 10:36
  • I thought that adjusting \textwidth would be the right way. Commented Nov 3, 2013 at 10:43
  • Also when changing the width it is much much easier to have a forced page break, as changing the width mid-paragraph requires multiple passes and calculating a \parshape. Is a forced page break acceptable? Commented Nov 3, 2013 at 10:51
  • No, not really. The text should flow normally, without the need to enforce a pagebreak. Commented Nov 3, 2013 at 11:15
  • Ah in that case changing \textwidth is the least of your worries. It's not really possible in TeX in general but so long as there is only normal text and no large inserts, so you can guess accurately how many lines are on the page it is possible in simple cases. Commented Nov 3, 2013 at 11:19

1 Answer 1

4

The basic technique is like this:

enter image description here

\documentclass[ngerman,12pt]{scrlttr2}
\usepackage{babel,blindtext}

\setlength{\textwidth}{16cm}

\setkomavar{fromname}{Just me}
\setkomavar{fromaddress}{Just some place}

\def\pshape#1{%
\parshape #1 \pshapexiicm{#1} 0pt 16cm }

\def\pshapexiicm#1{%
 \ifnum#1>1 0pt 12cm \expandafter
  \pshapexiicm\expandafter{\the\numexpr#1-1\expandafter\relax\expandafter}\fi}

\begin{document}



\begin{letter}{Some one \\ Some Place}
\opening{fsdfsdafs}

\pshape{26}
aaa\blindtext[5]

\closing{Best wishes}
\end{letter}
\end{document}

To make it more general you need to trap paragraph breaks and restart the new paragraph with a \parshape that has a reduced number of short lines, depending on how many lines you just did. (code could be stolen from the wrapfig package for that:-)

If however you have stretch parskip or anything else complicated on the page working out exactly how many short lines you need can be challenging.

2
  • Is it more easier to use afterpage? Commented Nov 3, 2013 at 11:45
  • 1
    @MarcoDaniel It's easy to use afterpage, it just doesn't help. Commented Nov 3, 2013 at 11:51

You must log in to answer this question.

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