Debian Codegraph @

texmf-dist/source/latex/tocdata/tocdata.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright 2016--2024 Brian Dunn
4 %
5 % This work may be distributed and/or modified under the
6 % conditions of the LaTeX Project Public License, either version 1.3
7 % of this license or (at your option) any later version.
8 % The latest version of this license is in
9 % http://www.latex-project.org/lppl.txt
10 % and version 1.3 or later is part of all distributions of LaTeX
11 % version 2005/12/01 or later.
12 %
13 % \fi
14 %
15 % \iffalse
16 %<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
17 %<package>\ProvidesPackage{tocdata}
18 %<package> [2024/01/20 v2.07 Adds author/artist to TOC entries.]
19 %
20 %<*driver>
21 \documentclass{ltxdoc}
22
23
24 \newcommand{\mypackagename}{tocdata}
25
26 \newcommand{\quicksummary}{%
27 Optionally prints author, artist, or other data on a line
28 of the \acro{TOC}\Slash\acro{LOF}.
29 }
30
31
32 % \usepackage{lmodern}
33 \usepackage{erewhon}
34 \usepackage{cabin}
35 \usepackage{inconsolata}
36 % \usepackage{libertine}
37 \usepackage[T1]{fontenc}
38 \usepackage[utf8]{inputenc}
39 \usepackage{textcomp} % provides \degree, \textquotesingle, \textmu
40 \usepackage{textgreek}
41
42 \usepackage{newunicodechar}
43 \newunicodechar{ff}{ff}
44 \newunicodechar{fi}{fi}
45 \newunicodechar{fl}{fl}
46 \newunicodechar{ffi}{ffi}
47 \newunicodechar{ffl}{ffl}
48 % \newunicodechar{°}{\degree}
49 \newunicodechar{ρ}{\ensuremath{\rho}}
50 \newunicodechar{⨯}{\texttimes}
51 \newunicodechar{⁄}{\textfractionsolidus}
52 % \newunicodechar{®}{\textregistered}
53 % \newunicodechar{©}{\textcopyright}
54 \newunicodechar{—}{---}
55 \newunicodechar{–}{--}
56 % \newunicodechar{”}{''}
57 % \newunicodechar{“}{``}
58 % \newunicodechar{§}{\S}
59 % \newunicodechar{¶}{\P}
60 % \newunicodechar{†}{\dag}
61 \newunicodechar{‡}{\ddag}
62
63 \usepackage{metalogo}
64 \makeatletter
65 \@ifpackageloaded{erewhon}{
66 \setlogokern{Te}{-.08em}
67 \setlogokern{eX}{-0.04em}
68 \setlogokern{La}{-.25em}
69 \setlogokern{aT}{-.08em}
70 \setlogokern{Xe}{-.04em}
71 \setlogokern{eL}{-.06em}
72 \setlogodrop{0.27ex}
73 }{}
74 \makeatother
75
76 \usepackage{microtype}
77
78 \usepackage{etoolbox}
79
80 \usepackage[log-declarations=false]{xparse}
81
82 \usepackage[svgnames]{xcolor}
83 \definecolor{myurlcolor}{rgb}{0,0,.7}
84 \definecolor{mylinkcolor}{rgb}{.7,0,0}
85 \definecolor{codecolor}{rgb}{0,.4,.2}
86 \definecolor{overviewcolor}{rgb}{0,.2,.4}
87
88 \usepackage{dtxdescribe}[2023/01/03]
89
90 \usepackage{graphicx}
91 \graphicspath{{images/}}
92
93 \usepackage{enumitem}
94
95 \usepackage{array}
96 \usepackage{longtable}
97 \usepackage{booktabs}
98
99 \usepackage[all,defaultlines=2]{nowidow}
100
101 \usepackage[normalem]{ulem}
102
103 \usepackage{fancyvrb}
104
105
106 \usepackage{newfloat}
107
108 \DeclareFloatingEnvironment[
109 fileext=loi,
110 listname={List of Illustrations},
111 name=Illustration,
112 placement=tbp,
113 ]{illustration}
114
115 \DeclareFloatingEnvironment[
116 fileext=loq,
117 listname={List of Quotations},
118 name=Quotation,
119 placement=tbp,
120 ]{aquote}
121
122 \setlength{\floatsep}{5ex}
123 \setlength{\textfloatsep}{5ex}
124
125
126 \usepackage{\mypackagename}
127
128
129
130 \usepackage{titletoc}
131 % \usepackage{tocloft}
132
133
134 \usepackage{titleps}
135
136 \newpagestyle{pageheadfoot}{
137 \headrule
138 \sethead{\pkg{\mypackagename}}{}{\thepage}
139 % \renewcommand{\makefootrule}{\rule[2.5ex]{\linewidth}{.4pt}}
140 \setfoot{}{}{}
141 }
142
143 \pagestyle{pageheadfoot}
144
145 \usepackage{needspace}
146
147
148
149 \AtBeginDocument{
150 \hypersetup{%
151 pdfinfo={%
152 Title={LaTeX \mypackagename{} package},%
153 Author={Brian Dunn},%
154 Subject={LaTeX tocdata package},%
155 Keywords={LaTeX, tocdata, contents},%
156 },%
157 colorlinks,%
158 linkcolor=mylinkcolor,%
159 urlcolor=myurlcolor,%
160 pageanchor=true,
161 }
162
163 \pdfstringdefDisableCommands{
164 \def\quad{ }
165 \def\\{ }
166 \def\pkg#1{#1}
167 \def\cs#1{\textbackslash#1}
168 \def\env#1{#1}
169 \def\,{ }
170 \def\prog#1{#1}
171 \def\LuaLaTeX{LuaLaTeX}
172 \def\XeLaTeX{XeLaTeX}
173 \def\TeX{TeX}
174 \def\LaTeX{LaTeX}
175 \def\Dash{ --- }
176 \def\dash{ -- }
177 \def\element#1{#1}
178 \def\attribute#1{#1}
179 }
180
181 }% AtBeginDocument
182
183 \AddToHook{begindocument/before}{% Before .aux file is loaded.
184 \usepackage{cleveref}% If needed.
185 }
186
187
188 % from dtxdescribe:
189 \setlength{\marginparsep}{1em}
190 \setlength{\marginparpush}{.7ex}
191
192
193
194 \setlength{\parindent}{2em}
195 \setlength{\parskip}{0ex}
196
197 \setlength{\IndexMin}{40ex}
198
199
200
201 \setcounter{IndexColumns}{2}
202 \setcounter{GlossaryColumns}{1}
203
204 \DisableCrossrefs
205 \CodelineIndex
206 \RecordChanges
207 \begin{document}
208 \DocInput{\mypackagename.dtx}
209 \end{document}
210 %</driver>
211 % \fi
212 %
213
214 % \changes{v0.10}{2016/05/05}{\ 2016/05/05 Initial ver.}
215 % \changes{v0.11}{2016/07/11}{\ 2016/07/11}
216 % \changes{v0.11}{2016/07/11}{Minor docs improvements in spelling, grammar, formatting.}
217 % \changes{v0.12}{2016/12/02}{\ 2016/12/02}
218 % \changes{v1.00}{2019/01/08}{Improved source formatting.}
219 % \changes{v1.00}{2019/01/12}{\ 2019/01/12}
220 % \changes{v2.00}{2019/03/15}{Added part and subsection macros.}
221 % \changes{v2.00}{2019/03/15}{Added caption authors.}
222 % \changes{v2.00}{2019/03/15}{Added support for new float types.}
223 % \changes{v2.00}{2019/03/15}{\ 2019/03/15}
224 % \changes{v2.01}{2019/03/15}{\ 2019/03/15}
225 % \changes{v2.02}{2019/03/21}{\ 2019/03/21}
226 % \changes{v2.03}{2019/07/06}{\ 2019/07/06}
227 % \changes{v2.04}{2020/07/15}{\ 2020/07/15}
228 % \changes{v2.05}{2023/01/03}{Docs updated for \pkg{dtxdescribe}.}
229 % \changes{v2.05}{2023/01/03}{\ 2023/01/03}
230 % \changes{v2.06}{2024/01/12}{\ 2024/01/12}
231 % \changes{v2.06}{2024/01/12}{Changed contact info.}
232 % \changes{v2.07}{2024/01/18}{Docs: Improved TOC change log and index entries.}
233 % \changes{v2.07}{2024/01/20}{Docs: Removed extra spaces.}
234 % \changes{v2.07}{2024/01/20}{2024/01/20}
235
236
237
238 % \GetFileInfo{\mypackagename.sty}
239 %
240 % \DoNotIndex{\newcommand,\renewcommand,\addtocounter,\begin,\end,\begingroup,\endgroup}
241 % \DoNotIndex{\global,\ifbool,\ifthenelse,\isequivalentto,\let}
242 % \DoNotIndex{\booltrue,\boolfalse}
243 % \expandafter\DoNotIndex\expandafter{\detokenize{\(,\),\,,\\,\#,\$,\%,\^,\_,\~,\ ,\&,\{,\}}}
244 %
245 % ^^A \renewcommand{\listfigurename}{List of }
246 % \begin{center}
247 % \thispagestyle{empty}
248 % \vfill
249 % ^^A \includegraphics[width=.3\linewidth]{\mypackagename_logo.pdf}
250 % \vfill
251 % {\Huge The \pkg{\mypackagename} package}
252 % \bigskip
253 %
254 % \fileversion{} --- \filedate
255 %
256 % \bigskip
257 %
258 % {\small\textcopyright{} 2016--2024} Brian Dunn\\ \small \url{https://github.com/bdtc/tocdata}
259 %
260 % \vspace{.5in}
261 %
262 % {\normalsize\textup{\quicksummary}}
263 %
264 %
265 %
266 % \vfill
267 %
268 % \begin{abstract}
269 % \noindent
270 % The \pkg{tocdata} package adds information such as an author or artist to
271 % an entry in the table of contents or list of figures or new float type.
272 % This new information is placed on a single line along with the caption and page number,
273 % as is commonly done in collections of literature, poetry, or art work.
274 %
275 % \pkg{tocdata} works with the \TOC\ \Slash \LOF\ formatting of
276 % the default \LaTeX\ classes, \pkg{memoir}, \pkg{koma-script},
277 % and with \pkg{titletoc}, \pkg{tocloft}, \pkg{tocbasic}, and \pkg{tocstyle}.
278 % \end{abstract}
279 %
280 % \vspace*{\fill}
281 % \vspace*{\fill}
282 % \vspace*{\fill}
283 % \end{center}
284 %
285 % \clearpage
286 %
287 % \tableofcontents
288 % ^^A \clearpage
289 % \listoffigures
290 % ^^A \listoftables
291
292 % \needspace{6\baselineskip}
293 % \listofillustrations
294
295 % \listofaquotes
296 %
297 %
298 % \thispagestyle{pageheadfoot}
299 %
300 % \clearpage
301 %
302 % \sectionauthor{Introduction}{Brian}{Dunn}
303 %
304 % \begin{figure}
305 % \setlength{\fboxsep}{0pt}
306 % \centering
307 % \fbox{\includegraphics[width=2in]{go_problem.png}}
308 % \captionartist{A Challenge}
309 % [Problem 1-2, from \textit{Gokyo Shumyo}]
310 % {Hayashi}{Genbi}
311 % \end{figure}
312 %
313 % \begin{aquote}
314 % \itshape
315 % ``Go uses the most elemental materials and concepts --- line and circle,
316 % wood and stone, black and white --- combining them with simple rules
317 % to generate subtle strategies and complex tactics that stagger the imagination.''
318 % \captionauthor{\textit{Go uses the most elemental materials and concepts \dots}}%
319 % {Iwamoto}{Kaoru}%
320 % [\textnormal{ --- former \textit{Honinbo} title holder}]
321 % \end{aquote}
322 %
323 % Anthologies may be printed with the author alongside each title in the
324 % table of contents.
325 %
326 % Many commonly-recommended methods for doing this with \LaTeX, such as those linked to in
327 % section \ref{sec:othermethods}, place the author above or below the title and
328 % page number, but seldom on the same line.
329 %
330 % The \pkg{tocdata} package provides some basic infrastructure to help
331 % add some information to a line in the table of contents, after the title
332 % and just before the page number. This function works with the standard
333 % \LaTeX\ classes, or with either of the \pkg{titletoc} or \pkg{tocloft} packages.
334 %
335 % Additionally,
336 % user-level macros are provided which add the author's name to a chapter or section,
337 % and add the author's or artist's name and optional additional text to a figure.
338 % Author and artist names are also added to the index.
339 %
340 % As examples of the use of these high-level macros,
341 % the major section headings of this documentation
342 % have the author's name applied, and additional figures, illustrations, and quotes
343 % are supplied as well.
344 % The results are demonstrated in the table of contents, list of figures,
345 % list of illustrations, list of quotes, and the index.\footnote{%
346 % Yes, I \emph{do} recognize the absurdity of placing my own name in the index
347 % amongst the likes of Churchill, Genbi, Herschel, Kaoru, Newton\,\dots}
348 %
349 %
350 % \clearpage
351 %
352 % \setlength{\parindent}{0em}
353 % \setlength{\parskip}{2ex}
354 %
355 % \sectionauthor[Other methods]{Other methods}{Various}{Authors}
356 % \label{sec:othermethods}
357 %
358 % For other methods which place the author on a separate line from the title, see the
359 % following.
360 %
361 % Note that these methods will be preferable if a larger amount of information
362 % is to be placed for each title, such that it usually would not all fit on one line
363 % \watchout[Too much text!]
364 % in the table of contents.
365 %
366 % \href
367 % {http://tex.stackexchange.com/questions/47554/add-authors-name-automatically-while-building-toc}
368 % {http://tex.stackexchange.com/questions/ \\ \hspace*{1in} 47554/add-authors-name-automatically-while-building-toc}
369 %
370 % \href
371 % {http://tex.stackexchange.com/questions/110218/add-author-before-chapter-title-in-toc}
372 % {http://tex.stackexchange.com/questions/ \\ \hspace*{1in} 110218/add-author-before-chapter-title-in-toc}
373 %
374 % \href
375 % {http://tex.stackexchange.com/questions/156862/displaying-author-for-each-chapter-in-book}
376 % {http://tex.stackexchange.com/questions/ \\ \hspace*{1in} 156862/displaying-author-for-each-chapter-in-book}%
377 %
378 % \begin{illustration}
379 % \setlength{\fboxsep}{0pt}
380 % \centering
381 % \fbox{\includegraphics[height=3in]{engineer.jpg}}
382 % \captionartist
383 % [The Crazy Engineer]
384 % {The Crazy Engineer}[Illustration from \textit{The Crazy Engineer} \par \textit{McGuffey's Fifth Eclectic Reader}]{H. F.}{Farny}
385 % \end{illustration}
386 %
387 % \clearpage
388 %
389 % \begin{figure}
390 % \centering
391 % \includegraphics[width=3in]{astronometer_herschel.jpg}
392 % \captionartist
393 % {Astronometer\label{fig:astronometer}}
394 % [Astronometer made to compare the light of certain stars by the intervention of the moon.]
395 % [Sir]{John}{Herschel}[, 1st Baronet KH FRS]
396 % \end{figure}
397 %
398 % \sectionauthor{How to use \pkg{tocdata}}{Brian}{Dunn}
399 %
400 % This section shows how to use the \pkg{tocdata} package.
401 %
402 % There are several layers of macros:
403 % \begin{itemize}
404 % \item The lowest level provides the basic infrastructure for inserting information
405 % into the table of contents, along with hooks for the \pkg{titletoc} and \pkg{tocloft} packages.
406 % \item The intermediate-level macro is \cs{tocdata}, which may be used to manually
407 % add a piece of data to a \cs{chapter}, \cs{section}, or \cs{caption}.
408 % \cs{tocdataformat} is also provided to control the appearance of this data in the \acro{TOC}\Slash\acro{LOF}.
409 % \item At the highest level is a sample implementation of user-level macros which provides
410 % an easy way to create chapters, sections, and figures with associated authors and artists,
411 % along with supplemental information for figures, and automatic index entries.
412 % \end{itemize}
413 %
414 %
415 % \subsection{Basic setup}
416 %
417 %
418 %
419 % \subsubsection{Preamble}
420 %
421 % \pkg{tocdata} may be used with either the \pkg{tocloft} or \pkg{titletoc} package,
422 % or neither.
423 %
424 % In the preamble, use:
425 % \begin{sourceverb}
426 % \usepackage{tocdata}
427 % \usepackage{titletoc}% optional
428 % \usepackage{tocloft}% optional
429 % \end{sourceverb}
430 %
431 %
432 % \subsection{Mid-level applications}
433 %
434 % Should the user only wish to add a bit of text into the \acro{TOC}\Slash\acro{LOF},
435 % the \cs{tocdata} macro may be used just before the sectioning or caption command,
436 % as shown below.
437 %
438 % \subsubsection{Font control in the \acro{TOC}\Slash\acro{LOF}}
439 %
440 % \DescribeMacro{\tocdataformat} \marg{text}
441 %
442 % To control the font and formatting used for the author on the table-of-contents line,
443 % the default is:
444 % \begin{sourceverb}
445 % \newcommand{\tocdataformat}[1]{{\normalfont\textit{\small#1}}}
446 % \end{sourceverb}
447 %
448 % You may change to other font options, add parenetheses, etc.:
449 % \begin{sourceverb}
450 % \renewcommand{\tocdataformat}[1]{%
451 % \normalfont\textsc{\footnotesize\qquad --- (#1)}%
452 % }
453 % \end{sourceverb}
454 %
455 %
456 % \subsubsection{Adding \acro{TOC} data per section}
457 %
458 % \DescribeMacro{\tocdata} \marg{list extension} \marg{text}
459 %
460 % Before each \cs{chapter} or \cs{section} which is to have an author or other data:
461 %
462 % \begin{sourceverb}
463 % \tocdata{toc}{Author's Name}
464 % \chapter{Chapter Title} -or- \section{Section Title}
465 % \end{sourceverb}
466 %
467 %
468 % \subsubsection{Adding \acro{LOF} data per figure}
469 % Before each \cs{caption} which is to have an artist or author:
470 %
471 % \begin{sourceverb}
472 % \tocdata{lof}{Artist's/Author's Name}
473 % \caption{Figure Title}
474 % \end{sourceverb}
475 %
476 % You may wish to print the artist's name in the figure as well.
477 %
478 %
479 % \subsection{High-level user macros}
480 %
481 % Additional macros are given in section \ref{sec:usermacros}.
482 % These are user-level sectioning and captioning commands which add the
483 % names to the \acro{TOC} and \acro{LOF},
484 % and also add the artist's name and optional additional text
485 % to a figure or other float (as in Figure \ref{fig:quail}),
486 % and also add the names to the index.
487 % An optional prefix and suffix may be attached to the names
488 % (as in Figure \ref{fig:astronometer}),
489 % and these will be printed at the section heading or caption, but not
490 % in the \acro{TOC}\Slash\acro{LOF} or in the index.
491 %
492 % These macros may be ignored or modified as needed.
493 %
494 % \subsubsection{Sectioning commands with authors}
495 %
496 % \DescribeMacro{\partauthor}
497 % \DescribeMacro{\chapterauthor}
498 % \DescribeMacro{\sectionauthor}
499 % \DescribeMacro{\subsectionauthor}
500 % To use these macros, do not use \cs{tocdata} as shown above, but instead use,
501 % in the place of \cs{part}:
502 % \begin{sourceverb}
503 % \partauthor[list entry]{Title}[Prefix]{First}{Last}[Suffix]
504 % \end{sourceverb}
505 % Likewise for chapters, sections, and subsections.
506 %
507 %
508 %
509 % \subsubsection{Figure captions with author \Slash artist names and additional text}
510 %
511 % \DescribeMacro{\captionartist}
512 % \DescribeMacro{\captionauthor}
513 % For figures, in the place of \cs{caption}, use:
514 %
515 % \begin{sourceverb}
516 % \captionartist[list entry]{Title}[Text][Prefix]{First}{Last}[Suffix]
517 % -or-
518 % \captionauthor[list entry]{Title}[Text][Prefix]{First}{Last}[Suffix]
519 % \end{sourceverb}
520 %
521 % By default, \cs{captionartist} prints the artist centered below the figure,
522 % and \cs{captionauthor} prints the author below and flush right, without
523 % an extra vertical skip.
524 %
525 % If you are using the optional prefix, the optional text must also be given, even if it
526 % is empty. For example, use:
527 % \watchout[Optional arguments]
528 % \begin{sourcedisplay}
529 % \cs{captionartist}\{Title\}\textcolor{red}{[]}[Sir]\{Isaac\}\{Newton\}
530 % \end{sourcedisplay}
531 % (If only one optional argument is given before the first name, it will be
532 % interpreted as the optional text, not as the optional prefix.)
533 %
534 % \DescribeMacro{\captionartist*}
535 % \DescribeMacro{\captionauthor*}
536 % If you are using the \pkg{caption} package or another package which
537 % supports \cs{caption*}, you may use \cs{captionartist*} and \cs{captionauthor*}
538 % with \pkg{tocdata}.
539 % The artist \Slash author and supplemental text will still be printed below the figure,
540 % and an unnumbered caption will be generated, even though a \acro{LOF} entry will not be made.
541 %
542 % Should you mistakenly use \cs{captionartist*} or \cs{captionauthor*}
543 % without the \pkg{caption} package,
544 % expect to get a caption with a visible star in it.
545 % \watchout[\pkg{caption} package]
546 % To fix the problem:\\
547 % \hspace*{1em} |\usepackage{caption}|
548 %
549 % \subsubsection{Formatting in sections and figures}
550 %
551 % \DescribeMacro{\tocdatapartprint}
552 % \DescribeMacro{\tocdatachapterprint}
553 % \DescribeMacro{\tocdatasectionprint}
554 % \DescribeMacro{\tocdatasubsectionprint}
555 % To change the formatting of the author names printed after
556 % each chapter or section, or to remove them entirely, use
557 % these macros, as described in section~\ref{sec:usermacros}
558 % on page~\pageref{sec:usermacros}.
559 %
560 % \cs{tocdatachapterprint} and \cs{tocdatasectionprint} by default
561 % \watchout[redefining]
562 % depend on \cs{tocdatapartprint}, so if it is redefined the others will
563 % have to be redefined as well.
564 %
565 %
566 % \DescribeMacro{\tocdataartistprint}
567 % \DescribeMacro{\tocdataartisttextprint}
568 % \DescribeMacro{\tocdataauthorprint}
569 % \DescribeMacro{\tocdataauthortextprint}
570 % To change the formatting of a figure's artist's name or author's name and optional text,
571 % use these macros, also described in section \ref{sec:usermacros}.
572 %
573 %
574 % \subsubsection{Text justification}
575 %
576 % \changes{v2.02}{2019/03/20}{Docs: Fix macro names.}
577 % \DescribeMacro{\tdartistjustify}
578 % \DescribeMacro{\tdartistcenter}
579 % \DescribeMacro{\tdartistleft}
580 % \DescribeMacro{\tdartistright}
581 % \DescribeMacro{\tdartisttextjustify}
582 % \DescribeMacro{\tdartisttextcenter}
583 % \DescribeMacro{\tdartisttextleft}
584 % \DescribeMacro{\tdartisttextright}
585 % \DescribeMacro{\tdauthorjustify}
586 % \DescribeMacro{\tdauthorcenter}
587 % \DescribeMacro{\tdauthorleft}
588 % \DescribeMacro{\tdauthorright}
589 % \DescribeMacro{\tdauthortextjustify}
590 % \DescribeMacro{\tdauthortextcenter}
591 % \DescribeMacro{\tdauthortextleft}
592 % \DescribeMacro{\tdauthortextright}
593 % The text alignment of artists, artists' additional text,
594 % authors, and authors' additional text may be set using
595 % these macros.
596 % All following figures use the selected justification
597 % until it is changed to another.
598 %
599 %
600 % \StopEventually{
601 % \appendix
602 % \GlossaryPrologue{\section{Change History}}
603 % \PrintChanges
604 % \IndexPrologue{\section{Index}}
605 % \tocdata{toc}{\prog{makeindex}}
606 % \PrintIndex
607 %
608 % \clearpage
609 %
610 % \tdauthortextright
611 % \begin{aquote}[tbp]
612 % \itshape
613 % ``Now this is not the end.
614 % It is not even the beginning of the end.
615 % But it is, perhaps, the end of the beginning.''
616 % \captionauthor{\textit{Now this is not the end \dots}}
617 % [(Full name used for demonstration purposes.)][Sir]{Winston Leonard Spencer}{Churchill}
618 % \end{aquote}
619 %
620 % \begin{figure}[tbp]
621 % \centering
622 % \setlength{\fboxsep}{2ex}
623 % {\fontsize{35}{50}\selectfont\textOmega}
624 % \captionartist{Omega}{Greek}{Alphabet}
625 % \end{figure}
626 %
627 %}
628 %
629 % \begin{illustration}[hbp]
630 % \setlength{\fboxsep}{0pt}
631 % \centering
632 % \fbox{\includegraphics[width=3in]{quail.jpg}}
633 % \captionartist{Quail\label{fig:quail}}
634 % [Illustration from \textit{About Quail} \par \textit{McGuffey's Fifth Eclectic Reader}]
635 % {Alexander}{Pope}
636 % \end{illustration}
637 %
638 %
639 % \clearpage
640 %
641 % \sectionauthor{Code}{Brian}{Dunn}
642 %
643 % \begin{figure}
644 % \centering
645 % \includegraphics[width=3in]{diagram_sunbeam.jpg}
646 % \captionartist
647 % {Diagram of a Sunbeam}[]
648 % [Sir]{Isaac}{Newton}
649 % \end{figure}
650 %
651 % Below, the \pkg{tocdata} code section contains the low-level code used to
652 % place the data into the table of contents and list of figures, as well as
653 % the code to control the font used while doing so.
654 %
655 % Next are sections used to support the default \LaTeX\ classes,
656 % as well as \pkg{titletoc} and \pkg{tocloft}.
657 %
658 % Finally, the high-level macros are provided. The user may ignore or redefine these
659 % as desired.
660 %
661 %
662 % \subsection{Requirements}
663 %
664 % \changes{v0.12}{2016/12/02}{Added requirement for \pkg{xifthen}.}
665 % \changes{v1.00}{2019/01/08}{Remove \pkg{xifthen} dependency.}
666 %
667 % \begin{macrocode}
668 \RequirePackage{xparse}
669 \RequirePackage{etoolbox}
670 \RequirePackage{xpatch}
671 % \end{macrocode}
672
673
674 % Require that \pkg{titletoc} and \pkg{tocloft} be loaded
675 % after \pkg{tocdata}, so that \pkg{tocdata} can patch
676 % the \LaTeX\ core definitions first.
677 % \changes{v2.00}{2019/03/12}{Test for early \pkg{titletoc} or \pkg{tocloft}.}
678 % \changes{v2.03}{2019/07/04}{Added support for \pkg{memoir}.}
679 % \begin{macrocode}
680 \@ifpackageloaded{titletoc}{
681 \PackageError{tocdata}
682 {%
683 Load titletoc after tocdata%
684 }
685 {%
686 Move \protect\usepackage{titletoc} after \protect\usepackage{tocdata}.%
687 }
688 }{}
689
690 \@ifclassloaded{memoir}
691 {}% memoir
692 {% not memoir
693
694 \@ifpackageloaded{tocloft}{
695 \PackageError{tocdata}
696 {%
697 Load tocloft after tocdata%
698 }
699 {%
700 Move \protect\usepackage{tocloft} after \protect\usepackage{tocdata}.%
701 }
702 }{}
703
704 }% not memoir
705 % \end{macrocode}
706
707 % Prevent the use of both \pkg{titletoc} and \pkg{tocloft}.
708 % \changes{v2.00}{2019/03/12}{Test for both \pkg{titletoc} and \pkg{tocloft}.}
709 % \begin{macrocode}
710 \AtBeginDocument{
711 \@ifpackageloaded{titletoc}{
712 \@ifpackageloaded{tocloft}{
713 \PackageError{tocdata}
714 {%
715 Both titletoc and tocloft are being used.\MessageBreak
716 Load only one%
717 }
718 {%
719 The tocdata package may use the default LaTeX formatting,\MessageBreak
720 or either one of titletoc or tocloft.
721 }
722 }{}
723 }{}
724 }
725 % \end{macrocode}
726
727
728
729 % \subsection{\pkg{tocdata} code}
730 % \begin{macro}{\TD@thistocdata}
731 % Storage for the data to be added to the end of the \acro{TOC} entry:
732 % \begin{macrocode}
733 \newcommand{\TD@thistocdata}{}
734 % \end{macrocode}
735 % \end{macro}
736
737 % \begin{macro}{\settocdata}
738 % Written to the |.toc| or |.lof| file, assigns \cs{TD@thistocdata}:
739 % \begin{macrocode}
740 \newcommand{\settocdata}[1]{\renewcommand{\TD@thistocdata}{#1}}
741 % \end{macrocode}
742 % \end{macro}
743
744 % \begin{macro}{\tocdata} \marg{|toc| or |lof|} \marg{text}
745 %
746 % To be called by a higher-level macro to assign data to a |.toc| or |.lof| file:
747 % \begin{macrocode}
748 \newcommand{\tocdata}[2]{%
749 \@bsphack\addtocontents{#1}{\protect\settocdata{#2}}\@esphack%
750 }
751 % \end{macrocode}
752 % \end{macro}
753 %
754 %
755 % \begin{macro}{\tocdatafont} \marg{text} \qquad
756 % Provided for compatibility with older documents.
757 % Instead, use and redefine \cs{tocdataformat} for newer documents.
758 % \watchout[deprecated]
759 %
760 % \begin{macrocode}
761 \newcommand{\tocdatafont}[1]{{\normalfont\textit{\small#1}}}
762 % \end{macrocode}
763 % \end{macro}
764 %
765 %
766 % \begin{macro}{\tocdataformat} \marg{text}
767 %
768 % Controls the font and formatting for the \acro{TOC} data:
769 %
770 % \begin{sourceverb}
771 % \renewcommand{\tocdataformat}[1]{\textit{#1}}
772 % \end{sourceverb}
773 %
774 % \begin{macrocode}
775 \def\tocdataformat{\tocdatafont}
776 % \end{macrocode}
777 % \end{macro}
778 %
779 %
780 % \begin{macro}{\TD@usetocdata}
781 %
782 % To be inserted into low-level \acro{TOC}-generation code where the data should appear.
783 %
784 % See the example using \pkg{titletoc}, below.
785 %
786 % Prints the data, then clears the storage so it is not printed again.
787 %
788 % \changes{v2.03}{2019/06/30}{Fix: No action if empty data.}
789 % \changes{v2.03}{2019/06/30}{Uses \cs{tocdataformat} instead of \cs{tocdatafont}.}
790 % \begin{macrocode}
791 \newcommand{\TD@usetocdata}{%
792 \ifdefvoid{\TD@thistocdata}{}{%
793 \tocdataformat{\TD@thistocdata}%
794 \global\def\TD@thistocdata{}%
795 }%
796 }
797 % \end{macrocode}
798 % \end{macro}
799
800
801 % \begin{macro}{\TD@checktocdatafont} \marg{text}
802 %
803 % Used to detect whether the user redefined \cs{tocdatafont},
804 % in which case a warning is issued to use \cs{tocdataformat} instead.
805 % \begin{macrocode}
806 \let\TD@checktocdatafont\tocdatafont
807
808 \AtBeginDocument{
809 \ifdefequal\TD@checktocdatafont\tocdatafont{}{
810 \PackageWarningNoLine{tocdata}{%
811 You have redefined \protect\tocdatafont,\MessageBreak
812 which has been deprecated. Please redefine\MessageBreak
813 \protect\tocdataformat\space instead}
814 }
815 }
816 % \end{macrocode}
817 % \end{macro}
818
819
820
821
822 % \subsection{Standard \LaTeX\ patches}
823 %
824 % \changes{v2.00}{2019/03/12}{Adds support for default \LaTeX\ \TOC\ formattting,
825 % without using \pkg{titletoc} or \pkg{tocloft}.}
826 % \changes{v2.03}{2019/06/30}{Fix: Don't try to patch \pkg{lwarp}.}
827 %
828 % \begin{macro}{\TD@patchstandardlatex} Patches standard \LaTeX\ \TOC\ formatting.
829 % \begin{macrocode}
830 \newcommand*{\TD@patchstandardlatex}{
831 % \end{macrocode}
832 %
833 % \begin{macro}{\@dottedtocline} Patched for \pkg{tocdata}.
834 % \begin{macrocode}
835 \xpatchcmd{\@dottedtocline}
836 {\hfill\nobreak}
837 {\hfill\TD@usetocdata\nobreak}
838 {}%
839 {%
840 \PackageWarningNoLine{tocdata}{%
841 Could not patch LaTeX core \protect\@dottedtocline.\MessageBreak
842 Authors may not appear in TOC, LOF}
843 }%
844 % \end{macrocode}
845 % \end{macro}
846
847 % \begin{macro}{\l@part} Patched for \pkg{tocdata}.
848 % \changes{v2.03}{2019/07/04}{Added support for \pkg{memoir}.}
849 % \changes{v2.03}{2019/07/06}{Added support for \pkg{koma-script}.}
850 % \begin{macrocode}
851 \@ifclassloaded{memoir}{}{%
852 \@ifpackageloaded{tocbasic}{}{%
853 \xpatchcmd{\l@part}
854 {\hfil}
855 {\hfil\TD@usetocdata}
856 {}%
857 {%
858 \PackageWarningNoLine{tocdata}{%
859 Could not patch LaTeX core \protect\l@part.\MessageBreak
860 Authors may not appear in TOC parts}
861 }%
862 }}
863 % \end{macrocode}
864 % \end{macro}
865
866 % \begin{macro}{\l@chapter} Patched for \pkg{tocdata}.
867 % \changes{v2.03}{2019/07/04}{Added support for \pkg{memoir}.}
868 % \changes{v2.03}{2019/07/06}{Added support for \pkg{koma-script}.}
869 % \begin{macrocode}
870 \@ifclassloaded{memoir}{}{%
871 \@ifpackageloaded{tocbasic}{}{%
872 \@ifundefined{chapter}{}{%
873 \xpatchcmd{\l@chapter}
874 {\hfil\nobreak}
875 {\hfil\TD@usetocdata\nobreak}
876 {}%
877 {%
878 \PackageWarningNoLine{tocdata}{%
879 Could not patch LaTeX core \protect\l@chapter.\MessageBreak
880 Authors may not appear in TOC chapters}
881 }%
882 }}}
883 % \end{macrocode}
884 % \end{macro}
885
886 % \begin{macro}{\l@section} Patched for \pkg{tocdata}.
887 % \changes{v2.01}{2019/03/15}{Fix for \LaTeX\ core section \TOC\ entry.}
888 % \changes{v2.03}{2019/06/30}{Fix: Only patch if \pkg{article}.}
889 % \begin{macrocode}
890 \@ifclassloaded{article}{
891 \xpatchcmd{\l@section}
892 {\hfil\nobreak}
893 {\hfil\TD@usetocdata\nobreak}
894 {}%
895 {%
896 \PackageWarningNoLine{tocdata}{%
897 Could not patch LaTeX core \protect\l@section.\MessageBreak
898 Authors may not appear in TOC sections}
899 }%
900 }{}
901 % \end{macrocode}
902 % \end{macro}
903 %
904 % \begin{macrocode}
905 }% TD@patchstandardlatex
906 % \end{macrocode}
907 % \end{macro}
908 %
909 %
910 % Patch standard \LaTeX\ if not using \pkg{lwarp}, or if
911 % \pkg{lwarp} is used in print mode:
912 % \begin{macrocode}
913 \@ifpackageloaded{lwarp}{%
914 \ifbool{warpingprint}{\TD@patchstandardlatex}{}%
915 }{%
916 \TD@patchstandardlatex%
917 }
918 % \end{macrocode}
919
920
921 % \subsection{\pkg{titletoc} support}
922 %
923 % \begin{figure}
924 % \centering
925 % \setlength{\fboxsep}{2ex}
926 %
927 % {\fontsize{140}{160}\selectfont$\pi$}
928 % \captionartist{Pi\label{fig:workofart}}{Greek}{Alphabet}
929 % \end{figure}
930 %
931 % \changes{v2.03}{2019/07/04}{Tested to work with \cs{dottedcontents}.}
932 %
933 % If \pkg{titletoc} is loaded, patch macros for its use:
934 % \changes{v2.00}{2019/03/13}{Patches \cs{AtBeginDocument}.}
935 % \begin{macrocode}
936 \AtBeginDocument{
937 \@ifpackageloaded{titletoc}{
938 % \end{macrocode}
939 %
940
941 % \DescribeMacro{\titlecontents}
942 % A set of \pkg{titletoc} commands which set up the formatting of the
943 % \acro{TOC} entries. These are patched \cs{AtBeginDocument},
944 % after user customizations in the preamble, to include the tocdata just after
945 % the leader (|titlerule*|), and just before the page number.
946 %
947 % These macros also include spacing commands, and thus may need to be
948 % redefined by the user.
949 %
950 % The default macros are patched via the \LaTeX\ core.
951 % The following are only necessary if \cs{titlecontents} was used.
952 % Since every combination is tried, but will only succeed if \cs{titlecontents}
953 % was used, no warnings are printed if the patch fails.
954 %
955 % \changes{v2.00}{2019/03/13}{Improved patches for \pkg{titletoc}.}
956 %
957 % \begin{macrocode}
958 \newcommand*{\TD@titletoc@patch}[1]{%
959 \expandafter\xpatchcmd\csname ttl@savel@#1\endcsname
960 {\nobreak\hfil\nobreak}
961 {\nobreak\hfil\TD@usetocdata\nobreak}
962 {}
963 {%
964 \PackageWarningNoLine{tocdata}{%
965 Could not patch titletoc ttl@savel@#1.\MessageBreak
966 Authors may not appear in TOC, LOF}
967 }
968 \expandafter\xpatchcmd\csname l@#1\endcsname
969 {\contentspage}
970 {\TD@usetocdata\contentspage}
971 {}
972 {%
973 \PackageWarningNoLine{tocdata}{%
974 Could not patch titletoc l@#1.\MessageBreak
975 Authors may not appear in TOC, LOF}
976 }
977 }
978
979 \TD@titletoc@patch{part}
980 \@ifundefined{chapter}{}{\TD@titletoc@patch{chapter}}
981 \TD@titletoc@patch{section}
982 \TD@titletoc@patch{subsection}
983 \TD@titletoc@patch{subsubsection}
984 \TD@titletoc@patch{paragraph}
985 \TD@titletoc@patch{subparagraph}
986 \TD@titletoc@patch{figure}
987 \TD@titletoc@patch{table}
988 }% end of titletoc loaded
989 {% titletoc is not loaded
990 }% end of \@ifpackageloaded{titletoc}
991 }% end of \AtBeginDocument
992 % \end{macrocode}
993
994
995 % \subsection{\pkg{tocloft} and \pkg{memoir} support}
996 %
997 % If \pkg{tocloft} is loaded, the following patches are applied.
998 % \pkg{memoir} emulates \pkg{tocloft}, so it is patched here as well.
999 % \changes{v2.00}{2019/03/13}{Patches \cs{AtBeginDocument}.}
1000 % \changes{v2.03}{2019/07/04}{Added support for \pkg{memoir}.}
1001 % \begin{macrocode}
1002 \AtBeginDocument{
1003 \@ifclassloaded{memoir}
1004 {
1005 \appto{\cftpartleader}{\TD@usetocdata}
1006 \appto{\cftchapterleader}{\TD@usetocdata}
1007 \appto{\cftsectionleader}{\TD@usetocdata}
1008 \appto{\cftsubsectionleader}{\TD@usetocdata}
1009 \appto{\cftsubsubsectionleader}{\TD@usetocdata}
1010 \appto{\cftparagraphleader}{\TD@usetocdata}
1011 \appto{\cftsubparagraphleader}{\TD@usetocdata}
1012 \appto{\cftfigureleader}{\TD@usetocdata}
1013 \appto{\cfttableleader}{\TD@usetocdata}
1014 \appto{\cftsubfigureleader}{\TD@usetocdata}
1015 \appto{\cftsubtableleader}{\TD@usetocdata}
1016 }% memoir
1017 {% not memoir
1018 \@ifpackageloaded{tocloft}
1019 {
1020 % \end{macrocode}
1021 %
1022 % \DescribeMacro{\cftXleader} A set of commands used by \cs{tocloft} to
1023 % typeset the leader between the title and the page number.
1024 % These are patched to print the tocdata just after the leader.
1025 %
1026 % \changes{v2.00}{2019/03/13}{Improved patches for \pkg{tocloft}.}
1027 % \begin{macrocode}
1028 \appto{\cftpartleader}{\TD@usetocdata}
1029 \if@cfthaschapter
1030 \appto{\cftchapleader}{\TD@usetocdata}
1031 \fi
1032 \appto{\cftsecleader}{\TD@usetocdata}
1033 \appto{\cftsubsecleader}{\TD@usetocdata}
1034 \appto{\cftsubsubsecleader}{\TD@usetocdata}
1035 \appto{\cftparaleader}{\TD@usetocdata}
1036 \appto{\cftsubparaleader}{\TD@usetocdata}
1037 \appto{\cftfigleader}{\TD@usetocdata}
1038 \appto{\cfttableader}{\TD@usetocdata}
1039 \appto{\cftsubfigleader}{\TD@usetocdata}
1040 \appto{\cftsubtableader}{\TD@usetocdata}
1041 % \end{macrocode}
1042
1043 % \begin{macrocode}
1044 }% end of tocloft patches
1045 {}% tocloft not loaded
1046 }% not memoir
1047 }% \AtBeginDocument
1048 % \end{macrocode}
1049 %
1050 %
1051 %
1052 % \subsection{Koma-script \pkg{tocbasic} support}
1053 %
1054 % There is no easy way to patch this\dots
1055 % \cs{TD@usetocdata} is inserted near the end of the following:
1056 %
1057 % \changes{v2.03}{2019/07/06}{Added support for \pkg{tocbasic}.}
1058 % \changes{v2.04}{2020/07/15}{Updated for \pkg{tocbasic} v3.30.}
1059 %
1060 % \begin{macrocode}
1061 \AtBeginDocument{
1062
1063 \@ifpackageloaded{tocbasic}{
1064 \xpatchcmd{\scr@dte@tocline}
1065 {%
1066 \nobreak
1067 \expandafter\let\expandafter\scr@dte@pagenumberwidth
1068 }
1069 {%
1070 \TD@usetocdata% tocdata
1071 \nobreak
1072 \expandafter\let\expandafter\scr@dte@pagenumberwidth
1073 }
1074 {}
1075 {%
1076 \PackageWarningNoLine{tocdata}{%
1077 Could not patch tocbasic \protect\scr@dte@tocline.\MessageBreak
1078 Authors may not appear in TOC, LOF}
1079 }
1080 }{}
1081 }
1082 % \end{macrocode}
1083 %
1084 %
1085 % \subsection{\pkg{tocstyle} support}
1086 %
1087 % \changes{v2.03}{2019/07/06}{Added support for \pkg{tocstyle}.}
1088 %
1089 % \begin{macrocode}
1090 \AtBeginDocument{
1091 \@ifpackageloaded{tocstyle}{
1092 \xpatchcmd\tocstyle@dottedtocline
1093 {%
1094 \ifx\tocstyle@feature@leaders\relax
1095 \leaders\hbox{$\m@th
1096 \mkern \@dotsep mu\hbox{\tocstyle@feature@dothook .}%
1097 \mkern \@dotsep mu$}\hfill
1098 \else
1099 \tocstyle@feature@leaders
1100 \fi%
1101 }
1102 {%
1103 \ifx\tocstyle@feature@leaders\relax
1104 \leaders\hbox{$\m@th
1105 \mkern \@dotsep mu\hbox{\tocstyle@feature@dothook .}%
1106 \mkern \@dotsep mu$}\hfill
1107 \else
1108 \tocstyle@feature@leaders
1109 \fi%
1110 \TD@usetocdata%
1111 }
1112 {}%
1113 {%
1114 \PackageWarningNoLine{tocdata}{%
1115 Could not patch tocstyle \protect\tocstyle@dottedtocline.\MessageBreak
1116 Authors may not appear in TOC, LOF}
1117 }%
1118 }{}
1119 }
1120 % \end{macrocode}
1121 %
1122 %
1123 %
1124 % \clearpage
1125 %
1126 % \subsection{User-level macros}
1127 % \label{sec:usermacros}
1128 %
1129 % \begin{figure}
1130 % \centering
1131 % \includegraphics[width=3in]{newton_astrolabe.jpg}
1132 % \captionartist{Sir Isaac Newton's Astrolabe}[][Sir]{Isaac}{Newton}
1133 % \end{figure}
1134 %
1135 %
1136 % Example user-level macros follow.
1137 %
1138 % These macros are in addition to the standard sectioning and caption commands,
1139 % adding first and last names for the table of contents and list of figures.
1140 % For parts, chapters, sections, and subsections,
1141 % the author's name with optional prefix and suffix
1142 % are also added below the title.
1143 % For figures, \cs{captionauthor} also prints the figure's artist's
1144 % name with optional prefix and suffix just below the figure.
1145 %
1146 % The regular sectioning and caption commands may still be used for anything
1147 % which does not have an author/artist name.
1148 %
1149 %
1150 % \subsubsection{User customization}
1151 %
1152 %
1153 % \begin{macro}{\TDoptionalnameprint} \marg{name}
1154 %
1155 % Adds optional artist's name and the following space.
1156 %
1157 % \changes{v2.03}{2019/07/04}{Name changed from \cs{TD@optionalnameprint}.}
1158 % \begin{macrocode}
1159 \newcommand{\TDoptionalnameprint}[1]
1160 {%
1161 \ifblank{#1}%
1162 {}%
1163 {#1~}%
1164 }
1165 % \end{macrocode}
1166 % \end{macro}
1167 %
1168 %
1169 %
1170 %
1171 % \begin{macro}{\tocdatapartprint} \marg{prefix} \marg{first} \marg{last} \marg{suffix}
1172 %
1173 % User-redefinable macro to print the author's name underneath the part title.
1174 %
1175 % \changes{v0.12}{2016/11/29}{Improved spacing.}
1176 % \changes{v2.00}{2019/03/15}{Added.}
1177 % \changes{v2.03}{2019/07/04}{Removed \cs{unskip}.}
1178 %
1179 % \begin{macrocode}
1180 \newcommand{\tocdatapartprint}[4]
1181 {%
1182 \par\noindent%
1183 {%
1184 \normalfont\normalsize%
1185 \textit{%
1186 \hspace*{4em}--- %
1187 \TDoptionalnameprint{#1}\TDoptionalnameprint{#2}#3#4%
1188 }%
1189 }%
1190 }
1191 % \end{macrocode}
1192 % \end{macro}
1193 %
1194 %
1195 % \begin{macro}{\tocdatachapterprint} \marg{prefix} \marg{first} \marg{last} \marg{suffix}
1196 %
1197 % User-redefinable macro to print the author's name underneath the chapter title.
1198 %
1199 % \changes{v2.00}{2019/03/15}{Renamed from \cs{tocdatachapprint}.}
1200 %
1201 % \begin{macrocode}
1202 \@ifundefined{chapter}
1203 {}% if no chapters
1204 {% only of chapters exists in this documentclass:
1205 \let\tocdatachapterprint\tocdatapartprint
1206 }% end of chapters-only
1207 % \end{macrocode}
1208 % \end{macro}
1209 %
1210 %
1211 % \begin{macro}{\tocdatasectionprint} \marg{prefix} \marg{first} \marg{last} \marg{suffix}
1212 %
1213 % User-redefinable macro to print the author's name underneath the section title.
1214 %
1215 % \changes{v2.00}{2019/03/15}{Renamed from \cs{tocdatasecprint}.}
1216 %
1217 % \begin{macrocode}
1218 \let\tocdatasectionprint\tocdatapartprint
1219 % \end{macrocode}
1220 % \end{macro}
1221 %
1222 %
1223 % \begin{macro}{\tocdatasubsectionprint} \marg{prefix} \marg{first} \marg{last} \marg{suffix}
1224 %
1225 % User-redefinable macro to print the author's name underneath the subsection title.
1226 %
1227 % \changes{v2.00}{2019/03/15}{Added.}
1228 % \begin{macrocode}
1229 \let\tocdatasubsectionprint\tocdatapartprint
1230 % \end{macrocode}
1231 % \end{macro}
1232 %
1233 %
1234 % \begin{macro}{\TDartistauthorprint} \marg{1: "artist" or "author"}
1235 % \marg{2: prefix} \marg{3: first} \marg{4: last} \marg{5: suffix}
1236 %
1237 % \changes{v2.00}{2019/03/15}{Improved font control.}
1238 % \changes{v2.03}{2019/07/04}{Name changed from \cs{TD@artistauthorprint}.}
1239 %
1240 % \begin{macrocode}
1241 \newcommand{\TDartistauthorprint}[5]{%
1242 \begin{minipage}{\linewidth}%
1243 \csuse{TD@#1align}%
1244 \footnotesize\normalfont%
1245 \textsc{{\TDoptionalnameprint{#2}\TDoptionalnameprint{#3}#4#5}}%
1246 \end{minipage}%
1247 \par%
1248 \addvspace{2ex}%
1249 }
1250 % \end{macrocode}
1251 % \end{macro}
1252 %
1253 %
1254 % \begin{macro}{\tocdataartistprint} \marg{prefix} \marg{first} \marg{last} \marg{suffix}
1255 %
1256 % User-redefinable macro to print the artist's name underneath the figure.
1257 %
1258 % \changes{v0.12}{2016/11/29}{Improved spacing.}
1259 % \changes{v0.12}{2016/11/30}{Added name alignment.}
1260 % \changes{v2.00}{2019/03/14}{Added.}
1261 % \changes{v2.02}{2019/03/20}{Improved spacing.}
1262 %
1263 % \begin{macrocode}
1264 \newcommand{\tocdataartistprint}{%
1265 \par\smallskip%
1266 \TDartistauthorprint{artist}%
1267 }
1268 % \end{macrocode}
1269 % To remove the artist's name, redefine this as a null function taking four arguments:
1270 % \begin{sourceverb}
1271 % \renewcommand{\tocdataartistprint}[4]{}
1272 % \end{sourceverb}
1273 % \end{macro}
1274 %
1275 %
1276 % \begin{macro}{\tocdataauthorprint} \marg{prefix} \marg{first} \marg{last} \marg{suffix}
1277 %
1278 % User-redefinable macro to print the author's name underneath the figure.
1279 %
1280 % \changes{v2.00}{2019/03/14}{Added.}
1281 % \changes{v2.02}{2019/03/20}{Improved spacing.}
1282 %
1283 % \begin{macrocode}
1284 \newcommand{\tocdataauthorprint}{%
1285 \par\smallskip%
1286 \TDartistauthorprint{author}%
1287 }
1288 % \end{macrocode}
1289 % \end{macro}
1290 %
1291 %
1292 %
1293 % \begin{macro}{\TDartistauthortextprint}
1294 % \marg{"artist" or "author"} \marg{text}
1295 % \changes{v0.12}{2016/11/29}{Improved spacing.}
1296 % \changes{v0.12}{2016/11/29}{Added text alignment.}
1297 % \changes{v2.00}{2019/03/15}{Improved font control.}
1298 % \changes{v2.00}{2019/03/14}{Replaced \cs{tocdatafigtextprint} with
1299 % \cs{tocdataartisttextprint} and \cs{tocdataauthortextprint}.}
1300 % \changes{v2.03}{2019/07/04}{Name changed from \cs{TD@artistauthortextprint}.}
1301 % \begin{macrocode}
1302 \newcommand{\TDartistauthortextprint}[2]{%
1303 \addvspace{2ex}%
1304 \begin{minipage}{\linewidth}%
1305 \csuse{TD@#1textalign}%
1306 \footnotesize\normalfont%
1307 \setlength{\parskip}{1.5ex}%
1308 \setlength{\parindent}{0em}%
1309 #2%
1310 \end{minipage}%
1311 \par%
1312 \addvspace{2ex}%
1313 }
1314 % \end{macrocode}
1315 % \end{macro}
1316 %
1317 %
1318 % \begin{macro}{\tocdataartisttextprint} \marg{text}
1319 %
1320 % User-redefinable macro to print the optional text below the artist's name.
1321 %
1322 %
1323 % \begin{macrocode}
1324 \newcommand{\tocdataartisttextprint}{\TDartistauthortextprint{artist}}
1325 % \end{macrocode}
1326 % \end{macro}
1327 %
1328 % \begin{macro}{\tocdataauthortextprint} \marg{text}
1329 %
1330 % User-redefinable macro to print the optional text below the author's name.
1331 %
1332 % \begin{macrocode}
1333 \newcommand{\tocdataauthortextprint}{\TDartistauthortextprint{author}}
1334 % \end{macrocode}
1335 % \end{macro}
1336 %
1337 %
1338 %
1339 % \subsubsection{Chapters and sections}
1340 %
1341 %
1342 % With \pkg{book} or \pkg{report} classes,
1343 % a starred \cs{part}'s name is printed on its own page,
1344 % \watchout[\cs{part*}]
1345 % making it difficult to add an author's name. If the author's name
1346 % is appended to the part's name, it also appears in name references as well.
1347 % Thus, if using one of these classes and a starred \cs{part}, the author's name is not
1348 % printed.
1349 % Using an unstarred \cs{part} with an author's name does work as expected.
1350 % The author's name is printed as part of the long name,
1351 % but does not appear in the name reference, which uses the short name.
1352 %
1353 % \begin{macro}{\TD@starredsectionauthorprint} \marg{author's name}
1354 % \changes{v2.03}{2019/07/04}{No author for \cs{part*} in \pkg{book} class.}
1355 % \begin{macrocode}
1356 \@ifclassloaded{article}
1357 {
1358 \newcommand*{\TD@starredsectionauthorprint}[5]{%
1359 \unskip\medskip\csuse{tocdata#1print}{#2}{#3}{#4}{#5}\par%
1360 \bigskip%
1361 }
1362 }
1363 {
1364 \newcommand*{\TD@starredsectionauthorprint}[5]{%
1365 \ifstrequal{#1}{part}%
1366 {%
1367 \PackageWarning{tocdata}{%
1368 The author's name will not be printed for\MessageBreak
1369 the starred \protect\part%
1370 }
1371 }%
1372 {%
1373 \unskip\medskip\csuse{tocdata#1print}{#2}{#3}{#4}{#5}\par%
1374 \bigskip%
1375 }%
1376 }
1377 }
1378 % \end{macrocode}
1379 % \end{macro}
1380 %
1381 %
1382 % \begin{macro}{\TD@sectionauthor}
1383 % \marg{1: section type}
1384 % *
1385 % \oarg{3: \TOC\ entry} \marg{4: title}
1386 % \oarg{5: prefix} \marg{6: first} \marg{7: last} \oarg{8: suffix}
1387 %
1388 % \changes{v0.12}{2016/11/28}{Expands first name before index check.}
1389 % \changes{v2.00}{2019/03/15}{Improved page breaks.}
1390 % \changes{v2.00}{2019/03/15}{Factored.}
1391 % \changes{v2.02}{2019/03/21}{Fix: Sectioning name formatting.}
1392 % \changes{v2.03}{2019/06/30}{Fix: Starred sectioning name formatting and labels.}
1393 % \begin{macrocode}
1394 \NewDocumentCommand{\TD@sectionauthor}{m s o m O{} m m O{}}{%
1395 % \end{macrocode}
1396 % The starred version does not create a \acro{TOC} entry,
1397 % so it is simply used as-is:
1398 % \begin{macrocode}
1399 \IfBooleanTF{#2}%
1400 {% star:
1401 \csuse{#1}*{#4}%
1402 \TD@starredsectionauthorprint{#1}{#5}{#6}{#7}{#8}%
1403 }%
1404 % \end{macrocode}
1405 % The un-starred version appears in the \acro{TOC}, so add the author's name:
1406 % \begin{macrocode}
1407 {% no star:
1408 \tocdata{toc}{#6 #7}%
1409 % \end{macrocode}
1410 % Create the section depending on the optional name:
1411 % \begin{macrocode}
1412 \IfValueTF{#3}%
1413 {\csuse{#1}[#3]{#4\nopagebreak\csuse{tocdata#1print}{#5}{#6}{#7}{#8}}}%
1414 {\csuse{#1}[#4]{#4\nopagebreak\csuse{tocdata#1print}{#5}{#6}{#7}{#8}}}%
1415 }% no star
1416 % \end{macrocode}
1417 % Create an index entry depending on whether there is a first name:
1418 % \begin{macrocode}
1419 \ifblank{#6}%
1420 {\index{#7}}%
1421 {\index{#7, #6}}%
1422 }
1423 % \end{macrocode}
1424 % \end{macro}
1425 %
1426 %
1427 % \begin{macro}{\partauthor} * \oarg{2: \TOC\ entry} \marg{3: title}
1428 % \oarg{4: prefix} \marg{5: first} \marg{6: last} \oarg{7: suffix}
1429 %
1430 % \changes{v2.00}{2019/03/15}{Added.}
1431 %
1432 % \begin{macrocode}
1433 \newcommand*{\partauthor}{\TD@sectionauthor{part}}
1434 % \end{macrocode}
1435 % \end{macro}
1436 %
1437 %
1438 % \begin{macro}{\chapterauthor} * \oarg{2: \TOC\ entry} \marg{3: title}
1439 % \oarg{4: prefix} \marg{5: first} \marg{6: last} \oarg{7: suffix}
1440 %
1441 % \begin{macrocode}
1442 \@ifundefined{chapter}
1443 {}% if no chapters
1444 {% only of chapters exists in this documentclass:
1445 \newcommand*{\chapterauthor}{\TD@sectionauthor{chapter}}
1446 }
1447 % \end{macrocode}
1448 % \end{macro}
1449 %
1450 %
1451 % \begin{macro}{\sectionauthor} * \oarg{2: \TOC\ entry} \marg{3: title}
1452 % \oarg{4: prefix} \marg{5: first} \marg{6: last} \oarg{7: suffix}
1453 %
1454 % \begin{macrocode}
1455 \newcommand*{\sectionauthor}{\TD@sectionauthor{section}}
1456 % \end{macrocode}
1457 % \end{macro}
1458 %
1459 %
1460 % \begin{macro}{\subsectionauthor} * \oarg{2: \TOC\ entry} \marg{3: title}
1461 % \oarg{4: prefix} \marg{5: first} \marg{6: last} \oarg{7: suffix}
1462 %
1463 % \changes{v2.00}{2019/03/15}{Added.}
1464 %
1465 % \begin{macrocode}
1466 \newcommand*{\subsectionauthor}{\TD@sectionauthor{subsection}}
1467 % \end{macrocode}
1468 % \end{macro}
1469 %
1470 %
1471 %
1472 % \subsubsection{Figure artist name alignment}
1473 %
1474 % \changes{v2.00}{2019/03/14}{Replaced \cs{tdnameX} with
1475 % \cs{tdauthorX} and \cs{tdartistX}.}
1476 %
1477 % \begin{macro}{\TD@artistalign} Sets text alignment for the artist's name.
1478 % \begin{macrocode}
1479 \newcommand{\TD@artistalign}{\centering}
1480 % \end{macrocode}
1481 % \end{macro}
1482 %
1483 % \begin{macro}{\tdartistjustify} Sets justified text alignment for the artist's name.
1484 % \changes{v0.12}{2016/11/30}{etc. Added name alignment.}
1485 % \begin{macrocode}
1486 \newcommand{\tdartistjustify}{%
1487 \renewcommand{\TD@artistalign}{}%
1488 }
1489 % \end{macrocode}
1490 % \end{macro}
1491 %
1492 % \begin{macro}{\tdartistcenter} Sets centered text alignment for the artist's name.
1493 % \begin{macrocode}
1494 \newcommand{\tdartistcenter}{%
1495 \renewcommand{\TD@artistalign}{\centering}%
1496 }
1497 % \end{macrocode}
1498 % \end{macro}
1499 %
1500 % \begin{macro}{\tdartistleft} Sets left text alignment for the artist's name.
1501 % \begin{macrocode}
1502 \newcommand{\tdartistleft}{%
1503 \renewcommand{\TD@artistalign}{\raggedright}%
1504 }
1505 % \end{macrocode}
1506 % \end{macro}
1507 %
1508 % \begin{macro}{\tdartistright} Sets right text alignment for the artist's name.
1509 % \begin{macrocode}
1510 \newcommand{\tdartistright}{%
1511 \renewcommand{\TD@artistalign}{\raggedleft}%
1512 }
1513 % \end{macrocode}
1514 % \end{macro}
1515 %
1516 %
1517 % \subsubsection{Figure author name alignment}
1518 %
1519 % \begin{macro}{\TD@authoralign} Sets text alignment for the author's name.
1520 % \begin{macrocode}
1521 \newcommand{\TD@authoralign}{\raggedleft}
1522 % \end{macrocode}
1523 % \end{macro}
1524 %
1525 % \begin{macro}{\tdauthorjustify} Sets justified text alignment for the author's name.
1526 % \changes{v0.12}{2016/11/30}{etc. Added name alignment.}
1527 % \begin{macrocode}
1528 \newcommand{\tdauthorjustify}{%
1529 \renewcommand{\TD@authoralign}{}%
1530 }
1531 % \end{macrocode}
1532 % \end{macro}
1533 %
1534 % \begin{macro}{\tdauthorcenter} Sets centered text alignment for the author's name.
1535 % \begin{macrocode}
1536 \newcommand{\tdauthorcenter}{%
1537 \renewcommand{\TD@authoralign}{\centering}%
1538 }
1539 % \end{macrocode}
1540 % \end{macro}
1541 %
1542 % \begin{macro}{\tdauthorleft} Sets left text alignment for the author's name.
1543 % \begin{macrocode}
1544 \newcommand{\tdauthorleft}{%
1545 \renewcommand{\TD@authoralign}{\raggedright}%
1546 }
1547 % \end{macrocode}
1548 % \end{macro}
1549 %
1550 % \begin{macro}{\tdauthorright} Sets right text alignment for the author's name.
1551 % \begin{macrocode}
1552 \newcommand{\tdauthorright}{%
1553 \renewcommand{\TD@authoralign}{\raggedleft}%
1554 }
1555 % \end{macrocode}
1556 % \end{macro}
1557 %
1558 %
1559 % \subsubsection{Figure artist text alignment}
1560 %
1561 % \begin{macro}{\TD@artisttextalign} Sets text alignment in the optional text.
1562 % \begin{macrocode}
1563 \newcommand{\TD@artisttextalign}{\centering}
1564 % \end{macrocode}
1565 % \end{macro}
1566 %
1567 % \begin{macro}{\tdartisttextjustify} Sets justified text alignment in the optional text.
1568 % \changes{v0.12}{2016/11/30}{etc. Added text alignment.}
1569 % \begin{macrocode}
1570 \newcommand{\tdartisttextjustify}{%
1571 \renewcommand{\TD@artisttextalign}{}%
1572 }
1573 % \end{macrocode}
1574 % \end{macro}
1575 %
1576 % \begin{macro}{\tdartisttextcenter} Sets centered text alignment in the optional text.
1577 % \begin{macrocode}
1578 \newcommand{\tdartisttextcenter}{%
1579 \renewcommand{\TD@artisttextalign}{\centering}%
1580 }
1581 % \end{macrocode}
1582 % \end{macro}
1583 %
1584 % \begin{macro}{\tdartisttextleft} Sets left text alignment in the optional text.
1585 % \begin{macrocode}
1586 \newcommand{\tdartisttextleft}{%
1587 \renewcommand{\TD@artisttextalign}{\raggedright}%
1588 }
1589 % \end{macrocode}
1590 % \end{macro}
1591 %
1592 % \begin{macro}{\tdartisttextright} Sets right text alignment in the optional text.
1593 % \begin{macrocode}
1594 \newcommand{\tdartisttextright}{%
1595 \renewcommand{\TD@artisttextalign}{\raggedleft}%
1596 }
1597 % \end{macrocode}
1598 % \end{macro}
1599 %
1600 %
1601 % \subsubsection{Figure author text alignment}
1602 %
1603 % \begin{macro}{\TD@authortextalign} Sets text alignment in the optional text.
1604 % \begin{macrocode}
1605 \newcommand{\TD@authortextalign}{\centering}
1606 % \end{macrocode}
1607 % \end{macro}
1608 %
1609 % \begin{macro}{\tdauthortextjustify} Sets justified text alignment in the optional text.
1610 % \changes{v0.12}{2016/11/30}{etc. Added text alignment.}
1611 % \begin{macrocode}
1612 \newcommand{\tdauthortextjustify}{%
1613 \renewcommand{\TD@authortextalign}{}%
1614 }
1615 % \end{macrocode}
1616 % \end{macro}
1617 %
1618 % \begin{macro}{\tdauthortextcenter} Sets centered text alignment in the optional text.
1619 % \begin{macrocode}
1620 \newcommand{\tdauthortextcenter}{%
1621 \renewcommand{\TD@authortextalign}{\centering}%
1622 }
1623 % \end{macrocode}
1624 % \end{macro}
1625 %
1626 % \begin{macro}{\tdauthortextleft} Sets left text alignment in the optional text.
1627 % \begin{macrocode}
1628 \newcommand{\tdauthortextleft}{%
1629 \renewcommand{\TD@authortextalign}{\raggedright}%
1630 }
1631 % \end{macrocode}
1632 % \end{macro}
1633 %
1634 % \begin{macro}{\tdauthortextright} Sets right text alignment in the optional text.
1635 % \begin{macrocode}
1636 \newcommand{\tdauthortextright}{%
1637 \renewcommand{\TD@authortextalign}{\raggedleft}%
1638 }
1639 % \end{macrocode}
1640 % \end{macro}
1641 %
1642 %
1643 %
1644 % \subsubsection{Figure captions with artists and authors}
1645 %
1646 % These macros adds optional supplemental text, which will be printed below the
1647 % artist's name and above the caption, presuming that the caption is generated
1648 % below the figure.
1649 %
1650 % If using the optional prefix, the optional text must also be given, even if it
1651 % \watchout[Optional arguments]
1652 % is empty. For example, use:
1653 % \begin{sourcedisplay}
1654 % \cs{captionartist}\{Title\}\textcolor{red}{[]}[Sir]\{Isaac\}\{Newton\}
1655 % \end{sourcedisplay}
1656 % If only one optional argument is given before the first name, it will be
1657 % interpreted as the optional text, not as the optional prefix.
1658 %
1659 %
1660 % \begin{macro}{\TD@captionartistauthor}
1661 % \marg{1: "artist" or "author"}
1662 % *
1663 % \oarg{3: \LOF\ entry} \marg{4: title}
1664 % \oarg{5: supplemental text} \\
1665 % \oarg{6: prefix} \marg{7: first} \marg{8: last} \oarg{9: suffix}
1666 %
1667 % Factored from \cs{captionartist} and \cs{captionauthor}, below.
1668 %
1669 % \changes{v0.12}{2016/11/28}{Allows paragraphs in add'l text.}
1670 % \changes{v0.12}{2016/11/28}{Expands first name before index check.}
1671 % \changes{v2.00}{2019/03/15}{Factored.}
1672 %
1673 % \begin{macrocode}
1674 \NewDocumentCommand{\TD@captionartistauthor}{m s o m +O{} O{} m m O{}}{%
1675 % \end{macrocode}
1676 %
1677 % Print the artist's name next to the figure:
1678 % \begin{macrocode}
1679 \csuse{tocdata#1print}{#6}{#7}{#8}{#9}%
1680 % \end{macrocode}
1681 % If supplemental text is provided, print it below the author:
1682 % \begin{macrocode}
1683 \ifblank{#5}%
1684 {}%
1685 {\par\csuse{tocdata#1textprint}{#5}}%
1686 % \end{macrocode}
1687 % Remove any existing vertical space and only use \cs{caption}'s built-in spacing:
1688 % \begin{macrocode}
1689 \unskip%
1690 % \end{macrocode}
1691 % If starred, there should be no \acro{TOC} entry, so do not add tocdata.
1692 % Use \cs{caption*} from the \pkg{caption} or similar packages.
1693 % \begin{macrocode}
1694 \IfBooleanTF{#2}%
1695 {% starred
1696 \IfValueTF{#3}{\caption*[#3]{#4}}{\caption*{#4}}%
1697 }% starred
1698 {% not starred
1699 % \end{macrocode}
1700 % No starred, so remember the artist's name for inclusion in the \acro{LOF}:
1701 % \changes{v2.00}{2019/03/14}{Added support for new float types.}
1702 % \begin{macrocode}
1703 \tocdata{\csuse{ext@\@captype}}{#7 #8}%
1704 % \end{macrocode}
1705 % Create the caption depending on the optional name:
1706 % \begin{macrocode}
1707 \IfValueTF{#3}{\caption[#3]{#4}}{\caption{#4}}%
1708 }% not starred
1709 % \end{macrocode}
1710 % Create an index entry depending on whether there is a first name:
1711 % \begin{macrocode}
1712 \ifblank{#7}%
1713 {\index{#8}}%
1714 {\index{#8, #7}}%
1715 }
1716 % \end{macrocode}
1717 % \end{macro}
1718 %
1719 %
1720 % \begin{macro}{\captionartist} * \oarg{2: \LOF\ entry} \marg{3: title}
1721 % \oarg{4: supplemental text}
1722 % \oarg{5: prefix} \marg{6: first} \\
1723 % \marg{7: last} \oarg{8: suffix}
1724 %
1725 % \begin{macrocode}
1726 \newcommand*{\captionartist}{\TD@captionartistauthor{artist}}
1727 % \end{macrocode}
1728 % \end{macro}
1729 %
1730 % \begin{macro}{\captionauthor} * \oarg{2: \LOF\ entry} \marg{3: title}
1731 % \oarg{4: supplemental text}
1732 % \oarg{5: prefix} \marg{6: first} \\
1733 % \marg{7: last} \oarg{8: suffix}
1734 %
1735 % \begin{macrocode}
1736 \newcommand*{\captionauthor}{\TD@captionartistauthor{author}}
1737 % \end{macrocode}
1738 % \end{macro}
1739 %
1740 %
1741 % \begin{illustration}
1742 % \setlength{\fboxsep}{0pt}
1743 % \centering
1744 % \fbox{\includegraphics[width=4in]{lacquer_go_board.jpg}}
1745 % \captionartist{Lacquer Go Board}[From the series \textit{Uma Zukushi}.]{Katsushika}{Hokusai}
1746 % \end{illustration}
1747 %
1748 %
1749 %
1750 %
1751 %
1752 %
1753 % ^^A At end:
1754 %
1755 % \clearpage
1756 % ^^A \pagestyle{plain}
1757 %
1758 % \pagestyle{plain}
1759 %
1760 % \Finale
1761 \endinput