From e0c6872cf40896c7be36b11dcc744620f10adf1d Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 2 Sep 2019 13:46:59 +0900 Subject: Initial commit --- macros/latex/contrib/titleref/miscdoc.sty | 115 ++++++++++++++++++++++ macros/latex/contrib/titleref/titleref.pdf | Bin 0 -> 204300 bytes macros/latex/contrib/titleref/titleref.sty | 152 +++++++++++++++++++++++++++++ macros/latex/contrib/titleref/titleref.tex | 89 +++++++++++++++++ 4 files changed, 356 insertions(+) create mode 100644 macros/latex/contrib/titleref/miscdoc.sty create mode 100644 macros/latex/contrib/titleref/titleref.pdf create mode 100644 macros/latex/contrib/titleref/titleref.sty create mode 100644 macros/latex/contrib/titleref/titleref.tex (limited to 'macros/latex/contrib/titleref') diff --git a/macros/latex/contrib/titleref/miscdoc.sty b/macros/latex/contrib/titleref/miscdoc.sty new file mode 100644 index 0000000000..da1f2a5fdb --- /dev/null +++ b/macros/latex/contrib/titleref/miscdoc.sty @@ -0,0 +1,115 @@ +\ProvidesPackage{miscdoc}[2010/01/20 v1.2 documentation macros misc latex pkgs] + +% miscdoc.sty +% Copyright 2010 Robin Fairbairns +% +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3 +% of this license or (at your option) any later version. +% The latest version of this license is in +% http://www.latex-project.org/lppl.txt +% and version 1.3 or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% This work has the LPPL maintenance status `maintained'. +% +% The Current Maintainer of this work is Robin Fairbairns. +% +% This work consists of the file miscdoc.sty (only) + +\setcounter{errorcontextlines}{1274} + +% The package arose from a small exercise to document packages whose +% previous documentation consisted solely of comments in the package files. +% The macros here defined are lifted from the author's faq.sty +% (written for the UK TeX FAQ, CTAN:help/uk-tex-faq) or are inspired +% by others' work (credited where the author is known) ... except +% where they came as a flash of inspiration while actually writing the +% documentation. + +% this option suggested by Heiko Oberdiek, 2010-01-29 +\DeclareOption{hyper}{% + \AtEndOfPackage{% + \RequirePackage[pdfusetitle]{hyperref} + \RequirePackage{bookmark} + \bookmarksetup{numbered,open,openlevel=1} + } +} +\ProcessOptions\relax + +% note: T1 encoding assumed +\usepackage{lmodern} +\usepackage[T1]{fontenc} +\usepackage{booktabs} + +% from faq.sty +\newcommand\cs[1]{\texttt{\char`\\#1}} +\let\csx\cs +\def\bsbs{\cs{\char`\\}} + +% \cmdinvoke\cs +% \cs typeset as above +% may consist of optional or mandatory arguments; +% +% the `arguments' are simply typesett \texttt, as yet -- if something +% fancier is needed, there's a bunch of code needs rewriting here... +\DeclareRobustCommand\cmdinvoke{\@ifstar + {\let\@tempa\emph\@scmdinvoke}% + {\let\@tempa\relax\@scmdinvoke}% +} +\def\@scmdinvoke#1{\texttt{\symbol{92}#1}% + \futurelet\@let@token\@cmdinvoke +} +\def\@cmdinvoke{\ifx\@let@token\bgroup + \let\@tempb\@cmdinvoke@lbrace + \else + \ifx\@let@token[% ] + \let\@tempb\@cmdinvoke@lbrack + \else + \ifx\@let@token(% ) + \let\@tempb\@cmdinvoke@lparen + \else + \let\@tempb\@empty + \fi + \fi + \fi + \@tempb +} +\def\@cmdinvoke@lbrace#1{\penalty0\hskip0pt\relax + \texttt{\symbol{123}\@tempa{#1}\symbol{125}}% + \futurelet\@let@token\@cmdinvoke +} +\def\@cmdinvoke@lbrack[#1]{\penalty-150\hskip0pt\relax + \texttt{[\@tempa{#1}]}% + \futurelet\@let@token\@cmdinvoke +} +\def\@cmdinvoke@lparen(#1){\penalty-150\hskip0pt\relax + \texttt{(\@tempa{#1})}% + \futurelet\@let@token\@cmdinvoke +} +% and extension -- versions that take a single extra (delimiter) +% argument, such as \delcmdinvoke{lscrunge}( ... awful syntax, but... +\DeclareRobustCommand\delcmdinvoke{\@ifstar + {\let\@tempa\emph\@sdelcmdinvoke}% + {\let\@tempa\relax\@sdelcmdinvoke}% +} +\def\@sdelcmdinvoke#1#2{\texttt{\symbol{92}#1#2}% + \futurelet\@let@token\@cmdinvoke +} + +% sui generis +\newcommand\newitem{\par\addvspace{1ex}\noindent} + +% inspired by doc.sty in latex distribution +\newcommand\meta[1]{\ensuremath{\langle}\emph{#1}\ensuremath{\rangle}} + +% meaningful names, as in faq.sty +\newcommand\environment[1]{\texttt{#1}} +\newcommand\pkgoption[1]{\texttt{#1}} +\newcommand\extension[1]{\texttt{.#1}} +\newcommand\Package[1]{\textsf{#1}} +\def\option{\@ifnextchar[\@optionb\@option}% ] +\def\@optionb[#1]{{\normalfont\ttfamily[#1]}} +\def\@option#1{\texttt{#1}} + +\let\FontName\textsf \ No newline at end of file diff --git a/macros/latex/contrib/titleref/titleref.pdf b/macros/latex/contrib/titleref/titleref.pdf new file mode 100644 index 0000000000..c56872a5a7 Binary files /dev/null and b/macros/latex/contrib/titleref/titleref.pdf differ diff --git a/macros/latex/contrib/titleref/titleref.sty b/macros/latex/contrib/titleref/titleref.sty new file mode 100644 index 0000000000..33b09411d2 --- /dev/null +++ b/macros/latex/contrib/titleref/titleref.sty @@ -0,0 +1,152 @@ +% TITLEREF.STY ver 3.1 2001-04-05 Donald Arseneau +% This is free unsupported software, released to the public domain. +% +% This package provides a "\titleref" command to cross-reference the titles +% of sections. The "\label" command is changed to remember the title for +% such a reference. Use "\titleref" just like "\ref" and "\pageref". +% +% Titles for numbered sectioning units and for floats with captions are +% the same as the respective TOC, LOF, or LOT entry (even when no TOC is +% printed). When a short title is provided ("\section[short]{long}") +% it will be used for the "\titleref". This is especially useful for +% figure captions. Unnumbered sections take their title reference from +% the printed title. Beware! This turns the title into a moving argument +% when it normally is not, and will cause weird errors if there are +% `fragile' commands present. +% +% Enumerated lists do not have titles and simply inherit the title of +% their section. +% +% The format of the title reference is controlled by the command +% "\theTitleReference", which can be redefined with "\renewcommand". +% It takes two parameters: the number and the title. The number is +% just the regular "\ref" and it is WRONG in unnumbered sections. +% Beware! The default definition is the unadorned title. You could +% do, for example, "\renewcommand{\theTitleReference}[2]{#1\ \emph{#2}}". +% +% The title of the current section is also available without "\label": +% Use the command "\currenttitle" to generate a "\titleref" to the current +% section. If you have redefined "\theTitleReference" to print the number +% with the title, be aware that the two may not correspond: In a numbered +% list the number will show the current item but the title will show the +% current section, but in an unnumbered section the number will show +% some previous section number. +% +% Options: [usetoc] and [nostar] +% +% In the default operation, the titles are recorded by a command inserted +% into the various sectioning commands ("\@sect", "\@ssect", "\@chapter", +% "\@schapter", "\@part", "\@spart", and "\@caption"). If this creates +% conflicts with some other package, you can use an entirely different +% method by specifying "\usepackage[usetoc]{titleref}". As the name +% implies, this option records the titles from the table-of-contents +% entry without redefining the sectioning commands. (This is the method +% used in older versions.) +% +% Since there are no TOC entries for the `star' versions of sectioning +% commands, they are still redefined. The additional option "[nostar]" +% ("\usepackage[usetoc,nostar]{titlerrf}") prevents the redefinitions, +% but then "\section*" will not generate a title reference. If you try +% to refer to the title of an unnumbered section while "[nostar]" is in +% effect, you will get the title of the previous section. +% +% Under the "[usetoc]" option, the current title will always be overridden +% by an "\addcontentsline" command before the "\label", even for starred +% section commands under the "[nostar]" option. +% +% The big problem with the "[usetoc]" method is that "\titleref" will +% not refer to a "\label" which was given in the title or caption itself; +% the label must be placed after the sectioning command or the caption. +% If you make a title-reference to a label given in a title, you will get +% a warning message. +% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{titleref}[2001/04/05 v3.1 \space + Cross-references with titles.] + +\newcommand{\theTitleReference}[2]{#2} +% +\let\TR@old@label\label +% +% This redefinition of \label is intended to work with other redirections +% of \label, if they record extra information in a similar way. +\def\label#1{\@bsphack\begingroup + \protected@edef\@currentlabel{\protect\TR@TitleReference + {\@currentlabel}{\TR@currentTitle}}% + \TR@old@label{#1}% + \endgroup \@esphack}% +% +\def\TR@gettitle#1{\begingroup \let\protect\@unexpandable@protect + \let\label\TR@nestwarn \let\index\@gobble \let\glossary\@gobble + \let\markboth\@gobbletwo \let\@mkboth\@gobbletwo \let\markright\@gobble + \edef\@tempa{\noexpand\def\noexpand\TR@currentTitle{#1}}% + \expandafter\endgroup\@tempa} +% +\let\TR@nestwarn\@gobble +% +\let\TR@TitleReference\@firstoftwo +% +% Allow aux file to be used after titleref is removed: +\AtBeginDocument{\immediate\write\@mainaux{\string\let + \string\TR@TitleReference\string\@firstoftwo}} +% +\DeclareRobustCommand{\titleref}[1]{\begingroup \let\numberline\@gobble + \let\TR@TitleReference\TR@theTR % interrupt recursion of \ref + \ref{#1}\endgroup} +% +\DeclareRobustCommand{\currenttitle}{\begingroup \let\numberline\@gobble + \theTitleReference\@currentlabel\TR@currentTitle\endgroup} +% +% +\def\TR@theTR{0} +\DeclareOption{usetoc}{\edef\TR@theTR{1\TR@theTR}}% +\DeclareOption{nostar}{\edef\TR@theTR{\TR@theTR 1}}% +\ProcessOptions\relax +% +% Put hooks in "star" commands if not [usetoc,nostar] +\ifnum\TR@theTR<100 +% +\AtBeginDocument{\let\TR@old@ssect\@ssect + \def\@ssect#1#2#3#4#5{\TR@gettitle{#5}\TR@old@ssect{#1}{#2}{#3}{#4}{#5}}% + \@ifundefined{@schapter}{}{\let\TR@old@schapter\@schapter + \def\@schapter#1{\TR@gettitle{#1}\TR@old@schapter{#1}}} + \@ifundefined{@spart}{}{\let\TR@old@spart\@spart + \def\@spart#1{\TR@gettitle{#1}\TR@old@spart{#1}}} +} +% +\fi +% +% Put hooks in other commands if not [usetoc] +\ifnum\TR@theTR<9 +% +\AtBeginDocument{% + \let\TR@old@sect\@sect \def\@sect#1#2#3#4#5#6[#7]{\TR@gettitle{#7}% + \TR@old@sect{#1}{#2}{#3}{#4}{#5}{#6}[{#7}]}% + \@ifundefined{@chapter}{}{\AtBeginDocument{\let\TR@old@chapter\@chapter + \def\@chapter[#1]{\TR@gettitle{#1}\TR@old@chapter[{#1}]}}} + \@ifundefined{@part}{}{\AtBeginDocument{\let\TR@old@part\@part + \def\@part[#1]{\TR@gettitle{#1}\TR@old@part[{#1}]}}}% + \let\TR@old@caption\@caption \long\def\@caption#1[#2]#3{\TR@gettitle{#2}% + \TR@old@caption{#1}[{#2}]{#3}} +} +% +\else % [usetoc], hook into \addcontentsline and prohibit labels in titles +% +\DeclareRobustCommand\TR@nestwarn[1]{\PackageWarning{titleref}% + {Label \string"#1\string" was put in a title,\MessageBreak + so the \noexpand\titleref is incorrect}} +% +\let\TR@old@addcontentsline\addcontentsline +% +\def\addcontentsline#1#2#3{% + \TR@old@addcontentsline{#1}{#2}{#3}% + \TR@gettitle{\relax#3}} +% +\fi +% +\let\TR@currentTitle\@empty +% +% proper definition: +\def\TR@theTR{\let\TR@TitleReference\@firstoftwo \theTitleReference} +% +\endinput % the end diff --git a/macros/latex/contrib/titleref/titleref.tex b/macros/latex/contrib/titleref/titleref.tex new file mode 100644 index 0000000000..6d184ed2c9 --- /dev/null +++ b/macros/latex/contrib/titleref/titleref.tex @@ -0,0 +1,89 @@ +\documentclass[a4paper]{article} +\usepackage[a4paper]{geometry} +\usepackage{miscdoc} +\usepackage[scaled=0.85]{luximono} +\begin{document} +\title{The \Package{titleref} package} +\author{Donald Arseneau\thanks{Documentation file assembled by Robin + Fairbairns}} +\date{5th April 2005, version 3.1} +\maketitle + +The package provides a command \cs{titleref} to cross-reference the +titles of sections (etc.). The \cs{label} command is changed to +remember the title for such a reference. You can use \cs{titleref} +just as you use \cs{ref} and \cs{pageref}. + +Titles for numbered sectioning units and for floats with captions are +the same as the respective \textsc{toc}, \textsc{lof}, or \textsc{lot} +entry (even when no \textsc{toc}, or whatever, is printed). When a +short title is provided (\cmdinvoke{section}[short]{long}, etc.\@) it +will be used for the \cs{titleref}. This is especially useful for +figure captions. Unnumbered sections take their title reference from +the printed title. Beware!~--- This turns the title into a moving +argument when it normally is not, and will cause weird errors if there +are `fragile' commands present. + +Enumerated lists do not have titles and simply inherit the title of +their section. + +The format of the title reference is controlled by the command +\cs{theTitleReference}, which can be redefined with \cs{renewcommand}. +It takes two parameters: the number and the title. The number is +just the regular \cs{ref} and it is WRONG in unnumbered sections. +Beware! The default definition is the unadorned title. You could +do, for example, +\cmdinvoke{renewcommand}{\cs{theTitleReference}}[2]{\#1\cs{\ }\cs{emph}{\#2}} + +The title of the current section is also available without \cs{label}: +use the command \cs{currenttitle} to generate a \cs{titleref} to the +current section. If you have redefined \cs{theTitleReference} to +print the number with the title, be aware that the two may not +correspond: in a numbered list the number will show the current item +but the title will show the current section, while in an unnumbered +section the number will show some previous section number. + +\section*{Options: \option[usetoc] and \option[nostar]} + +In the default operation, the titles are recorded by a command +inserted into the various sectioning commands (\cs{@sect}, +\cs{@ssect}, \cs{@chapter}, \cs{@schapter}, \cs{@part}, \cs{@spart}, +and \cs{@caption}). If this creates conflicts with some other +package, you can use an entirely different method by specifying +\cmdinvoke{usepackage}[usetoc]{titleref}. As the name implies, this +option records the titles from the table-of-contents entry without +redefining the sectioning commands. (This method was used in older +versions of the package.) + +Since there are no \textsc{toc} entries for the `star' versions of +sectioning commands, they are still redefined. The additional option +\option[nostar] (\cmdinvoke{usepackage}[usetoc,nostar]{titleref}) +prevents the redefinitions, but then "\cs{section*}" will not generate +a title reference. If you try to refer to the title of an unnumbered +section while \option[nostar] is in effect, you will get the title of +the previous section. + +Under the \option[usetoc] option, the current title will always be +overridden by an \cs{addcontentsline} command before the \cs{label}, +even for starred section commands under the \option[nostar] option. + +The big problem with the \option[usetoc] method is that \cs{titleref} +will not refer to a \cs{label} which was given in the title or caption +itself; the label must be placed after the sectioning command or the +caption. If you make a title-reference to a label given in a title, +you will get a warning message. + +\section*{Compatibility} + +The package was early in the field with this functionality, but it now +has competitors. The package \emph{will not} work with other packages +that manipulate the labelling mechanism, such as \Package{hyperref}; +for that title references with \Package{hyperref} you must use the +\Package{nameref} package in place of \Package{titleref}. + +The \Package{zref} package also diddles with the \cs{label}--\cs{ref} +mechanism, and will equally not work with \Package{titleref}. +\Package{zref} itself doesn't provide a title reference facility: you +need to use \Package{hyperref} and \Package{nameref} for that. + +\end{document} -- cgit v1.2.3