summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source')
-rw-r--r--Master/texmf-dist/source/latex/nowidow/nowidow.dtx134
1 files changed, 119 insertions, 15 deletions
diff --git a/Master/texmf-dist/source/latex/nowidow/nowidow.dtx b/Master/texmf-dist/source/latex/nowidow/nowidow.dtx
index 833ca1f0367..db0bf62c217 100644
--- a/Master/texmf-dist/source/latex/nowidow/nowidow.dtx
+++ b/Master/texmf-dist/source/latex/nowidow/nowidow.dtx
@@ -26,12 +26,12 @@
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{nowidow}
%<*package>
- [2011/09/11 0.2 Easily prevent widows]
+ [2011/09/14 0.4 Easily prevent widows and orphans]
%</package>
%
%<*driver>
\documentclass{ltxdoc}
-\usepackage{nowidow}[2011/09/11]
+\usepackage{nowidow}[2011/09/14]
\EnableCrossrefs
\CodelineIndex
\RecordChanges
@@ -43,7 +43,7 @@
%</driver>
% \fi
%
-% \CheckSum{24}
+% \CheckSum{55}
%
% \CharacterTable
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
@@ -62,6 +62,8 @@
% Right brace \} Tilde \~}
%
%
+% \changes{0.4}{2011/09/14}{Add orphan management}
+% \changes{0.3}{2011/09/13}{Add setnowidow command and package options}
% \changes{0.2}{2011/09/11}{Fix nowidow@X}
% \changes{0.1}{2011/09/11}{Initial version}
%
@@ -70,34 +72,59 @@
% \providecommand*{\url}{\texttt}
% \GetFileInfo{nowidow.dtx}
% \title{The \textsf{nowidow} package}
-% \author{Raphaƫl Pinson \\ \url{raphink@gmail.com}}
+% \author{Rapha\"el Pinson \\ \url{raphink@gmail.com}}
% \date{\fileversion~from \filedate}
%
% \maketitle
%
% \section{Introduction}
%
-% Widows (single lines at the top of a page) happen frequently
+% This package was based on the answer to a
+% question\footnote{\url{http://tex.stackexchange.com/questions/26272/expansion-issue-with-begingroup-and-foreach/26275\#26275}}
+% about expansion with |\begingroup| and |\foreach| asked on \url{http://tex.stackexchange.com}.
+% Thanks to Martin Scharrer\footnote{\url{http://tex.stackexchange.com/users/2975/martin-scharrer}} for his solution.
+%
+% Widows (single lines at the top of a page) and orphans
+% (single lines at the bottom of a page) happen frequently
% and should be avoided.
%
-% The |\widowpenalty| command allows to prevent them,
-% but its syntax is a bit complex to use.
+% The |\widowpenalties| and |\clubpenalties| commands allow to prevent them,
+% but their syntax is a bit complex to use.
%
-% The \textsf{nowidow} package provides a |\nowidow| command which is simpler
-% to use in order to prevent widows.
+% The \textsf{nowidow} package provides |\nowidow| and |\noclub| commands
+% which are simpler to use in order to prevent widows and orphans.
%
% \section{Usage}
%
% To load the package, use:
%
% \begin{verbatim}
-% \usepackage{nowidow}
+% \usepackage[<options>]{nowidow}
+% \end{verbatim}
+%
+% \subsection{Options}
+%
+% \DescribeMacro{defaultlines=<value>}
+%
+% The \texttt{defaultlines} option
+% sets the default minimal number of lines
+% to be kept after or before the page break.
+%
+% \DescribeMacro{all}
+%
+% The \texttt{all} option sets the widow and orphan penalties
+% for the whole document upon loading the package, for example:
+%
+% \begin{verbatim}
+% \usepackage[defaultlines=4,all]{nowidow}
% \end{verbatim}
%
+% \subsection{Commands}
+%
% \DescribeMacro{\nowidow}
%
% To prevent widows in a paragraph, call |\nowidow|
-% immediatly at the of the paragraph (without an empty line),
+% immediatly at the end of the paragraph (without an empty line),
% optionally followed by the minimal number of lines you
% want after the page break:
%
@@ -108,8 +135,41 @@
% \end{verbatim}
%
% The minimal number of lines to be kept after
-% the page break defaults to 2 if not specified.
+% the page break defaults to 2 if not specified
+% or overridden by the \texttt{defaultlines} option.
+%
+% \DescribeMacro{\setnowidow}
+%
+% This macro is similar to |\nowidow| but sets
+% the widow penalty for the whole document
+% instead of the current paragraph only.
%
+% This macro is used when the package is loaded
+% with the \texttt{all} option.
+%
+% \DescribeMacro{\noclub}
+%
+% This is similar to the |\nowidow| command
+% but prevents orphans at the end of a page:
+%
+% \begin{verbatim}
+% This paragraph overflows to the next page,
+% but I really don't want any orphans in it.
+% \noclub[3]
+% \end{verbatim}
+%
+% The minimal number of lines to be kept before
+% the page break defaults to 2 if not specified
+% or overridden by the \texttt{defaultlines} option.
+%
+% \DescribeMacro{\setnoclub}
+%
+% This macro is similar to |\noclub| but sets
+% the orphan penalty for the whole document
+% instead of the current paragraph only.
+%
+% This macro is used when the package is loaded
+% with the \texttt{all} option.
%
% \StopEventually{}
%
@@ -123,6 +183,19 @@
\ProvidesPackage{nowidow}
% \end{macrocode}
%
+% \begin{macro}{Options}
+% \begin{macrocode}
+\RequirePackage{kvoptions}
+\SetupKeyvalOptions{
+ family=nowidow,
+ prefix=nowidow@,
+}
+\DeclareStringOption[2]{defaultlines}
+\DeclareBoolOption{all}
+\ProcessKeyvalOptions*
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}{\nowidow@X}
% \begin{macrocode}
\def\nowidow@X#1{%
@@ -135,18 +208,49 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\setnowidow}
+% \begin{macrocode}
+\newcommand{\setnowidow}[1][\nowidow@defaultlines]{%
+ \mathchardef\nowidowmax#1\relax
+ \widowpenalties #1 \nowidow@X{1} 0\par
+}
+\ifnowidow@all
+ \setnowidow
+\fi
+% \end{macrocode}
+% \end{macro}
%
% \begin{macro}{\nowidow}
% \begin{macrocode}
-\newcommand{\nowidow}[1][2]{%
+\newcommand{\nowidow}[1][\nowidow@defaultlines]{%
\begingroup
- \mathchardef\nowidowmax#1\relax
- \widowpenalties #1 \nowidow@X{1} 0\par
+ \setnowidow[#1]
\endgroup
}
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\setnoclub}
+% \begin{macrocode}
+\newcommand{\setnoclub}[1][\nowidow@defaultlines]{%
+ \mathchardef\nowidowmax#1\relax
+ \clubpenalties #1 \nowidow@X{1} 0\par
+}
+\ifnowidow@all
+ \setnoclub
+\fi
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\noclub}
+% \begin{macrocode}
+\newcommand{\noclub}[1][\nowidow@defaultlines]{%
+ \begingroup
+ \setnoclub[#1]
+ \endgroup
+}
+% \end{macrocode}
+% \end{macro}
%
% \iffalse
%</package>