diff options
author | Karl Berry <karl@freefriends.org> | 2017-12-26 22:07:36 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2017-12-26 22:07:36 +0000 |
commit | ab34d559eee3be0fcacb000229e72c45e2a56ad2 (patch) | |
tree | c6c44ee1c1aff2666c3f825a2359f37c5bb67f1f /Master/texmf-dist/tex/latex/crossreftools | |
parent | 700227e76504f7d34cad2c0c3bf6bbc7616f862a (diff) |
crossreftools (26dec17)
git-svn-id: svn://tug.org/texlive/trunk@46142 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/crossreftools')
-rw-r--r-- | Master/texmf-dist/tex/latex/crossreftools/crossreftools.sty | 197 |
1 files changed, 194 insertions, 3 deletions
diff --git a/Master/texmf-dist/tex/latex/crossreftools/crossreftools.sty b/Master/texmf-dist/tex/latex/crossreftools/crossreftools.sty index 10ec71fb078..bacb9cfc8db 100644 --- a/Master/texmf-dist/tex/latex/crossreftools/crossreftools.sty +++ b/Master/texmf-dist/tex/latex/crossreftools/crossreftools.sty @@ -1,4 +1,4 @@ -%% LaTeX package crossreftools - version 0.3 (2017/10/31 -- 08:23:52) +%% LaTeX package crossreftools - version 0.4 (2017/12/26 -- 17:55:15) %% Source file for crossreftools.sty %% %% @@ -19,15 +19,24 @@ %% %% -\def\crossreftoolspackageversion{0.3} +\def\crossreftoolspackageversion{0.4} \NeedsTeXFormat{LaTeX2e}[1995/12/01] -\ProvidesPackage{crossreftools}[2017/10/31 - v\crossreftoolspackageversion] +\ProvidesPackage{crossreftools}[2017/12/26 - v\crossreftoolspackageversion] +\newif\ifcrtfinal +\DeclareOption{final}{\global\crtfinaltrue} +\DeclareOption{draft}{\global\crtfinalfalse} + +\ProcessOptions* % Some helper macros + \newcommand{\crt@refundefined}{[UNDEFINED]} +\newcommand{\crtrefundefinedtext}[1]{\renewcommand{\crt@refundefined}{#1}} + +\@onlypreamble\crtrefundefined % Splitters for cleveref @@ -280,6 +289,21 @@ \@@crtextr@ct@ref{name}{#1}% } +%%% + +\def\crt@split@@@anchor#1.#2\@nil{#1} +\def\crt@split@@anchor#1#2#3#4#5{\crt@split@@@anchor#4\@nil} +\def\crt@split@anchor#1{% + \expandafter\crt@split@@anchor#1% +} + +\newcommand{\crtrefcounter}[1]{% + \@ifundefined{r@#1}{\crt@refundefined}{% + \expandafter\crt@split@anchor\expandafter{\csname r@#1\endcsname}% + }% +} + + %%% Hyperref wrappers, not expandable. @@ -299,6 +323,173 @@ \crthyperlink{\crtrefanchor{#1}}{\crtCref{#1}}% } +%%% Support for list of labels + +\providecommand*{\listoflabelsname}{List of labels} + +\@ifclassloaded{book}{ + \providecommand*{\listoflabelstructurelevel}{% + chapter% + } +}{% + \providecommand*{\listoflabelstructurelevel}{% + section% + } +} + + +\newcommand{\crt@listoflabelsfileextension}{lla} +\newcommand{\crt@listoflabelsstructurelevel}{section} + +\newcommand{\crtlistoflabelsstructurelevel}[1]{% + \renewcommand{\crt@listoflabelsstructurelevel}{#1}% +} + +\newcommand{\crtlistoflabelsfileextension}[1]{% + \renewcommand{\crt@listoflabelsfileextension}{#1}% +} + + + + +\newcommand{\crtlistoflabels@unstarred}{% + \addcontentsline{toc}{\listoflabelstructurelevel}{\listoflabelsname}% + \@crt@listofl@bels% +} + + +\newcommand{\crtlistoflabels@starred}{% + \@crt@listofl@bels% +} + + +\newcommand{\@crt@listofl@bels}{% + \begingroup + \makeatletter + % In case of loading tcolorbox documentation mode + \@ifundefined{tcb@cs}{}{% Redefine \tcb@cs to gobble its argument + \renewcommand{\tcb@cs}[1]{}% + }% + \@input{\jobname.\crt@listoflabelsfileextension} + \if@filesw + \expandafter\newwrite\csname tf@\crt@listoflabelsfileextension\endcsname + \immediate\openout \csname tf@\crt@listoflabelsfileextension\endcsname \jobname.\crt@listoflabelsfileextension\relax + \fi + \endgroup +} + + + +\newcommand{\crtlistoflabels}{% + \ifcrtfinal + \else + \csname\listoflabelstructurelevel\endcsname*{\listoflabelsname\@mkboth{\MakeUppercase{\listoflabelsname}}{\MakeUppercase{\listoflabelsname}}}% + \@ifstar{\crtlistoflabels@starred}{\crtlistoflabels@unstarred}% + \fi +} + + +\newcommand{\crtaddlabeltotoc}[1]{% + \ifcrtfinal + \else + \addcontentsline{\crt@listoflabelsfileextension}{\crt@listoflabelsstructurelevel}{\protect\numberline{\expandafter\crtrefnumber{#1}}#1}% + \fi +} + + +\@onlypreamble{\crtlistoflabelsstructurelevel} + +\providecommand{\crtprelabelhook}[1]{} +\providecommand{\crtpostlabelhook}[1]{} + + +%%%%%%%%%%%%%% Support for generic labels + + + +\newcommand{\crtprovidecurrentlabelname}[1]{% + \protected@edef\@currentlabelname{#1}% +} + +\newcommand{\crtprovidecurrentlabel}[1]{% + \protected@edef\@currentlabel{#1}% +} + +\newcommand{\crtprovidecurrentlabelinfo}[2]{% + \if@crt@hyperrefloaded + \phantomsection% + \fi + \protected@edef\@currentlabel{#1}% + \protected@edef\@currentlabelname{#2}% +} + + + +\def\crt@@genericl@belopt@rgi[#1]#2{% + \crtprovidecurrentlabelinfo{#2}{#1}% + #1% + \@ifnextchar[{\crt@@genericl@belopt@rgii}{} +} + + +\def\scrt@@genericl@belopt@rgi[#1]#2{% + \crtprovidecurrentlabelinfo{#2}{#1}% + \@ifnextchar[{\crt@@genericl@belopt@rgii}{} +} + + +\def\crt@@genericl@belopt@rgii[#1]{% + \label{#1}% +} + + + +\def\crt@@genericl@belnoopt#1{% + \crtprovidecurrentlabelinfo{#1}{#1}% + #1% + \@ifnextchar[{\crt@@genericl@belopt@rgii}{}% +} + +\def\scrt@@genericl@belnoopt#1{% + \crtprovidecurrentlabelinfo{#1}{#1}% + \@ifnextchar[{\crt@@genericl@belopt@rgii}{}% +} + + +\newcommand{\crtcrossreflabel}{% + \@ifstar{% + \@ifnextchar[{\scrt@@genericl@belopt@rgi}{\scrt@@genericl@belnoopt}% + }{% + \@ifnextchar[{\crt@@genericl@belopt@rgi}{\crt@@genericl@belnoopt}% + }% +} + +%%%%%%%%%%%%%% + + + +\AtBeginDocument{% + + \let\crt@l@bels@fe\label + + \newcommand{\l@belwithopt@rg}[2][]{% + \crtprelabelhook{#2}% + \crt@l@bels@fe[#1]{#2}% + \crtaddlabeltotoc{#2}% + \crtpostlabelhook{#2}% + } + \newcommand{\l@belwithoutopt@rg}[1]{% + \crtprelabelhook{#1}% + \crt@l@bels@fe{#1}% + \crtaddlabeltotoc{#1}% + \crtpostlabelhook{#1}% + } + + \renewcommand{\label}{% + \@ifnextchar[{\l@belwithopt@rg}{\l@belwithoutopt@rg}% + } +} \endinput + |