summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/nowidow/nowidow.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/nowidow/nowidow.dtx')
-rw-r--r--Master/texmf-dist/source/latex/nowidow/nowidow.dtx156
1 files changed, 156 insertions, 0 deletions
diff --git a/Master/texmf-dist/source/latex/nowidow/nowidow.dtx b/Master/texmf-dist/source/latex/nowidow/nowidow.dtx
new file mode 100644
index 00000000000..833ca1f0367
--- /dev/null
+++ b/Master/texmf-dist/source/latex/nowidow/nowidow.dtx
@@ -0,0 +1,156 @@
+% \iffalse meta-comment
+%
+% Copyright (C) 2011 by Raphaël Pinson <raphink@gmail.com>
+% ---------------------------------------------------------------------------
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3
+% of this license or (at your option) any later version.
+% The latest version of this license is in
+% http://www.latex-project.org/lppl.txt
+% and version 1.3 or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% This work has the LPPL maintenance status `maintained'.
+%
+% The Current Maintainer of this work is Raphaël Pinson.
+%
+% This work consists of the files nowidow.dtx and nowidow.ins
+% and the derived filebase nowidow.sty.
+%
+% \fi
+%
+% \iffalse
+%<*driver>
+\ProvidesFile{nowidow.dtx}
+%</driver>
+%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
+%<package>\ProvidesPackage{nowidow}
+%<*package>
+ [2011/09/11 0.2 Easily prevent widows]
+%</package>
+%
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage{nowidow}[2011/09/11]
+\EnableCrossrefs
+\CodelineIndex
+\RecordChanges
+\begin{document}
+ \DocInput{nowidow.dtx}
+ \PrintChanges
+ \PrintIndex
+\end{document}
+%</driver>
+% \fi
+%
+% \CheckSum{24}
+%
+% \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
+% Lower-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
+% Digits \0\1\2\3\4\5\6\7\8\9
+% Exclamation \! Double quote \" Hash (number) \#
+% Dollar \$ Percent \% Ampersand \&
+% Acute accent \' Left paren \( Right paren \)
+% Asterisk \* Plus \+ Comma \,
+% Minus \- Point \. Solidus \/
+% Colon \: Semicolon \; Less than \<
+% Equals \= Greater than \> Question mark \?
+% Commercial at \@ Left bracket \[ Backslash \\
+% Right bracket \] Circumflex \^ Underscore \_
+% Grave accent \` Left brace \{ Vertical bar \|
+% Right brace \} Tilde \~}
+%
+%
+% \changes{0.2}{2011/09/11}{Fix nowidow@X}
+% \changes{0.1}{2011/09/11}{Initial version}
+%
+% \DoNotIndex{\newcommand,\newenvironment}
+%
+% \providecommand*{\url}{\texttt}
+% \GetFileInfo{nowidow.dtx}
+% \title{The \textsf{nowidow} package}
+% \author{Raphaël Pinson \\ \url{raphink@gmail.com}}
+% \date{\fileversion~from \filedate}
+%
+% \maketitle
+%
+% \section{Introduction}
+%
+% Widows (single lines at the top 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 \textsf{nowidow} package provides a |\nowidow| command which is simpler
+% to use in order to prevent widows.
+%
+% \section{Usage}
+%
+% To load the package, use:
+%
+% \begin{verbatim}
+% \usepackage{nowidow}
+% \end{verbatim}
+%
+% \DescribeMacro{\nowidow}
+%
+% To prevent widows in a paragraph, call |\nowidow|
+% immediatly at the of the paragraph (without an empty line),
+% optionally followed by the minimal number of lines you
+% want after the page break:
+%
+% \begin{verbatim}
+% This paragraph overflows to the next page,
+% but I really don't want any widows in it.
+% \nowidow[3]
+% \end{verbatim}
+%
+% The minimal number of lines to be kept after
+% the page break defaults to 2 if not specified.
+%
+%
+% \StopEventually{}
+%
+% \section{Implementation}
+%
+% \iffalse
+%<*package>
+% \fi
+%
+% \begin{macrocode}
+\ProvidesPackage{nowidow}
+% \end{macrocode}
+%
+% \begin{macro}{\nowidow@X}
+% \begin{macrocode}
+\def\nowidow@X#1{%
+ \ifnum#1<\nowidowmax
+ 10000
+ \expandafter\nowidow@X\expandafter{%
+ \the\numexpr(#1)+1\expandafter\relax\expandafter}%
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\nowidow}
+% \begin{macrocode}
+\newcommand{\nowidow}[1][2]{%
+ \begingroup
+ \mathchardef\nowidowmax#1\relax
+ \widowpenalties #1 \nowidow@X{1} 0\par
+ \endgroup
+}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \iffalse
+%</package>
+% \fi
+%
+% \Finale
+\endinput