[texhax] Avoid paragraph indentation on new page?

Morten Høgholm morten.hoegholm at gmail.com
Fri Nov 23 22:39:21 CET 2007


On Fri, 23 Nov 2007 12:08:25 +0100, Edsko de Vries wrote:

> Hi,
>
> Is there a way to avoid the parindent at the start of a new page? At the
> moment, I do this manually by inserting a \noindent before each
> paragraph that starts a new page, but obviously this is extremely
> fragile---I'd much prefer an automatic solution.

IF (big if) you wish to do this (after all that has been said in this  
thread) you should be aware that you have to intervene at special places.  
Using something like everypage does not work because it happens much too  
late: you want something to intervene in the paragraph breaking.

Your best bet for this is hijacking \everypar in combination with  
something storing the position on the page such as \pdfsavepos which  
exists in a more user-friendly incarnation in the zref package. So for  
each new paragraph begun with \everypar, set a position marker with zref.  
Then check the vertical position of the marker. If it falls on the top  
line of the page, remove the paragraph indentation.

Here is a small example:

\documentclass{article}

\usepackage[savepos]{zref}


\newcounter{par-position}

\newcommand*\checkandfixparindent{%
   \stepcounter{par-position}%	
   \message{\zposy{par-\number\value{par-position}}}%
   \ifnum\zposy{par-\number\value{par-position}} > 46500000\relax
   % the value depends on your layout - check with the messages written
     \begingroup\setbox0\lastbox\endgroup% remove indention box
   \fi
   \zsavepos{par-\number\value{par-position}}%
}


\makeatletter
\AtBeginDocument{\addto at hook\everypar{\checkandfixparindent}}
\makeatother

\setlength\textheight{5cm}


\begin{document}

\input{tufte}\par \input{tufte}\par \input{tufte}\par
\input{tufte}\par \input{tufte}\par \input{tufte}\par
\input{tufte}\par \input{tufte}\par \input{tufte}\par
\input{tufte}\par \input{tufte}\par \input{tufte}\par
\input{tufte}\par \input{tufte}\par \input{tufte}\par
\end{document}


Ensuring the \everypar addition survives throughout the document is left  
as an exercise...

And don't do it! :-)

-- 
Morten


More information about the texhax mailing list