Debian Codegraph @

texmf-dist/source/latex/listparskip/listparskip_code.dtx

raw
1 % \iffalse ---!!! FIRST META-COMMENT !!!---
2 %
3 %
4 % This file is listparskip_code.dtx from version 1.0
5 % of the free and open-source LaTeX package "listparskip,"
6 % released December 2024.
7 %
8 % Running Plain TeX on listparskip_code.dtx will
9 % produce the following files:
10 %
11 % (1) the package file listparskip.sty;
12 %
13 % (2) the derived files listparskip_heading.tex
14 % and listparskip_user_guide.tex, and
15 % listparskip_example.tex, which are
16 % used for typesetting documentation;
17 %
18 % and
19 %
20 % (3) a number of other derived files.
21 %
22 % Running LaTeX on listparskip_code.dtx will produce the
23 % files listed above as well as the following:
24 %
25 % (4) the pdf documentation file listparskip_code.pdf;
26 %
27 % and
28 %
29 % (5) a number of other derived files.
30 %
31 % To install listparskip on your computer, run this file
32 % through Plain TeX or LaTeX and move listparskip.sty
33 % to a directory searchable by TeX. See the associated
34 % README.txt file for installation information.
35 %
36 %
37 % \fi
38 % \iffalse ---!!! SECOND META-COMMENT !!!---
39 %
40 %
41 % This file is from version 1.0 of the free and open-source
42 % LaTeX package "listparskip," released December 2024.
43 %
44 % Copyright 2024 Conrad Kosowsky
45 %
46 % This file may be used, distributed, and modified under the
47 % terms of the LaTeX Public Project License, version 1.3c or
48 % any later version. The most recent version of this license
49 % is available online at
50 %
51 % https://www.latex-project.org/lppl/
52 %
53 % This Work has the LPPL status "maintained," and the current
54 % maintainer is the package author, Conrad Kosowsky. He can
55 % be reached at [email protected]. The Work consists
56 % of the following items:
57 %
58 % (1) the base file:
59 % listparskip.dtx
60 %
61 % (2) the package file:
62 % listparskip.sty
63 %
64 % (3) the pdf documentation files:
65 % listparskip_code.pdf
66 % listparskip_user_guide.pdf
67 % listparskip_example.pdf
68 %
69 % (4) the derived files:
70 % listparskip_user_guide.tex
71 % listparskip_example.tex
72 % listparskip_heading.tex
73 %
74 % (5) all other files created through the configuration
75 % process
76 %
77 % and
78 %
79 % (6) this README.txt file
80 %
81 % PLEASE KNOW THAT THIS FREE SOFTWARE IS PROVIDED WITHOUT
82 % ANY WARRANTY. SPECIFICALLY, THE "NO WARRANTY" SECTION OF
83 % THE LATEX PROJECT PUBLIC LICENSE STATES THE FOLLOWING:
84 %
85 % THERE IS NO WARRANTY FOR THE WORK. EXCEPT WHEN OTHERWISE
86 % STATED IN WRITING, THE COPYRIGHT HOLDER PROVIDES THE WORK
87 % `AS IS’, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
88 % OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
89 % WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
90 % PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE
91 % OF THE WORK IS WITH YOU. SHOULD THE WORK PROVE DEFECTIVE,
92 % YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR
93 % CORRECTION.
94 %
95 % IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED
96 % TO IN WRITING WILL THE COPYRIGHT HOLDER, OR ANY AUTHOR
97 % NAMED IN THE COMPONENTS OF THE WORK, OR ANY OTHER PARTY
98 % WHO MAY DISTRIBUTE AND/OR MODIFY THE WORK AS PERMITTED
99 % ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL,
100 % SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT
101 % OF ANY USE OF THE WORK OR OUT OF INABILITY TO USE THE WORK
102 % (INCLUDING, BUT NOT LIMITED TO, LOSS OF DATA, DATA BEING
103 % RENDERED INACCURATE, OR LOSSES SUSTAINED BY ANYONE AS A
104 % RESULT OF ANY FAILURE OF THE WORK TO OPERATE WITH ANY
105 % OTHER PROGRAMS), EVEN IF THE COPYRIGHT HOLDER OR SAID
106 % AUTHOR OR SAID OTHER PARTY HAS BEEN ADVISED OF THE
107 % POSSIBILITY OF SUCH DAMAGES.
108 %
109 % For more information, see the LaTeX Project Public License.
110 % Derivative works based on this software may come with their
111 % own license or terms of use, and the package author is not
112 % responsible for any third-party software.
113 %
114 % Happy TeXing!
115 %
116 %
117 % \fi
118 % \iffalse
119 %
120 % The installation and driver files are incorporated into
121 % listparskip_code.dtx, so we do not need to generate them
122 % separately. The <batchfile> and <driver> tags are for
123 % reference.
124 %
125 %<*batchfile>
126 \begingroup
127 \input docstrip.tex
128 \keepsilent
129 \askforoverwritefalse
130 \preamble
131
132 This file is from version 1.0 of the free and open-source
133 LaTeX package "listparskip," released December 2024.
134
135 Copyright 2024 Conrad Kosowsky
136
137 This file may be used, distributed, and modified under the
138 terms of the LaTeX Public Project License, version 1.3c or
139 any later version. The most recent version of this license
140 is available online at
141
142 https://www.latex-project.org/lppl/
143
144 This work has the LPPL status "maintained," and the current
145 maintainer is the package author, Conrad Kosowsky. He can
146 be reached at [email protected].
147
148 PLEASE KNOW THAT THIS FREE SOFTWARE IS PROVIDED WITHOUT
149 ANY WARRANTY. SPECIFICALLY, THE "NO WARRANTY" SECTION OF
150 THE LATEX PROJECT PUBLIC LICENSE STATES THE FOLLOWING:
151
152 THERE IS NO WARRANTY FOR THE WORK. EXCEPT WHEN OTHERWISE
153 STATED IN WRITING, THE COPYRIGHT HOLDER PROVIDES THE WORK
154 `AS IS’, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
155 OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
156 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
157 PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE
158 OF THE WORK IS WITH YOU. SHOULD THE WORK PROVE DEFECTIVE,
159 YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR
160 CORRECTION.
161
162 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED
163 TO IN WRITING WILL THE COPYRIGHT HOLDER, OR ANY AUTHOR
164 NAMED IN THE COMPONENTS OF THE WORK, OR ANY OTHER PARTY
165 WHO MAY DISTRIBUTE AND/OR MODIFY THE WORK AS PERMITTED
166 ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL,
167 SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT
168 OF ANY USE OF THE WORK OR OUT OF INABILITY TO USE THE WORK
169 (INCLUDING, BUT NOT LIMITED TO, LOSS OF DATA, DATA BEING
170 RENDERED INACCURATE, OR LOSSES SUSTAINED BY ANYONE AS A
171 RESULT OF ANY FAILURE OF THE WORK TO OPERATE WITH ANY
172 OTHER PROGRAMS), EVEN IF THE COPYRIGHT HOLDER OR SAID
173 AUTHOR OR SAID OTHER PARTY HAS BEEN ADVISED OF THE
174 POSSIBILITY OF SUCH DAMAGES.
175
176 For more information, see the LaTeX Project Public License.
177 Derivative works based on this software may come with their
178 own license or terms of use, and the package author is not
179 responsible for any third-party software.
180
181 Happy TeXing!
182
183 \endpreamble
184 \generate{\file{listparskip.sty}{\from{listparskip_code.dtx}{package}}
185 \file{listparskip_user_guide.tex}{\from{listparskip_code.dtx}{user}}
186 \file{listparskip_example.tex}{\from{listparskip_code.dtx}{example}}
187 \file{listparskip_heading.tex}{\from{listparskip_code.dtx}{heading}}}
188 \catcode`\ =12\relax
189 \immediate\write0{^^J%
190 ****************************************************^^J%
191 * Step 1 of the listparskip installation complete! *^^J%
192 ****************************************************^^J^^J%
193 ****************************************************^^J%
194 * To finish installing the package, move *^^J%
195 * listparskip.sty to a directory searchable by TeX *^^J%
196 * after listparskip_code.tex is done typesetting *^^J%
197 ****************************************************^^J}
198 \endgroup
199 \ifx\LaTeX\undefined
200 \immediate\write0{Plain TeX format used; quitting now.}
201 \immediate\write0{To create listparskip_code.pdf, run^^J%
202 listparskip_code.dtx through LaTeX.^^J^^J}
203 \expandafter\end
204 \fi
205 %</batchfile>
206 %<*driver>
207 \makeatletter
208 \documentclass[12pt,doc2,letterpaper]{ltxdoc}
209 \usepackage[margin=72.27pt]{geometry}
210 \usepackage[factor=700,stretch=14,shrink=14,step=1]{microtype}
211 \begin{document}
212 \def\documentname{Implementation}
213 \input listparskip_heading.tex
214 \DocInput{listparskip_code.dtx}
215 \end{document}
216 %</driver>
217 %<*package>
218 %
219 % \fi
220 %
221 %
222 % \CheckSum{112}
223 % \init@checksum
224 %
225 % \makeatother
226 % \CharacterTable
227 % {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
228 % 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
229 % Digits \0\1\2\3\4\5\6\7\8\9
230 % Exclamation \! Double quote \" Hash (number) \#
231 % Dollar \$ Percent \% Ampersand \&
232 % Acute accent \' Left paren \( Right paren \)
233 % Asterisk \* Plus \+ Comma \,
234 % Minus \- Point \. Solidus \/
235 % Colon \: Semicolon \; Less than \<
236 % Equals \= Greater than \> Question mark \?
237 % Commercial at \@ Left bracket \[ Backslash \\
238 % Right bracket \] Circumflex \^ Underscore \_
239 % Grave accent \` Left brace \{ Vertical bar \|
240 % Right brace \} Tilde \~}
241 % \makeatletter
242 %
243 %
244 %
245 %
246 %
247 %
248 % \noindent This file documents the code for the \textsf{listparskip} package. It is not a user guide! If you are looking for discussion of how \textsf{listparskip} will change the layout of your documents, see |listparskip_user_guide.pdf| and |listparskip_example.pdf|, which are included with the \textsf{listparskip} installation and are available on \textsc{ctan}.
249 %
250 % Spacing in list environments is subtle, and it will be helpful to summarize how \LaTeX\ implements vertical space in lists. Every list environment comes from either a |\list| or |\trivlist| macro, and |\list| is responsible for the standard list structure that shows up in enumerate, itemize, and description environments. A |\trivlist| is a list without any indentation or space for item markers, and this command comes up, for example, in quotations or some verbatim environments where fine control over vertical spacing is important. Both user-level commands serve as wrappers for the internal macro |\@trivlist|, which translates the definition of the current environment into internal list control sequences for processing later in the document. Default dimensions for different list levels come from the class file in the |\@listi| through |\@listiv| macros.
251 %
252 % When the user enters a list environment, for example with |\begin{enumerate}|, \TeX\ will at some point encounter |\@trivlist|. When that happens, \TeX\ prepares to add |\topsep| and |\parskip| to the main vertical list, and if \TeX\ is in \v mode, it prepares to add an extra |\partopsep|. The environment call itself doesn't add space or penalties, and instead, the first |\item| inside the list environment is responsible for these changes. Future uses of |\item| add an |\itempenalty| and |\itemsep| to the main vertical list, and any |\parsep| space additions happen automatically because \LaTeX\ sets |\parskip| to |\parsep| inside |\list| immediately after |\@trivlist|. At the end of the list environment, \TeX\ adds |\topsep| and, if it was present at the beginning of the environment, |\partopsep| to the main vertical list. \LaTeX\ does not instruct \TeX\ to manually add |\parskip|, so if the user includes, for example, an |\hbox| right after |\end{enumerate}|, \TeX\ will not add |\parskip| there. (\TeX\ is always in \v mode after it begins or ends a list environment.)
253 %
254 % Changing this behavior at the beginning of lists is straightforward---\textsf{listparskip} patches |\@trivlist| by treating the extra |\parskip| the same way \LaTeX\ normally treats |\partopsep|. Dealing with after-list space is more complicated. Normally |\@endparenv| adds |\topsep| and possibly |\partopsep| directly to the main vertical list, but we want a more tailored approach. Instead, \textsf{listparskip} redefines |\@endparenv| to add |\topsep| to the main vertical list and (globally) save |\topsep| plus |\partopsep| in |\@tempskipa|. Immediately outside the list environment, \textsf{listparskip} sets |\parskip| to 0pt and redefines |\par| to remove the previous |\topsep| and replace it with |\@tempskipa|. To ensure that (a) the extra |\partopsep| happens only if a blank line immediately follows the list and (b) \TeX\ avoids inserting |\parskip| only if \h mode material immediately follows the list, \textsf{listparskip} makes |\par|, |\everypar|, and |\item| restore |\par| and |\parskip| to their previous (local) definitions. Using creative groupings or manually redefining |\par| or |\everypar| right after a list may break things, so please be careful!
255 %
256 % Sometimes the user will want to include non-horizontal material, such as a box, immediately after a list environment without worrying about an extra or missing |\parskip| or |\partopsep|. In the implementation outlined above, \textsf{listparskip} adds or removes this space whenever \TeX\ first encounters a |\par| or \h mode material after a list. A box is neither of these things, so any after-list adjustments will show up after the box instead of before. The easiest way to avoid this problem is to transition to \h mode and then back to \v mode before adding the box, and the macro |\nullline| does this.
257 %
258 % \bigskip
259 % \centerline{$***$}
260 % \bigskip
261 %
262 % \noindent First, the package should declare itself. There are no package options.
263 % \begin{macrocode}
264 \NeedsTeXFormat{LaTeX2e}
265 \ProvidesPackage{listparskip}[2024/12/17 v. 1.0 Package listparskip]
266 \newdimen\@saveparskip
267 % \end{macrocode}
268 % We begin with spacing at the start of list environments. We patch |\@trivlist| such that |\@topsepadd| increases by |\parskip| only when \TeX\ is already in \v mode.
269 % \begin{macrocode}
270 \long\def\patch@trivlist#1\ifvmode#2\else#3%
271 \advance\@topsep\parskip#4\@nil{%
272 #1%
273 \ifvmode
274 \advance\@topsepadd\partopsep
275 \advance\@topsepadd\parskip
276 \else
277 #3#4}
278 \toks@\expandafter\expandafter\expandafter
279 {\expandafter\patch@trivlist\@trivlist\@nil}
280 \edef\@trivlist{\the\toks@}
281 % \end{macrocode}
282 % We change |\@endparenv| so that it adds only |\topsep|. We set |\@tempskipa| globally in order to access its value in |\@doendpe|, which is outside the current group.
283 % \begin{macrocode}
284 \def\@endparenv{%
285 \addpenalty\@endparpenalty
286 \addvspace\topsep
287 \global\@tempskipa\glueexpr\topsep+\partopsep\relax
288 \@endpetrue}
289 % \end{macrocode}
290 % Normally |\@restoreparskip| is |\relax|, but we change it in |\@doendpe| to return |\parskip| back to its previous value, which we have stored in |\@saveparskip|. This makes |\parskip\z@| a one-op. (Or a no-op if \TeX\ sees a |\par| or |\item| after the list and doesn't enter \h mode.)\vadjust{\penalty-100}
291 % \begin{macrocode}
292 \let\@restoreparskip\relax
293 \def\@doendpe{%
294 \@endpetrue
295 \@saveparskip\parskip
296 \parskip\z@
297 \def\@restoreparskip{%
298 \parskip\@saveparskip
299 \let\@restoreparskip\relax}
300 % \end{macrocode}
301 % We add |\@restoreparskip| to |\par|, and the |\addvspace| will replace the previous addition of |\topsep| from |\@endparenv| with |\topsep| plus |\partopsep|. We put everything inside an |\edef| so we can expand |\the\@tempskipa| now and not worry about a redefinition of |\@tempskipa| before the next |\par|. (Unlikely, but you never know.)
302 % \begin{macrocode}
303 \edef\par{%
304 \unexpanded{\clubpenalty\@clubpenalty
305 \everypar{}%
306 \@restorepar\par
307 \@restoreparskip
308 \@endpefalse}%
309 \noexpand\addvspace{\the\@tempskipa}}%
310 % \end{macrocode}
311 % The contents of |\everypar| here are the same as the \LaTeX\ default in this situation except that we add |\@restorepar| and |\@restoreparskip|.
312 % \begin{macrocode}
313 \everypar{\@restorepar
314 \@restoreparskip
315 {\setbox\z@\lastbox}%
316 \everypar{}%
317 \@endpefalse}}
318 % \end{macrocode}
319 % Next we add |\@restorepar| to the beginning of |\item|. Calling |\patch@item| on a control sequence |#1| will insert |\@restorepar| and |\@restoreparskip| into |#1|'s definition.
320 % \begin{macrocode}
321 \def\patch@item#1{%
322 \edef#1{\noexpand\@restorepar
323 \noexpand\@restoreparskip
324 \expandafter\unexpanded\expandafter{#1}}}
325 % \end{macrocode}
326 % The \textsf{hyperref} package sometimes turns |\item| into a wrapper for itself. In that case, \textsf{hyperref} will have renamed |\item| to |\H@item|, so we patch that instead.
327 % \begin{macrocode}
328 \@ifpackageloaded{hyperref}{%
329 \ifHy@implicit
330 \patch@item\H@item
331 \else
332 \patch@item\item
333 \fi}{\patch@item\item}
334 % \end{macrocode}
335 % Finally, create the command that forces a transition from \textsc v mode to \h mode and back without (directly) adding any space.
336 % \begin{macrocode}
337 \def\nullline{\ifvmode\nointerlineskip\leavevmode\par\fi}
338 % \end{macrocode}
339 % All done!
340 %
341 %
342 % \iffalse
343 % ^^A No version history unless we end up with multiple versions
344 %
345 % \vfill\eject
346 %
347 % \section*{Version History}
348 %
349 % \begin{multicols*}{2}
350 % \raggedright
351 % \parskip\z@
352 % \parindent\z@
353 % \leftskip1em
354 % \obeylines
355 % \setbox0\hbox{\hskip 1pt.\hskip 1pt}
356 % \def\version#1#2{\bigskip\hbox to \hsize{\textbf{#1} %
357 % \cleaders\copy0\hfill\ #2}\par}
358 % \def\item{---\kern0.2ex\relax}
359 %
360 % \version{1.0}{May 2024}
361 % \item initial release
362 %
363 %
364 % \end{multicols*}
365 %
366 % \fi
367 %
368 %
369 % \check@checksum
370 %
371 %
372 % \iffalse
373 %</package>
374 %<*user>
375 %
376 \documentclass[12pt]{article}
377 \usepackage[margin=72.27pt]{geometry}
378 \usepackage[factor=700,stretch=14,shrink=14,step=1]{microtype}
379 \usepackage{booktabs}
380 \usepackage{tabularx}
381 \usepackage{enumitem}
382 \setlist{topsep=\smallskipamount,itemsep=\smallskipamount,
383 parsep=0pt,partopsep=0pt}
384 \usepackage{shortvrb}
385 \MakeShortVerb{|}
386
387 \begin{document}
388
389 \def\documentname{User Guide}
390 \newdimen\MacroIndent
391 \input listparskip_heading.tex
392
393
394 \noindent Most \LaTeX\ users are familiar with the enumerate and itemize environments, and a number of other environments share the same underlying macros and structure. These list environments are useful and versatile, and they come up in many different situations where fine control over vertical spacing is important.\footnote{There is an overlap in terminology. The list environments described in this document are very different from horizontal and vertical lists in the \TeX\ language.} The dimensions |\topsep|, |\parsep|, |\partopsep|, and |\itemsep| control vertical spacing for list environments, and by default, \LaTeX\ determines the space immediately outside a list as follows:
395 \begin{itemize}
396 \item Always add |\topsep| before and after a list
397 \item Add |\parskip| (not |\parsep|) always before a list and usually after it\footnote{\TeX\ treats any text after a list as the start of a new paragraph, so if the next material to be typeset is text, \TeX\ adds \vrb\parskip\ after the list. If the user includes a box or rule instead of text, it does not trigger the start of a paragraph, and \TeX\ does not add \vrb\parskip.}
398 \item If a list begins outside of a paragraph, add |\partopsep| before and after the list
399 \end{itemize}
400 If |\parskip| is nonzero, for example in a formal letter, it is impossible to include a list inside a paragraph without the inter-paragraph space suggesting that the list forms its own paragraph. (Unless the user manually changes |\parskip| or adds negative vertical glue.) Similarly, \LaTeX\ chooses whether to add |\partopsep| after a list independently of what happens at that point in the source code.
401
402 The \textsf{listparskip} package modifies this behavior by making the |\parskip| and |\partopsep| spacing depend more closely on paragraph structure from the source code. Under \textsf{listparskip} rules, the space around lists happens as follows:
403 \begin{itemize}
404 \item Always add |\topsep| before and after a list
405 \item If a list begins outside of a paragraph, add |\parskip| and |\partopsep| before the list
406 \item If a blank line comes immediately after the list in the source code, always add |\partopsep| and usually add |\parskip|
407 \end{itemize}
408 These changes happen automatically after loading the package, and they allow the user to control whether \TeX\ positions a list environment as its own paragraph or as part of the surrounding paragraph. When |\parskip| and |\partopsep| are both 0pt, this package does nothing, but for an example of what can happen when either dimension is positive, see |listparskip_example.pdf|, which is included with the \textsf{listparskip} installation and is available on \textsc{ctan}. Users can load \textsf{listparskip} with the standard |\usepackage{listparskip}| syntax, and the package has no options.
409
410
411
412 \begin{figure}[t]
413 \centerline{\bfseries Table 1: Recommended Source Code to Insert after a List\strut}
414 \begin{tabularx}{\textwidth}{lXX}\toprule
415 Next Material to Typeset & No New Paragraph Desired & New Paragraph Desired \\\midrule
416 Text & Nothing & Blank line \\
417 |\item| & Nothing & Nothing or blank line \\
418 Box or Rule & |\nullline| & Blank line, then |\nullline| \\\bottomrule
419 \end{tabularx}
420 \end{figure}
421
422 \begin{figure}[tb]
423 \centerline{\bfseries Table 2: Space after a List When Using \textsf{listparskip}\strut}
424 \begin{tabularx}{\textwidth}{XX}\toprule
425 Material after a List & Vertical Space Used in Addition to |\topsep|\\\midrule
426 Text* & None \\
427 Box & Don't do this\textsuperscript\ddag \\
428 |\item|*\textsuperscript\dag & $\vrb\parsep+\vrb\itemsep$ \\\midrule
429 Blank line, then text* & $\vrb\partopsep+\vrb\parskip$ \\
430 Blank line, then box & Don't do this\textsuperscript\ddag \\
431 Blank line, then |\item|*\textsuperscript\dag &
432 $\vrb\partopsep+\vrb\parsep+\vrb\itemsep$ \\\midrule
433 |\nullline|, then text & |\parskip| \\
434 |\nullline|, then box* & None \\
435 |\nullline|, then |\item|\textsuperscript\dag &
436 $\vrb\parsep+\vrb\itemsep$ \\\midrule
437 Blank line, then |\nullline|, then text &
438 $\vrb\partopsep+2\vrb\parskip$ \\
439 Blank line, then |\nullline|, then box* &
440 $\vrb\partopsep+\vrb\parskip$ \\
441 Blank line, then |\nullline|, then |\item|\textsuperscript\dag &
442 $\vrb\partopsep+2\vrb\parsep+\vrb\itemsep$ \\
443 \bottomrule
444 \end{tabularx}
445 \smallskip
446 \vbox{\footnotesize\noindent\hskip 1.8em\llap{*}Recommended use.
447
448 \noindent\hskip 1.8em\llap{\textsuperscript\dag}For \vrb\item\ in a nested list, the \vrb\parsep\ and \vrb\itemsep\ refer to the dimensions in the outer list, not the list that just ended.
449
450 \noindent\hskip 1.8em\llap{\textsuperscript\ddag}With \textsf{listparskip}, putting a box after the end of a list environment without text or \vrb\nullline\ previously may mess up vertical spacing or paragraph indentation after the box depending on what comes next.}
451 \end{figure}
452
453 Immediately after the end of a list environment, \textsf{listparskip} expects to see a some text, a blank line followed by text, or an |\item|. As a general rule, text means an extra |\topsep|, and a blank line followed by text leads to an extra $\vrb\topsep+\vrb\partopsep+\vrb\parskip$. If you want to put something else, such as a box or rule, after the end of a list environment, you should type |\nullline| before the other material to prevent any spacing mishaps. This macro instructs \TeX\ to behave like it just encountered a line of text except without adding any vertical space. Table~1 shows my recommendations for code to include after a list in various cases depending on the desired result, and Table~2 shows the full rules for what happens after a list with \textsf{listparskip} in various situations. For more information, see |listparskip_code.pdf|, which is included with the \textsf{listparskip} installation and is available on \textsc{ctan}.
454
455
456
457
458
459 \end{document}
460 %
461 %</user>
462 %<*example>
463 %
464 %
465 \documentclass[12pt]{article}
466 \usepackage[margin=72.27pt]{geometry}
467 \usepackage[factor=700,stretch=14,shrink=14,step=1]{microtype}
468 \usepackage{lipsum}
469 \usepackage{multicol}
470 \usepackage{enumitem}
471 \setlist{parsep=0pt,partopsep=\medskipamount,
472 topsep=\smallskipamount,itemsep=\smallskipamount}
473 \usepackage{shortvrb}
474 \MakeShortVerb{|}
475 \parindent=0pt
476 \makeatletter
477 \begin{document}
478
479 \def\documentname{Example}
480
481 \newdimen\MacroIndent
482 \input listparskip_heading.tex
483 \baselineskip=14pt
484
485 This document shows an example of \textsf{listparskip}. The left column uses standard \LaTeX\ spacing before and after the itemize and enumerate lists, and the right column shows the same text with \textsf{listparskip} spacing rules. Notice \textsf{listparskip} corrects the issues from the left column.
486 \begin{multicols*}{2}
487 \parskip\bigskipamount
488
489 \lipsum[1][1]
490
491 This paragraph has some bullet points in the middle of the paragraph. In this portion of the document, |\parskip| is set to |\bigskipamount|, and we see that
492 \begin{itemize}
493 \item \LaTeX\ inserts |\parskip| above the list
494 \item Even though there is no |\par| between the paragraph and the itemize environment in the source code
495 \item The same thing is true after the itemize
496 \item It's especially salient when |\topsep| and |\itemsep| are |\smallskipamount|
497 \end{itemize}
498 Currently |\partopsep| is |\medskipamount|, but when there is no |\par| immediately before a list, \LaTeX\ does not insert |\partopsep| before or after the list environment. \hbox{This is true}
499 \begin{enumerate}
500 \item Despite the use of |\parskip|; and
501 \item For the end of the list environment regardless of whether a |\par| follows the list, as is the case with this enumerate.
502 \end{enumerate}
503
504 \lipsum[1][2]
505
506 \vfill\nointerlineskip\null
507 \columnbreak
508
509 \lipsum[1][1]
510
511 This paragraph has some bullet points in the middle of the paragraph. In this portion of the document, |\parskip| is set to |\bigskipamount|, and we see that
512 \begin{itemize}
513 \vskip-\@outerparskip
514 \vskip\z@
515 \item \LaTeX\ inserts |\parskip| above the list
516 \item Even though there is no |\par| between the paragraph and the itemize environment in the source code
517 \item The same thing is true after the itemize
518 \item It's especially salient when |\topsep| and |\itemsep| are |\smallskipamount|
519 \end{itemize}
520 \vskip-\parskip
521 Currently |\partopsep| is |\medskipamount|, but when there is no |\par| immediately before a list, \LaTeX\ does not insert |\partopsep| before or after the list environment. \hbox{This is true}
522 \begin{enumerate}
523 \vskip-\@outerparskip
524 \vskip\z@
525 \item Despite the use of |\parskip|; and
526 \item For the end of the list environment regardless of whether a |\par| follows the list, as is the case with this enumerate.
527 \end{enumerate}
528 \vskip\partopsep
529
530 \lipsum[1][2]
531
532 \end{multicols*}
533
534 \end{document}
535 %
536 %
537 %</example>
538 %<*heading>
539 %
540 % preliminaries
541 \csname count@\endcsname\catcode`\@
542 \makeatletter
543 % date
544 \def\packageversion{1.0}
545 \def\packagedate{December 2024}
546 % spacing macros
547 \MacroIndent=1.3em
548 \baselineskip=\the\baselineskip plus 0.3pt minus 0.3pt\relax
549 % section redefinition
550 \let\@@section\section
551 \def\section{\@ifstar\star@sect\no@star@sect}
552 \def\star@sect#1{\sectionhook{#1}\@@section*{#1}}
553 \def\no@star@sect#1{\sectionhook{#1}\@@section{#1}}
554 %
555 \def\sectionhook#1{%
556 \ifdim\dimexpr\pagegoal-\pagetotal-3pt\relax<6\bigskipamount
557 \vfill\eject
558 \fi
559 \def\sectionname{#1}}
560 \let\sectionhook\@gobble
561 % header and footer (centered page number in the foot
562 % for first page only; otherwise at left or right of
563 % the header)
564 \def\@oddhead{%
565 \ifnum\count0>1\relax
566 \ifodd\c@page
567 \hfil
568 \llap{\the\count0}%
569 \else
570 \rlap{\the\count0}\hfil
571 \fi
572 \fi}
573 \def\@oddfoot{\hfil\ifnum\count0=1\relax1\fi\hfil}
574 % penalties
575 \pretolerance=-1
576 \hyphenpenalty=20
577 \exhyphenpenalty=15
578 \brokenpenalty=0
579 \clubpenalty=0
580 \widowpenalty=0
581 \finalhyphendemerits=500
582 \doublehyphendemerits=2000
583 % floats
584 \c@topnumber\@ne
585 \def\topfraction{1}
586 \def\bottomfraction{0.5}
587 \def\textfraction{0}
588 \def\floatpagefraction{0}
589 % macros
590 \def\h{\textsc h }
591 \def\v{\textsc v }
592 \def\smallskip{\vskip\smallskipamount}
593 \def\medskip{\vskip\medskipamount}
594 \def\bigskip{\vskip\bigskipamount}
595 % environment for code (would probably better to use
596 % trivlist)
597 \let\code\@undefined
598 \let\endcode\@undefined
599 \newenvironment{code}
600 {\strut\vadjust\bgroup\medskip\parindent\z@\leftskip=4em\relax
601 \noindent\strut\ignorespaces}
602 {\strut\par\medskip\egroup\hfill\break\strut\ignorespacesafterend}
603 \def\argtext#1{\ensuremath{\langle$\textit{#1}$\rangle}}
604 \def\vrb#1{\expandafter\texttt\expandafter{\string#1}}
605 \def\clap@math#1{\hb@xt@\z@{\hss$\displaystyle#1$\hss}}
606 % begin first-page heading
607 {\large
608 \parindent=0pt
609 \leftskip=0pt plus 1 fil
610 \rightskip=0pt plus 1fil
611 \parfillskip=0pt
612 {\strut\Large Package \textsf{listparskip} v.\ 1.0 \documentname}\par
613 \strut Conrad Kosowsky\par
614 \strut \packagedate\par
615 \strut\texttt{[email protected]}\par}
616 % bigskip
617 \bigskip
618 % overview/abstract
619 {\small
620 \leftskip=0.5in
621 \rightskip=0.5in
622 \centerline{\bfseries Overview\strut}
623 \noindent The \textsf{listparskip} package modifies list environments such that they add |\parskip| and |\partopsep| before or after a list if and only if the environment follows or precedes, respectively, a blank line (i.e.\ a |\par|).
624 \par}
625 % bar between overview/abstract and text
626 \bigskip\bigskip\nointerlineskip
627 \centerline{\vrule height 0.5pt width 2.5in}\bigskip\bigskip
628 \nointerlineskip
629 % restore catcode
630 \catcode`\@\count@
631 %
632 %
633 %</heading>
634 % \fi
635 %
636 %
637 \endinput