From 7a2e438ec282f3f0db1665410f185ace128a33ef Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Fri, 13 Jan 2006 00:07:12 +0000 Subject: smartref git-svn-id: svn://tug.org/texlive/trunk@1330 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/latex/smartref/byname.sty | 65 +++++++ Master/texmf-dist/tex/latex/smartref/smartref.sty | 207 ++++++++++++++++++++++ 2 files changed, 272 insertions(+) create mode 100644 Master/texmf-dist/tex/latex/smartref/byname.sty create mode 100644 Master/texmf-dist/tex/latex/smartref/smartref.sty (limited to 'Master') diff --git a/Master/texmf-dist/tex/latex/smartref/byname.sty b/Master/texmf-dist/tex/latex/smartref/byname.sty new file mode 100644 index 00000000000..648be4939d4 --- /dev/null +++ b/Master/texmf-dist/tex/latex/smartref/byname.sty @@ -0,0 +1,65 @@ +\def\fileversion{v1.1} +\def\filedate{2001/07/12} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Giuseppe Bilotta +% +% Phone +39-095-338103 +% +% Email: bourbaki@bigfoot.com +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% This package is distributed under the terms +% of the LaTeX Project Public License +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Please read the readme.txt file for details +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{byname}[\filedate\space\fileversion\space Increase +reference capability (reference by name)] +% +\newcommand*{\byn@melabel}[2]{% + \def\@currnamelabel{{#1}{#2}}} + +\let\bns@vesect=\@sect + +\def\@sect#1#2#3#4#5#6[#7]#8{% + \bns@vesect{#1}{#2}{#3}{#4}{#5}{#6}[#7]{#8}% + \byn@melabel{#7}{#8}} + +\let\bns@vechap=\@chapter +\def\@chapter[#1]#2{% + \bns@vechap[#1]{#2}% + \byn@melabel{#1}{#2}} + +% Hack label: also write the NameRef data ... +\def\newnamelabel{\@newl@bel {name}} +%save previous \label +\AtBeginDocument{\let\nr@ldlabel=\label +\renewcommand*{\label}[1]{\nr@ldlabel{#1}% + \@bsphack% + \protected@write\@auxout{}% + {\string\newnamelabel{#1}{\@currnamelabel}}% + \@esphack}} +% Reference by name +% +\@ifpackageloaded{hyperref}{% + \newcommand*{\byname}[1]{% + \expandafter\real@setref\csname name@#1\endcsname\@secondoftwo{#1}% + } + \newcommand*{\byshortname}[1]{% + \expandafter\real@setref\csname name@#1\endcsname\@firstoftwo{#1}% + } + }{ + \newcommand*{\byname}[1]{% + \expandafter\@setref\csname name@#1\endcsname\@secondoftwo{#1}% + } + \newcommand*{\byshortname}[1]{% + \expandafter\@setref\csname name@#1\endcsname\@firstoftwo{#1}% + } + } +\endinput diff --git a/Master/texmf-dist/tex/latex/smartref/smartref.sty b/Master/texmf-dist/tex/latex/smartref/smartref.sty new file mode 100644 index 00000000000..c8455b9e534 --- /dev/null +++ b/Master/texmf-dist/tex/latex/smartref/smartref.sty @@ -0,0 +1,207 @@ +\def\fileversion{v1.9} +\def\filedate{2002/02/28} +% smartref.sty +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Giuseppe Bilotta +% +% Phone +39 095 338103 +% +% Email: bourbaki@bigfoot.com +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% This package is distributed under the terms +% of the LaTeX Project Public License +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Please read the readme.txt file for details +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{smartref}[\filedate\space\fileversion\space Increase +reference capability (deep reference)] +% +\newcounter{@smartlistlen} +\newcounter{less@smartlist} +\setcounter{less@smartlist}{-2} +\newcommand*{\@increasesmartlist}{% + \addtocounter{@smartlistlen}{1}% + \addtocounter{less@smartlist}{1}} +\def\sm@rtreflist{{\@currentlabel}} +\@increasesmartlist +% +\newcommand*{\@getsmartreflist}[3]{% + \ifx#1% + \relax\protect\G@refundefinedtrue% + \@latex@warning {SmartReference `#2' on page % + \thepage \space undefined}% + \nfss@text{\reset@font \bfseries ??}% + \else% + \expandafter #2#1% + \fi} +\newcounter{@currsmartlistplace} +\newcommand*{\@getsmartref}[3]{%Paramaters are: #1: Where #2: Label, #3: place in list + \edef\@smartlistplace{#3}% + \setcounter{@currsmartlistplace}{0}% + \edef\@originalsmartlist{% + \expandafter\@getsmartreflist\csname sr@#2\endcsname{}{}}% + \edef\@currsmartlist{\@originalsmartlist}% + \loop% + \edef\@currsmartvalue{\expandafter\@car\@currsmartlist\@nil}% + \ifnum\the@currsmartlistplace=\theless@smartlist + \edef\@currsmartlist{\noexpand{\expandafter\@cdr\@currsmartlist\@nil\noexpand}}% + \else + \edef\@currsmartlist{\expandafter\@cdr\@currsmartlist\@nil}% + \fi + \ifnum\the@currsmartlistplace<\@smartlistplace% + \addtocounter{@currsmartlistplace}{1}% + \repeat + \edef#1{\@currsmartvalue}% +% \typeout{Got Smart Reference (place #3, value \@currsmartvalue)}% + } +% Hack label: also write the SmartRef data ... +\def\newsmartlabel{\@newl@bel {sr}} +%save previous \label +\AtBeginDocument{% + \let\sr@ldlabel=\label + \renewcommand*{\label}[1]{% + \sr@ldlabel{#1}% + \@bsphack% + \protected@write\@auxout{}% + {\string\newsmartlabel{#1}{\sm@rtreflist}}% + \@esphack}% +% This one is needed for those who use AMS-LaTeX, to ensure that +% smartref labelling system is used wih equations too (AMS-LaTeX +% uses its own labeling system for equations + \let\ltx@label=\label} +% Command to add new items to reflist: +% +\newtoks\sm@rtintern@ltok +\newcommand*{\addtoreflist}[1]{% Add item ... + \@ifundefined{c@#1}% Check if real counter; + {\@nocounterr{#1}}% If not, give error + {\@ifundefined{#1posinlist}{% If yes, check if already defined: + \sm@rtintern@ltok=\expandafter{\sm@rtreflist}% If not, define everything ... + \expandafter\edef\csname sm@rtreflist\endcsname{% + \the\sm@rtintern@ltok{\noexpand\csname the#1\endcsname}}% Add it ... +% Set position of counter in list: + \expandafter\edef\csname #1posinlist\endcsname{\the@smartlistlen}% + \@increasesmartlist% +% Define SmartCommands: +% Define command to get number of for