From 0ef5b158bb06ded89f7677ce81742f3ceb5e7c60 Mon Sep 17 00:00:00 2001
From: Mark Wooding <mdw@distorted.org.uk>
Date: Thu, 6 Dec 2007 12:51:40 +0000
Subject: [PATCH] strayman: New `indentpar' option: indented paragraphs rather
 than blocks.

---
 strayman.dtx | 168 +++++++++++++++++++++++++++++++----------------------------
 1 file changed, 89 insertions(+), 79 deletions(-)

diff --git a/strayman.dtx b/strayman.dtx
index fbafd63..0fe7db0 100644
--- a/strayman.dtx
+++ b/strayman.dtx
@@ -35,7 +35,7 @@
 %<+strayman>              [2003/09/04 1.10 Straylight document class]
 % \end{meta-comment}
 %
-% \CheckSum{2936}
+% \CheckSum{3022}
 %% \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
@@ -60,6 +60,7 @@
 \input{mdwtools}
 \usepackage{mdwlist}
 \describesclass{strayman}
+\errorcontextlines\maxdimen
 \title[The \strayman\ document class]
       {The \strayman\footnote{The \strayman\ document class is currently %
        at version \mdwfileinfo{strayman.cls}{version}, dated %
@@ -204,6 +205,7 @@
 \newif\if@numbering\@numberingfalse
 \newif\if@herefloats\@herefloatstrue
 \newif\if@runinsubsubsec\@runinsubsubsecfalse
+\newif\if@indentpar
 \newdimen\pagesurround
 \let\headfam\rmfamily
 \let\pad@margin\@empty
@@ -290,6 +292,8 @@
 \DeclareOption{nonumbering}{\@numberingfalse}
 \DeclareOption{runinsubsubsec}{\@runinsubsubsectrue}
 \DeclareOption{noruninsubsubsec}{\@runinsubsubsecfalse}
+\DeclareOption{indentpar}{\@indentpartrue}
+\DeclareOption{noindentpar}{\@indentparfalse}
 %    \end{macrocode}
 %
 % \subsection{Set up the options}
@@ -361,11 +365,14 @@
 % gap when we change font size.  This macro does the job.
 %
 %    \begin{macrocode}
+\newskip\@parskip
+\newdimen\@parshortfall
 \def\@setparskip{%
-  \relax\ifdim\parskip=\z@\else%
-    \parskip.67\baselineskip\@plus\p@\relax%
-  \fi%
+  \@parskip.67\baselineskip\@plus\p@\relax%
+  \ifdim\parskip=\z@\else\parskip\@parskip\relax\fi%
+  \@parshortfall\@parskip\advance\@parshortfall-\parskip%
 }
+\def\set@vsep#1{#1\@parshortfall\advance#1}
 %    \end{macrocode}
 % \end{macro}
 %
@@ -378,45 +385,49 @@
 %<*8pt>
   \@setfontsize\normalsize\@viiipt{9.6\p@}%
   \abovedisplayskip8\p@\@plus2\p@\@minus4\p@%
-  \abovedisplayshortskip\z@\@plus3\p@%
-  \belowdisplayshortskip6\p@\@plus3\p@\@minus3\p@%
+  \set@vsep\abovedisplayshortskip\z@\@plus3\p@%
+  \set@vsep\belowdisplayshortskip6\p@\@plus3\p@\@minus3\p@%
 %</8pt>
 %<*9pt>
   \@setfontsize\normalsize\@ixpt\@xipt%
   \abovedisplayskip9\p@\@plus2\p@\@minus5\p@%
-  \abovedisplayshortskip\z@\@plus3\p@%
-  \belowdisplayshortskip6\p@\@plus3\p@\@minus3\p@%
+  \set@vsep\abovedisplayshortskip\z@\@plus3\p@%
+  \set@vsep\belowdisplayshortskip6\p@\@plus3\p@\@minus3\p@%
 %</9pt>
 %<*10pt>
   \@setfontsize\normalsize\@xpt\@xiipt%
   \abovedisplayskip10\p@\@plus2\p@\@minus5\p@%
-  \abovedisplayshortskip\z@\@plus3\p@%
-  \belowdisplayshortskip6\p@\@plus3\p@\@minus3\p@%
+  \set@vsep\abovedisplayshortskip\z@\@plus3\p@%
+  \set@vsep\belowdisplayshortskip6\p@\@plus3\p@\@minus3\p@%
 %</10pt>
 %<*11pt>
   \@setfontsize\normalsize\@xipt{13.6}%
   \abovedisplayskip11\p@\@plus3\p@\@minus6\p@%
-  \abovedisplayshortskip\z@\@plus3\p@%
-  \belowdisplayshortskip6.5\p@ \@plus3.5\p@\@minus3\p@%
+  \set@vsep\abovedisplayshortskip\z@\@plus3\p@%
+  \set@vsep\belowdisplayshortskip6.5\p@ \@plus3.5\p@\@minus3\p@%
 %</11pt>
 %<*12pt>
   \@setfontsize\normalsize\@xiipt{14.5}%
   \abovedisplayskip12\p@\@plus3\p@\@minus7\p@%
-  \abovedisplayshortskip\z@\@plus3\p@%
-  \belowdisplayshortskip6.5\p@ \@plus3.5\p@\@minus3\p@%
+  \set@vsep\abovedisplayshortskip\z@\@plus3\p@%
+  \set@vsep\belowdisplayshortskip6.5\p@ \@plus3.5\p@\@minus3\p@%
 %</12pt>
 %<*text>
   \@setfontsize\normalsize\@xpt\@xiipt%
   \abovedisplayskip10\p@\@plus2\p@\@minus5\p@%
-  \abovedisplayshortskip\z@\@plus3\p@%
-  \belowdisplayshortskip6\p@\@plus3\p@\@minus3\p@%
+  \set@vsep\abovedisplayshortskip\z@\@plus3\p@%
+  \set@vsep\belowdisplayshortskip6\p@\@plus3\p@\@minus3\p@%
 %</text>
   \belowdisplayskip\abovedisplayskip%
   \let\@listi\@listI%
   \@setparskip%
 }
 \normalsize
-\parskip2ex\@plus\p@
+\if@indentpar
+  \parskip0pt\@plus\p@
+\else
+  \parskip2ex\@plus\p@
+\fi
 %    \end{macrocode}
 % \end{macro}
 %
@@ -433,37 +444,37 @@
 %<*8pt>
   \@setfontsize\small\@viipt{8.4}%
   \abovedisplayskip8\p@\@plus2\p@\@minus4\p@%
-  \abovedisplayshortskip\z@\@plus2\p@%
-  \belowdisplayshortskip4\p@\@plus2\p@\@minus2\p@%
+  \set@vsep\abovedisplayshortskip\z@\@plus2\p@%
+  \set@vsep\belowdisplayshortskip4\p@\@plus2\p@\@minus2\p@%
 %</8pt>
 %<*9pt>
   \@setfontsize\small\@viiipt{9.5}%
   \abovedisplayskip8\p@\@plus2\p@\@minus4\p@%
-  \abovedisplayshortskip\z@\@plus2\p@%
-  \belowdisplayshortskip4\p@\@plus2\p@\@minus2\p@%
+  \set@vsep\abovedisplayshortskip\z@\@plus2\p@%
+  \set@vsep\belowdisplayshortskip4\p@\@plus2\p@\@minus2\p@%
 %</9pt>
 %<*10pt>
   \@setfontsize\small\@ixpt{11}%
   \abovedisplayskip8.5\p@\@plus3\p@\@minus4\p@%
-  \abovedisplayshortskip\z@\@plus2\p@%
-  \belowdisplayshortskip4\p@\@plus2\p@\@minus2\p@%
+  \set@vsep\abovedisplayshortskip\z@\@plus2\p@%
+  \set@vsep\belowdisplayshortskip4\p@\@plus2\p@\@minus2\p@%
 %</10pt>
 %<*11pt>
   \@setfontsize\small\@xpt\@xiipt%
   \abovedisplayskip10\p@\@plus2\p@\@minus5\p@%
-  \abovedisplayshortskip\z@\@plus3\p@%
-  \belowdisplayshortskip6\p@\@plus3\p@\@minus3\p@%
+  \set@vsep\abovedisplayshortskip\z@\@plus3\p@%
+  \set@vsep\belowdisplayshortskip6\p@\@plus3\p@\@minus3\p@%
 %</11pt>
 %<*12pt>
   \@setfontsize\small\@xipt{13.6}%
   \abovedisplayskip11\p@\@plus3\p@\@minus6\p@%
-  \abovedisplayshortskip\z@ \@plus3\p@%
-  \belowdisplayshortskip6.5\p@ \@plus3.5\p@\@minus3\p@%
+  \set@vsep\abovedisplayshortskip\z@ \@plus3\p@%
+  \set@vsep\belowdisplayshortskip6.5\p@ \@plus3.5\p@\@minus3\p@%
 %</12pt>
   \def\@listi{%
     \leftmargin\leftmargini%
-    \topsep\z@%
-    \parsep\parskip%
+    \topsep\@parshortfall%
+    \parsep\@parskip%
     \itemsep\z@%
   }%
   \belowdisplayskip\abovedisplayskip%
@@ -484,38 +495,38 @@
 \newcommand\footnotesize{%
 %<*8pt>
   \@setfontsize\footnotesize\@vipt\@viipt%
-  \abovedisplayskip6\p@\@plus2\p@\@minus4\p@%
-  \abovedisplayshortskip\z@\@plus\p@%
-  \belowdisplayshortskip3\p@\@plus\p@\@minus2\p@%
+  \set@vsep\abovedisplayskip6\p@\@plus2\p@\@minus4\p@%
+  \set@vsep\abovedisplayshortskip\z@\@plus\p@%
+  \set@vsep\belowdisplayshortskip3\p@\@plus\p@\@minus2\p@%
 %</8pt>
 %<*9pt>
   \@setfontsize\footnotesize\@viipt{8.4}%
-  \abovedisplayskip6\p@\@plus2\p@\@minus4\p@%
-  \abovedisplayshortskip\z@\@plus\p@%
-  \belowdisplayshortskip3\p@\@plus\p@\@minus2\p@%
+  \set@vsep\abovedisplayskip6\p@\@plus2\p@\@minus4\p@%
+  \set@vsep\abovedisplayshortskip\z@\@plus\p@%
+  \set@vsep\belowdisplayshortskip3\p@\@plus\p@\@minus2\p@%
 %</9pt>
 %<*10pt>
   \@setfontsize\footnotesize\@viiipt{9.5}%
-  \abovedisplayskip6\p@\@plus2\p@\@minus4\p@%
-  \abovedisplayshortskip\z@\@plus\p@%
-  \belowdisplayshortskip3\p@\@plus\p@\@minus2\p@%
+  \set@vsep\abovedisplayskip6\p@\@plus2\p@\@minus4\p@%
+  \set@vsep\abovedisplayshortskip\z@\@plus\p@%
+  \set@vsep\belowdisplayshortskip3\p@\@plus\p@\@minus2\p@%
 %</10pt>
 %<*11pt>
   \@setfontsize\footnotesize\@ixpt{11}%
-  \abovedisplayskip8\p@\@plus2\p@\@minus4\p@%
-  \abovedisplayshortskip\z@\@plus\p@%
-  \belowdisplayshortskip4\p@\@plus2\p@\@minus2\p@%
+  \set@vsep\abovedisplayskip8\p@\@plus2\p@\@minus4\p@%
+  \set@vsep\abovedisplayshortskip\z@\@plus\p@%
+  \set@vsep\belowdisplayshortskip4\p@\@plus2\p@\@minus2\p@%
 %</11pt>
 %<*12pt>
   \@setfontsize\footnotesize\@xpt\@xiipt
-  \abovedisplayskip10\p@\@plus2\p@\@minus5\p@%
-  \abovedisplayshortskip\z@\@plus3\p@%
-  \belowdisplayshortskip6\p@\@plus3\p@\@minus3\p@%
+  \set@vsep\abovedisplayskip10\p@\@plus2\p@\@minus5\p@%
+  \set@vsep\abovedisplayshortskip\z@\@plus3\p@%
+  \set@vsep\belowdisplayshortskip6\p@\@plus3\p@\@minus3\p@%
 %</12pt>
   \def\@listi{%
     \leftmargin\leftmargini%
-    \topsep\z@%
-    \parsep\parskip%
+    \topsep\@parshortfall%
+    \parsep\@parskip%
     \itemsep\z@%
   }%
   \belowdisplayskip\abovedisplayskip%
@@ -616,13 +627,7 @@
 \renewcommand\baselinestretch{}
 %    \end{macrocode}
 %
-% We don't indent paragraphs at all; instead, we separate them with blank
-% lines.  The vertical gap is worked out in the size command; we just clear
-% |\parindent|.
-%
-%    \begin{macrocode}
-\parindent\z@
-%    \end{macrocode}
+% Paragraph indentation is set up later.
 %
 % Set up some standard penalty values.
 %
@@ -1477,80 +1482,77 @@
 % introduced.
 %
 %    \begin{macrocode}
-\newcommand\section{%
-  \@startsection%
+\def\@defsection#1#2#3#4#5#6{%
+  \expandafter\newcommand\csname#1\endcsname{%
+    \skip@#4\advance\skip@\ifdim\skip@<\z@-\fi\@parshortfall%
+    \skip\tw@#5\relax\ifdim\skip\tw@>\z@\advance\skip\tw@\@parshortfall\fi%
+    \@startsection%
+      {#1}%
+      {#2}%
+      {#3}%
+      \skip@
+      {\skip\tw@}%
+      {\reset@font#6\bfseries\headfam}%
+  }%
+}
+\@defsection
     {section}%                          % Section name (for contents)
     {1}%                                % Level number (for numbering)
     {-.5\sectindent}%                   % Indentation of title
     {-1.5ex\@plus-1ex\@minus-.2ex}%     % Space after title (vert/horiz)
     {.3ex\@plus.2ex}%                   % Space before title
     {\reset@font\Large\bfseries\headfam}% How to typeset the title
-}
-\newcommand\subsection{%
-  \@startsection%
+\@defsection
     {subsection}%
     {2}%
     {-.25\sectindent}%
     {-1.25ex\@plus-1ex\@minus-.2ex}%
     {\p@\@plus.2ex}%
     {\reset@font\large\bfseries\headfam}%
-}
 \if@runinsubsubsec
-\newcommand\subsubsection{%
-  \@startsection%
+\@defsection
     {subsubsection}%
     {3}%
     {\z@}%
     {0pt\@plus1ex\@minus.2ex}%
     {-1em}%
     {\reset@font\normalsize\bfseries\headfam}%
-}
-\newcommand\paragraph{%
-  \@startsection%
+\@defsection
     {paragraph}%
     {4}%
     {\z@}%
     {0pt\@plus.5ex\@minus.1ex}%
     {-1em}%
     {\reset@font\normalsize\bfseries\headfam}%
-}
-\newcommand\subparagraph{%
-  \@startsection%
+\@defsection
     {subparagraph}%
     {5}%
     {\parindent}%
     {0pt\@plus.5ex\@minus.1ex}%
     {-1em}%
     {\reset@font\normalsize\bfseries\headfam}%
-}
 \else
-\newcommand\subsubsection{%
-  \@startsection%
+\@defsection
     {subsubsection}%
     {3}%
     {\z@}%
     {-1.25ex\@plus-1ex\@minus-.2ex}%
     {\p@\@plus.2ex}%
     {\reset@font\normalsize\bfseries\headfam}%
-}
-\newcommand\paragraph{%
-  \@startsection%
+\@defsection
     {paragraph}%
     {4}%
     {\z@}%
     {0pt\@plus1ex\@minus.2ex}%
     {-1em}%
     {\reset@font\normalsize\bfseries\headfam}%
-}
-\newcommand\subparagraph{%
-  \@startsection%
+\@defsection
     {subparagraph}%
     {5}%
     {\parindent}%
     {0pt\@plus.5ex\@minus.1ex}%
     {-1em}%
     {\reset@font\normalsize\bfseries\headfam}%
-}
 \fi
 %    \end{macrocode}
 %
@@ -1616,6 +1618,14 @@
   \leftmarginvi1em
 \fi
 %    \end{macrocode}
+% And now we can set the paragraph indent.
+%    \begin{macrocode}
+\if@indentpar
+  \parindent\leftmargini
+\else
+  \parindent\z@
+\fi
+%    \end{macrocode}
 %
 % Other spacing defaults:
 %
@@ -1641,8 +1651,8 @@
 %    \begin{macrocode}
 \def\@listI{%
   \leftmargin\leftmargini%
-  \parsep\parskip%
-  \topsep\z@%
+  \parsep\@parskip%
+  \topsep\@parskip%
   \itemsep\z@%
 }
 \let\@listi\@listI
-- 
2.11.0

