From 6e5c7721efd8538de71d9c13e23ba3cc7683c789 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Fri, 15 Mar 2019 21:16:31 +0000 Subject: tocdata (15mar19) git-svn-id: svn://tug.org/texlive/trunk@50403 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/latex/tocdata/tocdata.sty | 319 +++++++++++++++--------- 1 file changed, 207 insertions(+), 112 deletions(-) (limited to 'Master/texmf-dist/tex/latex/tocdata') diff --git a/Master/texmf-dist/tex/latex/tocdata/tocdata.sty b/Master/texmf-dist/tex/latex/tocdata/tocdata.sty index 64c2fa95129..6bc4e76600a 100644 --- a/Master/texmf-dist/tex/latex/tocdata/tocdata.sty +++ b/Master/texmf-dist/tex/latex/tocdata/tocdata.sty @@ -17,27 +17,46 @@ %% version 2005/12/01 or later. \NeedsTeXFormat{LaTeX2e}[1999/12/01] \ProvidesPackage{tocdata} - [2019/01/12 v1.00 Adds author/artist to TOC entries.] - + [2019/03/15 v2.00 Adds author/artist to TOC entries.] \RequirePackage{xparse} \RequirePackage{etoolbox} +\RequirePackage{xpatch} + +\@ifpackageloaded{titletoc}{ + \PackageError{tocdata} + {% + Load titletoc after tocdata% + } + {% + Move \protect\usepackage{titletoc} after \protect\usepackage{tocdata}.% + } +}{} +\@ifpackageloaded{tocloft}{ + \PackageError{tocdata} + {% + Load tocloft after tocdata% + } + {% + Move \protect\usepackage{tocloft} after \protect\usepackage{tocdata}.% + } +}{} +\AtBeginDocument{ \@ifpackageloaded{titletoc}{ \@ifpackageloaded{tocloft}{ \PackageError{tocdata} - {Both titletoc and tocloft are being used. Load only one} - {The tocdata package requires either one of titletoc or tocloft.} - }{} -}{% Not titletoc. - \@ifpackageloaded{tocloft}{}{ - \PackageError{tocdata} - { - The tocdata package requires either the tocloft or titletoc package% + {% + Both titletoc and tocloft are being used.\MessageBreak + Load only one% + } + {% + The tocdata package may use the default LaTeX formatting,\MessageBreak + or either one of titletoc or tocloft. } - {Load either, then load tocdata next.} - } + }{} +}{} } \newcommand{\TD@thistocdata}{} @@ -53,164 +72,240 @@ \global\def\TD@thistocdata{}% } -\@ifpackageloaded{titletoc}{ +\xpatchcmd{\@dottedtocline} + {\hfill\nobreak} + {\hfill\TD@usetocdata\nobreak} + {}% + {% + \PackageWarningNoLine{tocdata}{% + Could not patch LaTeX core \protect\@dottedtocline.\MessageBreak + Authors will not appear in TOC, LOF} + }% + +\xpatchcmd{\l@part} + {\hfil} + {\hfil\TD@usetocdata} + {}% + {% + \PackageWarningNoLine{tocdata}{% + Could not patch LaTeX core \protect\l@part.\MessageBreak + Authors will not appear in TOC parts} + }% \@ifundefined{chapter} {} { -\titlecontents{chapter}[0em]{}{\contentslabel{2.5em}}{}{% -\titlerule*[.75pc]{.}% -\TD@usetocdata% <-- newly added for the tocdata package -\contentspage}[\vspace{-.5ex}]% -} -\titlecontents{section}[2.5em]{}{\contentslabel{2.5em}}{}{% -\titlerule*[.75pc]{.}% -\TD@usetocdata% -\contentspage}[\vspace{-.5ex}]% -\titlecontents{figure}[0em]{}{\contentslabel{3em}}{}{% -\titlerule*[1pc]{.}% -\TD@usetocdata% -\contentspage}[\vspace{-.5ex}]% +\xpatchcmd{\l@chapter} + {\hfil\nobreak} + {\hfil\TD@usetocdata\nobreak} + {}% + {% + \PackageWarningNoLine{tocdata}{% + Could not patch LaTeX core \protect\l@chapter.\MessageBreak + Authors will not appear in TOC chapters} + }% +} +\AtBeginDocument{ +\@ifpackageloaded{titletoc}{ + +\newcommand*{\TD@titletoc@patch}[1]{% + \expandafter\xpatchcmd\csname ttl@savel@#1\endcsname + {\nobreak\hfil\nobreak} + {\nobreak\hfil\TD@usetocdata\nobreak} + {} + {} + \expandafter\xpatchcmd\csname l@#1\endcsname + {\contentspage} + {\TD@usetocdata\contentspage} + {} + {} +} + +\TD@titletoc@patch{part} +\@ifundefined{chapter}{}{\TD@titletoc@patch{chapter}} +\TD@titletoc@patch{section} +\TD@titletoc@patch{subsection} +\TD@titletoc@patch{subsubsection} +\TD@titletoc@patch{paragraph} +\TD@titletoc@patch{subparagraph} +\TD@titletoc@patch{figure} +\TD@titletoc@patch{table} }% end of titletoc loaded {% titletoc is not loaded }% end of \@ifpackageloaded{titletoc} +}% end of \AtBeginDocument +\AtBeginDocument{ \@ifpackageloaded{tocloft} { +\appto{\cftpartleader}{\TD@usetocdata} \if@cfthaschapter -\renewcommand{\cftchapleader}{\bfseries\cftdotfill{\cftchapdotsep}\TD@usetocdata} -\renewcommand{\cftsecleader}{\normalfont\cftdotfill{\cftsecdotsep}\TD@usetocdata} -\renewcommand{\cftfigleader}{\normalfont\cftdotfill{\cftfigdotsep}\TD@usetocdata} -\else -\renewcommand{\cftsecleader}{\bfseries\cftdotfill{\cftsecdotsep}\TD@usetocdata} -\renewcommand{\cftfigleader}{\normalfont\cftdotfill{\cftfigdotsep}\TD@usetocdata} + \appto{\cftchapleader}{\TD@usetocdata} \fi +\appto{\cftsecleader}{\TD@usetocdata} +\appto{\cftsubsecleader}{\TD@usetocdata} +\appto{\cftsubsubsecleader}{\TD@usetocdata} +\appto{\cftparaleader}{\TD@usetocdata} +\appto{\cftsubparaleader}{\TD@usetocdata} +\appto{\cftfigleader}{\TD@usetocdata} +\appto{\cfttableader}{\TD@usetocdata} +\appto{\cftsubfigleader}{\TD@usetocdata} +\appto{\cftsubtableader}{\TD@usetocdata} + }% end of tocloft patches {}% tocloft not loaded - +}% \AtBeginDocument \newcommand{\TD@optionalname}[1] {% \ifblank{#1}% {}% {#1~}% } +\newcommand{\tocdatapartprint}[4] +{% + \par\unskip\noindent% + {% + \normalfont\normalsize% + \textit{% + \hspace*{4em}--- % + \TD@optionalname{#1}\TD@optionalname{#2}#3#4% + }% + }% +} \@ifundefined{chapter} {}% if no chapters {% only of chapters exists in this documentclass: -\newcommand{\tocdatachapprint}[4] -{% - \newline\noindent{\normalfont\normalsize\textit{\hspace*{2em}--- % - \TD@optionalname{#1}\TD@optionalname{#2}#3#4}}% -} + \let\tocdatachapterprint\tocdatapartprint }% end of chapters-only -\newcommand{\tocdatasecprint}[4] -{% - \newline\noindent{\normalfont\normalsize\textit{\hspace*{2em}--- % - \TD@optionalname{#1}\TD@optionalname{#2}#3#4}% -}% -} -\newcommand{\tocdatafigprint}[4]{% - \addvspace{2ex}% +\let\tocdatasectionprint\tocdatapartprint +\let\tocdatasubsectionprint\tocdatapartprint +\newcommand{\TD@artistauthorprint}[5]{% \begin{minipage}{\linewidth}% - \TD@namealign% - \footnotesize\textsc{{\TD@optionalname{#1}\TD@optionalname{#2}#3#4}}% + \csuse{TD@#1align}% + \footnotesize\normalfont% + \textsc{{\TD@optionalname{#2}\TD@optionalname{#3}#4#5}}% \end{minipage}% \par% \addvspace{2ex}% } -\newcommand{\tocdatafigtextprint}[1]{% +\newcommand{\tocdataartistprint}{% + \par\addvspace{\medskipamount}% + \TD@artistauthorprint{artist}% +} +\newcommand{\tocdataauthorprint}{% + \par\unskip + \TD@artistauthorprint{author}% +} +\newcommand{\TD@artistauthortextprint}[2]{% \addvspace{2ex}% \begin{minipage}{\linewidth}% - \TD@textalign% - \footnotesize% + \csuse{TD@#1textalign}% + \footnotesize\normalfont% \setlength{\parskip}{1.5ex}% \setlength{\parindent}{0em}% - #1% + #2% \end{minipage}% \par% \addvspace{2ex}% } -\@ifundefined{chapter} -{}% if no chapters -{% only of chapters exists in this documentclass: -\NewDocumentCommand{\chapterauthor}{s o m O{} m m O{}}{% - \IfBooleanTF{#1}% - {% star: - \chapter*{#3\tocdatachapprint{#4}{#5}{#6}{#7}}% - }% - {% no star: - \tocdata{toc}{#5 #6}% - \IfValueTF{#2}% - {\chapter[#2]{#3\tocdatachapprint{#4}{#5}{#6}{#7}}}% - {\chapter[#3]{#3\tocdatachapprint{#4}{#5}{#6}{#7}}}% - }% - \ifblank{#5}% - {\index{#6}}% - {\index{#6, #5}}% -}% end of \chapterauthor -}% end of \@ifundefined{chapter} - -\NewDocumentCommand{\sectionauthor}{s o m O{} m m O{}}{% - \IfBooleanTF{#1}% +\newcommand{\tocdataartisttextprint}{\TD@artistauthortextprint{artist}} +\newcommand{\tocdataauthortextprint}{\TD@artistauthortextprint{author}} +\NewDocumentCommand{\TD@sectionauthor}{m s o m O{} m m O{}}{% + \IfBooleanTF{#2}% {% star: - \section*{#3\tocdatasecprint{#4}{#5}{#6}{#7}}% + \csuse{#1}*{#4\nopagebreak\tocdatasectionprint{#5}{#6}{#7}{#8}}% }% {% no star: - \tocdata{toc}{#5 #6}% - \IfValueTF{#2}% - {\section[#2]{#3\tocdatasecprint{#4}{#5}{#6}{#7}}}% - {\section[#3]{#3\tocdatasecprint{#4}{#5}{#6}{#7}}}% + \tocdata{toc}{#6 #7}% + \IfValueTF{#3}% + {\csuse{#1}[#3]{#4\nopagebreak\tocdatasectionprint{#5}{#6}{#7}{#8}}}% + {\csuse{#1}[#4]{#4\nopagebreak\tocdatasectionprint{#5}{#6}{#7}{#8}}}% }% no star - \ifblank{#5}% - {\index{#6}}% - {\index{#6, #5}}% + \ifblank{#6}% + {\index{#7}}% + {\index{#7, #6}}% } -\newcommand{\TD@namealign}{\centering} -\newcommand{\tdnamejustify}{% - \renewcommand{\TD@namealign}{}% +\newcommand*{\partauthor}{\TD@sectionauthor{part}} +\@ifundefined{chapter} +{}% if no chapters +{% only of chapters exists in this documentclass: + \newcommand*{\chapterauthor}{\TD@sectionauthor{chapter}} } -\newcommand{\tdnamecenter}{% - \renewcommand{\TD@namealign}{\centering}% +\newcommand*{\sectionauthor}{\TD@sectionauthor{section}} +\newcommand*{\subsectionauthor}{\TD@sectionauthor{subsection}} +\newcommand{\TD@artistalign}{\centering} +\newcommand{\tdartistjustify}{% + \renewcommand{\TD@artistalign}{}% } -\newcommand{\tdnameleft}{% - \renewcommand{\TD@namealign}{\raggedright}% +\newcommand{\tdartistcenter}{% + \renewcommand{\TD@artistalign}{\centering}% } -\newcommand{\tdnameright}{% - \renewcommand{\TD@namealign}{\raggedleft}% +\newcommand{\tdartistleft}{% + \renewcommand{\TD@artistalign}{\raggedright}% } -\newcommand{\TD@textalign}{\centering} -\newcommand{\tdtextjustify}{% - \renewcommand{\TD@textalign}{}% +\newcommand{\tdartistright}{% + \renewcommand{\TD@artistalign}{\raggedleft}% } -\newcommand{\tdtextcenter}{% - \renewcommand{\TD@textalign}{\centering}% +\newcommand{\TD@authoralign}{\raggedleft} +\newcommand{\tdauthorjustify}{% + \renewcommand{\TD@authoralign}{}% } -\newcommand{\tdtextleft}{% - \renewcommand{\TD@textalign}{\raggedright}% +\newcommand{\tdauthorcenter}{% + \renewcommand{\TD@authoralign}{\centering}% } -\newcommand{\tdtextright}{% - \renewcommand{\TD@textalign}{\raggedleft}% +\newcommand{\tdauthorleft}{% + \renewcommand{\TD@authoralign}{\raggedright}% } -\NewDocumentCommand{\captionartist}{s o m +O{} O{} m m O{}}{% - \par\addvspace{\medskipamount}% - \tocdatafigprint{#5}{#6}{#7}{#8}% - \ifblank{#4}% +\newcommand{\tdauthorright}{% + \renewcommand{\TD@authoralign}{\raggedleft}% +} +\newcommand{\TD@artisttextalign}{\centering} +\newcommand{\tdartisttextjustify}{% + \renewcommand{\TD@artisttextalign}{}% +} +\newcommand{\tdartisttextcenter}{% + \renewcommand{\TD@artisttextalign}{\centering}% +} +\newcommand{\tdartisttextleft}{% + \renewcommand{\TD@artisttextalign}{\raggedright}% +} +\newcommand{\tdartisttextright}{% + \renewcommand{\TD@artisttextalign}{\raggedleft}% +} +\newcommand{\TD@authortextalign}{\centering} +\newcommand{\tdauthortextjustify}{% + \renewcommand{\TD@authortextalign}{}% +} +\newcommand{\tdauthortextcenter}{% + \renewcommand{\TD@authortextalign}{\centering}% +} +\newcommand{\tdauthortextleft}{% + \renewcommand{\TD@authortextalign}{\raggedright}% +} +\newcommand{\tdauthortextright}{% + \renewcommand{\TD@authortextalign}{\raggedleft}% +} +\NewDocumentCommand{\TD@captionartistauthor}{m s o m +O{} O{} m m O{}}{% + \csuse{tocdata#1print}{#6}{#7}{#8}{#9}% + \ifblank{#5}% {}% - {\par\tocdatafigtextprint{#4}}% + {\par\csuse{tocdata#1textprint}{#5}}% \unskip% - \IfBooleanTF{#1}% + \IfBooleanTF{#2}% {% starred - \IfValueTF{#2}{\caption*[#2]{#3}}{\caption*{#3}}% + \IfValueTF{#3}{\caption*[#3]{#4}}{\caption*{#4}}% }% starred {% not starred - \tocdata{lof}{#6 #7}% - \IfValueTF{#2}{\caption[#2]{#3}}{\caption{#3}}% + \tocdata{\csuse{ext@\@captype}}{#7 #8}% + \IfValueTF{#3}{\caption[#3]{#4}}{\caption{#4}}% }% not starred - \ifblank{#6}% - {\index{#7}}% - {\index{#7, #6}}% + \ifblank{#7}% + {\index{#8}}% + {\index{#8, #7}}% } +\newcommand*{\captionartist}{\TD@captionartistauthor{artist}} +\newcommand*{\captionauthor}{\TD@captionartistauthor{author}} \endinput %% %% End of file `tocdata.sty'. -- cgit v1.2.3