There have been several questions about how to avoid widows and orphans, so let me first state that that is not the question here. I know I can try and tweak the settings but that it's still possible to end up with widows and orphans.

What I do want to ask is whether there is some easy way (package) to get a list of all the widows and orphans that are in the document. Written to a separate file or just outputted when the processing of the file is done.

1 Answer 1


Yes, this is possible if you are prepared to accept a certain level of false positives. Basically for both cases special penalties are used by TeX and those can be recognized in the output routine. So my code below sets the value for \widowpenalty to 151 and \clubpenalty (orphans) to 152 (the LaTeX default is 150). The we use the following code:

\documentclass %[twocolumn]


% we want to know if we are on first or second column in a 2 column document
  \def\oncol{\if@twocolumn \space \if@firstcolumn  (first \else (second \fi column)\fi}

% check if the output penalty was due to orphan or widow or both
        \typeout{*** Widow on page  \thepage \oncol}%
          \typeout{*** Orphan on page \thepage \oncol}%
            \typeout{*** Orphan and Widow on page \thepage \oncol}%

% execute this code at the very beginning of the OR

\newcommand\stupidpara{First line\\second line\\and final line\par}
\newcommand\verystupidpara{First line\\and final one\par}



Basically we test if the \outputpenaltythat triggered the page is either 152 or 153 or 305, ie the sum of it (which would be the case if a two line paragraph is broken). That will give us the output:

*** Widow on page 1
*** Orphan on page 2
*** Orphan and Widow on page 3

and if we typeset the same document in twocolumn mode we get

*** Widow on page 1 (first column)
*** Orphan on page 1 (second column)
*** Orphan and Widow on page 2 (first column)

You may find that other page breaks produce the same penalties (which then gives you false positives) so chosing the initial values right is essential. Of course you could use 150 and not distinguish between widow and orphan.

Final note: one should probably also add \displaywidowpenalty into the test (the default here is 50 in LaTeX and instead of a simple \typeoutone could think of a more elaborate output, but this is syntactic sugar.

Small update

As remarked by David Carlisle elsewhere it is better not to use 151 (as I did initially for the \clubpenalty) as standard LaTeX uses 151 for \pagebreak[2] so we would get some unnecessary false positives. Of course, if any of such default values are changed the above code would need to change too.

Also worth noting: changing the penalties even by only such small amounts means that the break behavior of your document could get altered, i.e., it may break differently after you added that code. As this version only adds warnings it is therefore best to keep using it all the time and not make the mistake of removing it just before "final" run after having corrected all problems it reported. It may just mean that afterwards you see new breaks --- unlikely but not impossible!.

Now available as a package

A much extended version of the above code is now available on CTAN as the package widows-and-orphans. It automatically calculates the penalty values to make everything unique and detectible and besides widows and orphans it also detects hyphenation across column or page boundaries and math displays that got separated from the preceding text (in case that is allowed in the document).

Next Tugboat will contain an article that discusses various ways to fix such issues. I will also put it up soon at https://latex-project.org/publications

  • 3
    Nice. Can we have a package, please? Commented Feb 28, 2012 at 23:12
  • @Martin sure but probaby not by me :-) Commented Feb 29, 2012 at 17:37
  • Very nice idd. False positives aren't a problem. Thanks very much.
    – nvcleemp
    Commented Mar 1, 2012 at 6:47
  • 2
    @MartinSchröder since nobody volunteered I did one in the end after all. Commented Sep 18, 2018 at 17:07

You must log in to answer this question.

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