summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2019-07-16 21:14:47 +0000
committerKarl Berry <karl@freefriends.org>2019-07-16 21:14:47 +0000
commite60e39769f3e2422fce8df70f0475a8d77c83000 (patch)
tree45db9926ff31482f29e778c672fbacda1e7c6301 /Master/texmf-dist/tex/latex
parentcf12bb505e9a4455ac9fb495f04cf7a2d079186c (diff)
tocdata (16jul19)
git-svn-id: svn://tug.org/texlive/trunk@51654 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r--Master/texmf-dist/tex/latex/tocdata/tocdata.sty238
1 files changed, 219 insertions, 19 deletions
diff --git a/Master/texmf-dist/tex/latex/tocdata/tocdata.sty b/Master/texmf-dist/tex/latex/tocdata/tocdata.sty
index 13314164446..ae4dfa715bf 100644
--- a/Master/texmf-dist/tex/latex/tocdata/tocdata.sty
+++ b/Master/texmf-dist/tex/latex/tocdata/tocdata.sty
@@ -17,7 +17,7 @@
%% version 2005/12/01 or later.
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{tocdata}
- [2019/03/21 v2.02 Adds author/artist to TOC entries.]
+ [2019/07/06 v2.03 Adds author/artist to TOC entries.]
\RequirePackage{xparse}
@@ -33,6 +33,11 @@
Move \protect\usepackage{titletoc} after \protect\usepackage{tocdata}.%
}
}{}
+
+\@ifclassloaded{memoir}
+{}% memoir
+{% not memoir
+
\@ifpackageloaded{tocloft}{
\PackageError{tocdata}
{%
@@ -43,6 +48,8 @@
}
}{}
+}% not memoir
+
\AtBeginDocument{
\@ifpackageloaded{titletoc}{
\@ifpackageloaded{tocloft}{
@@ -67,11 +74,26 @@
\@bsphack\addtocontents{#1}{\protect\settocdata{#2}}\@esphack%
}
\newcommand{\tocdatafont}[1]{{\normalfont\textit{\small#1}}}
+\def\tocdataformat{\tocdatafont}
\newcommand{\TD@usetocdata}{%
- \tocdatafont{\TD@thistocdata}%
- \global\def\TD@thistocdata{}%
+ \ifdefvoid{\TD@thistocdata}{}{%
+ \tocdataformat{\TD@thistocdata}%
+ \global\def\TD@thistocdata{}%
+ }%
+}
+
+\let\TD@checktocdatafont\tocdatafont
+
+\AtBeginDocument{
+\ifdefequal\TD@checktocdatafont\tocdatafont{}{
+ \PackageWarningNoLine{tocdata}{%
+ You have redefined \protect\tocdatafont,\MessageBreak
+ which has been deprecated. Please redefine\MessageBreak
+ \protect\tocdataformat\space instead}
+}
}
+\newcommand*{\TD@patchstandardlatex}{
\xpatchcmd{\@dottedtocline}
{\hfill\nobreak}
{\hfill\TD@usetocdata\nobreak}
@@ -82,6 +104,8 @@
Authors may not appear in TOC, LOF}
}%
+\@ifclassloaded{memoir}{}{%
+\@ifpackageloaded{tocbasic}{}{%
\xpatchcmd{\l@part}
{\hfil}
{\hfil\TD@usetocdata}
@@ -91,10 +115,11 @@
Could not patch LaTeX core \protect\l@part.\MessageBreak
Authors may not appear in TOC parts}
}%
+}}
-\@ifundefined{chapter}
-{}
-{
+\@ifclassloaded{memoir}{}{%
+\@ifpackageloaded{tocbasic}{}{%
+\@ifundefined{chapter}{}{%
\xpatchcmd{\l@chapter}
{\hfil\nobreak}
{\hfil\TD@usetocdata\nobreak}
@@ -104,8 +129,9 @@
Could not patch LaTeX core \protect\l@chapter.\MessageBreak
Authors may not appear in TOC chapters}
}%
-}
+}}}
+\@ifclassloaded{article}{
\xpatchcmd{\l@section}
{\hfil\nobreak}
{\hfil\TD@usetocdata\nobreak}
@@ -115,6 +141,13 @@
Could not patch LaTeX core \protect\l@section.\MessageBreak
Authors may not appear in TOC sections}
}%
+}{}
+}% TD@patchstandardlatex
+\@ifpackageloaded{lwarp}{%
+ \ifbool{warpingprint}{\TD@patchstandardlatex}{}%
+}{%
+ \TD@patchstandardlatex%
+}
\AtBeginDocument{
\@ifpackageloaded{titletoc}{
@@ -147,6 +180,21 @@
}% end of \AtBeginDocument
\AtBeginDocument{
+\@ifclassloaded{memoir}
+{
+\appto{\cftpartleader}{\TD@usetocdata}
+\appto{\cftchapterleader}{\TD@usetocdata}
+\appto{\cftsectionleader}{\TD@usetocdata}
+\appto{\cftsubsectionleader}{\TD@usetocdata}
+\appto{\cftsubsubsectionleader}{\TD@usetocdata}
+\appto{\cftparagraphleader}{\TD@usetocdata}
+\appto{\cftsubparagraphleader}{\TD@usetocdata}
+\appto{\cftfigureleader}{\TD@usetocdata}
+\appto{\cfttableleader}{\TD@usetocdata}
+\appto{\cftsubfigureleader}{\TD@usetocdata}
+\appto{\cftsubtableleader}{\TD@usetocdata}
+}% memoir
+{% not memoir
\@ifpackageloaded{tocloft}
{
\appto{\cftpartleader}{\TD@usetocdata}
@@ -165,21 +213,150 @@
}% end of tocloft patches
{}% tocloft not loaded
+}% not memoir
}% \AtBeginDocument
-\newcommand{\TD@optionalname}[1]
+\AtBeginDocument{
+
+\@ifpackageloaded{tocbasic}{
+\renewcommand*{\scr@dte@tocline}[3]{%
+ \ifnum \@nameuse{#1tocdepth}>\c@tocdepth
+ \else
+ \tocbasic@DependOnPenaltyAndTOCLevel{#1}%
+ \addvspace{\@nameuse{scr@tso@#1@beforeskip}}\relax
+ {%
+ \leftskip \@nameuse{scr@tso@#1@indent}\relax
+ \rightskip \@tocrmarg
+ \parfillskip -\rightskip
+ \@nameuse{Ifscr@tso@#1@raggedpage}{%
+ \addtolength{\parfillskip}{\z@ \@plus 1fil}%
+ }{}%
+ \parindent \@nameuse{scr@tso@#1@indent}\relax
+ \@afterindenttrue
+ \interlinepenalty\@M
+ \expandafter\ifx\csname ragged#1entry\endcsname\raggedright
+ \addtolength\rightskip\@flushglue
+ \else
+ \def\reserved@a{\raggedright}%
+ \expandafter\ifx\csname ragged#1entry\endcsname\reserved@a
+ \addtolength\rightskip\@flushglue
+ \else
+ \renewcommand\reserved@a{\raggedright}%
+ \expandafter\ifx\csname ragged#1entry\endcsname\reserved@a
+ \addtolength\rightskip\@flushglue
+ \fi
+ \fi
+ \fi
+ \leavevmode
+ \@tempdima \@nameuse{scr@tso@#1@numwidth}\relax
+ \@nameuse{Ifscr@tso@#1@dynnumwidth}{%
+ \scr@ifundefinedorrelax{scr@dte@#1@lastmaxnumwidth}{}{%
+ \ifdim \@nameuse{scr@dte@#1@lastmaxnumwidth}>\@tempdima
+ \@tempdima\@nameuse{scr@dte@#1@lastmaxnumwidth}\relax
+ \fi
+ }%
+ }{}%
+ \advance\leftskip \@tempdima
+ \null\nobreak\hskip -\leftskip
+ {%
+ \usetocbasicnumberline
+ \let\scr@dte@numberline@box\numberline@box
+ \def\numberline@box##1{%
+ \sbox\scr@dte@tocline@numbox{\@nameuse{scr@tso@#1@numberformat}{##1}}%
+ \global\scr@dte@tocline@numberwidth
+ \dimexpr\wd\scr@dte@tocline@numbox+\@nameuse{scr@tso@#1@numsep}\relax
+ \relax
+ \ifdim \scr@dte@tocline@numberwidth
+ >\@nameuse{scr@dte@#1@maxnumwidth}\relax
+ \global\@nameuse{scr@dte@#1@maxnumwidth}\scr@dte@tocline@numberwidth
+ \fi
+ \@nameuse{Ifscr@tso@#1@dynnumwidth}{}{%
+ \ifdim \scr@dte@tocline@numberwidth
+ >\dimexpr \@nameuse{scr@tso@#1@numwidth}%
+ +\@nameuse{scr@tso@#1@numsep}\relax\relax
+ \PackageWarning{tocbasic%
+ }{%
+ number width of #1 toc entries should be
+ increased!\MessageBreak
+ Currently used number width =
+ \the\wd\scr@dte@tocline@numbox,\MessageBreak
+ Wanted number separation
+ \space\space\space =
+ \the\dimexpr\@nameuse{scr@tso@#1@numsep}\relax,\MessageBreak
+ Reserved number width \space\space\space\space\space\space =
+ \the\dimexpr\@nameuse{scr@tso@#1@numwidth}\relax%
+ }%
+ \fi
+ }%
+ \scr@dte@numberline@box{\@nameuse{scr@tso@#1@numberformat}{##1}}%
+ \@nameuse{Ifscr@tso@#1@breakafternumber}{%
+ {\parfillskip\@flushglue\par}\nobreak\hskip-\leftskip
+ }{}%
+ }%
+ \@nameuse{scr@tso@#1@entryformat}{%
+ #2%
+ \nobreak
+ {%
+ \normalfont\normalsize\@nameuse{scr@tso@#1@linefill}%
+ \TD@usetocdata% lwarp
+ \nobreak
+ \@nameuse{scr@tso@#1@pagenumberbox}{%
+ \@nameuse{scr@tso@#1@pagenumberformat}{#3}%
+ }%
+ }%
+ \@par
+ }%
+ }%
+ }%
+ \tocbasic@SetPenaltyByTOCLevel{#1}%
+ \fi
+}
+
+}{}
+}
+\AtBeginDocument{
+\@ifpackageloaded{tocstyle}{
+\xpatchcmd\tocstyle@dottedtocline
+ {%
+ \ifx\tocstyle@feature@leaders\relax
+ \leaders\hbox{$\m@th
+ \mkern \@dotsep mu\hbox{\tocstyle@feature@dothook .}%
+ \mkern \@dotsep mu$}\hfill
+ \else
+ \tocstyle@feature@leaders
+ \fi%
+ }
+ {%
+ \ifx\tocstyle@feature@leaders\relax
+ \leaders\hbox{$\m@th
+ \mkern \@dotsep mu\hbox{\tocstyle@feature@dothook .}%
+ \mkern \@dotsep mu$}\hfill
+ \else
+ \tocstyle@feature@leaders
+ \fi%
+ \TD@usetocdata%
+ }
+ {}%
+ {%
+ \PackageWarningNoLine{tocdata}{%
+ Could not patch tocstyle \protect\tocstyle@dottedtocline.\MessageBreak
+ Authors may not appear in TOC, LOF}
+ }%
+}{}
+}
+\newcommand{\TDoptionalnameprint}[1]
{%
\ifblank{#1}%
{}%
{#1~}%
}
-\newrobustcmd{\tocdatapartprint}[4]
+\newcommand{\tocdatapartprint}[4]
{%
- \par\unskip\noindent%
+ \par\noindent%
{%
\normalfont\normalsize%
\textit{%
\hspace*{4em}--- %
- \TD@optionalname{#1}\TD@optionalname{#2}#3#4%
+ \TDoptionalnameprint{#1}\TDoptionalnameprint{#2}#3#4%
}%
}%
}
@@ -190,24 +367,24 @@
}% end of chapters-only
\let\tocdatasectionprint\tocdatapartprint
\let\tocdatasubsectionprint\tocdatapartprint
-\newcommand{\TD@artistauthorprint}[5]{%
+\newcommand{\TDartistauthorprint}[5]{%
\begin{minipage}{\linewidth}%
\csuse{TD@#1align}%
\footnotesize\normalfont%
- \textsc{{\TD@optionalname{#2}\TD@optionalname{#3}#4#5}}%
+ \textsc{{\TDoptionalnameprint{#2}\TDoptionalnameprint{#3}#4#5}}%
\end{minipage}%
\par%
\addvspace{2ex}%
}
\newcommand{\tocdataartistprint}{%
\par\smallskip%
- \TD@artistauthorprint{artist}%
+ \TDartistauthorprint{artist}%
}
\newcommand{\tocdataauthorprint}{%
\par\smallskip%
- \TD@artistauthorprint{author}%
+ \TDartistauthorprint{author}%
}
-\newcommand{\TD@artistauthortextprint}[2]{%
+\newcommand{\TDartistauthortextprint}[2]{%
\addvspace{2ex}%
\begin{minipage}{\linewidth}%
\csuse{TD@#1textalign}%
@@ -219,12 +396,35 @@
\par%
\addvspace{2ex}%
}
-\newcommand{\tocdataartisttextprint}{\TD@artistauthortextprint{artist}}
-\newcommand{\tocdataauthortextprint}{\TD@artistauthortextprint{author}}
+\newcommand{\tocdataartisttextprint}{\TDartistauthortextprint{artist}}
+\newcommand{\tocdataauthortextprint}{\TDartistauthortextprint{author}}
+\@ifclassloaded{article}
+{
+ \newcommand*{\TD@starredsectionauthorprint}[5]{%
+ \unskip\medskip\csuse{tocdata#1print}{#2}{#3}{#4}{#5}\par%
+ \bigskip%
+ }
+}
+{
+ \newcommand*{\TD@starredsectionauthorprint}[5]{%
+ \ifstrequal{#1}{part}%
+ {%
+ \PackageWarning{tocdata}{%
+ The author's name will not be printed for\MessageBreak
+ the starred \protect\part%
+ }
+ }%
+ {%
+ \unskip\medskip\csuse{tocdata#1print}{#2}{#3}{#4}{#5}\par%
+ \bigskip%
+ }%
+ }
+}
\NewDocumentCommand{\TD@sectionauthor}{m s o m O{} m m O{}}{%
\IfBooleanTF{#2}%
{% star:
- \csuse{#1}*{#4\nopagebreak\csuse{tocdata#1print}{#5}{#6}{#7}{#8}}%
+ \csuse{#1}*{#4}%
+ \TD@starredsectionauthorprint{#1}{#5}{#6}{#7}{#8}%
}%
{% no star:
\tocdata{toc}{#6 #7}%