From e0c6872cf40896c7be36b11dcc744620f10adf1d Mon Sep 17 00:00:00 2001
From: Norbert Preining <norbert@preining.info>
Date: Mon, 2 Sep 2019 13:46:59 +0900
Subject: Initial commit

---
 .../contrib/crossreference/crossreference.dtx      | 173 +++++++++++++++++++++
 1 file changed, 173 insertions(+)
 create mode 100644 macros/latex/contrib/crossreference/crossreference.dtx

(limited to 'macros/latex/contrib/crossreference/crossreference.dtx')

diff --git a/macros/latex/contrib/crossreference/crossreference.dtx b/macros/latex/contrib/crossreference/crossreference.dtx
new file mode 100644
index 0000000000..1f786686ac
--- /dev/null
+++ b/macros/latex/contrib/crossreference/crossreference.dtx
@@ -0,0 +1,173 @@
+\def\fileversion{1.0}
+\def\filedate{2001/05/19}
+\def\docdate{2001/05/19}
+%
+% \changes{v1.0}{19 May 200}{First Release}
+%
+% \MakeShortVerb{\|}
+% \title{Cross-referencing technical Documents with \texttt{crossreference}}
+% \author{Vince Filby}
+% \maketitle
+% \begin{abstract}
+% This is the instruction manual for using
+% \texttt{crossreference}.
+% \end{abstract}
+% 
+% \section{Introduction}
+% This package allows authors to maintain a crossreference section in technical 
+% documents easily and efficiently without having to worry about reordering, 
+% removing or otherwise altering the crossreference numbers because they are 
+% automatically generated.
+% 
+% This package was originally designed to maintain the crossreference section
+% of software requirements document and a software design document.
+%
+% \section{Documentation Driver}
+% This code will generate the documentation.  Since
+% it is the first peice of code in this file, the documentation
+% can obtained by simply processing this file with \LaTeXe
+%    \begin{macrocode}
+%<*driver>
+\documentclass{ltxdoc}
+\EnableCrossrefs
+\CodelineIndex
+\RecordChanges
+\begin{document}
+        \DocInput{crossreference.dtx}    \PrintIndex   \PrintChanges
+\end{document}
+%</driver>
+%    \end{macrocode}
+% \section{User Interface}
+% This section defines everything that an average user should know.
+% 
+%    \begin{macrocode}
+%<*crossreference>
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{crossreference}[\filedate\space\fileversion\space 
+Crossreferencing for technical documents (V. Filby)]
+\newcounter{xref}
+%    \end{macrocode}
+% \DescribeMacro{\crossreferences}
+% The command|\crossreferences| will print out the crossreference table.
+% The format is simple and uses the "list of figures" table of contents style.
+% You can change the format of the table by changing this macro.   If you
+% choose to use a tabular format you will have to change the output lines
+% to include \&'s.   
+%    \begin{macrocode}
+\newcommand\crossreferences{%
+	\if@twocolumn
+		\@restonecoltrue\onecolumn
+	\else
+		\@restonecolfalse
+	\fi
+	\@starttoc{xref}
+	\if@restonecol\twocolumn\fi
+}
+%    \end{macrocode}
+% 
+% \DescribeMacro{\addxref}
+% The command |\addxref| will add a a line to the crossreference
+% table containing the number, label and section label.
+% 
+%    \begin{macrocode}
+\newcommand{\addxref}[1]{%
+	\protected@write{\@auxout}{}{\protect\@writefile{xref}{
+		\string\contentsline{figure}{\string\numberline {\thexref}{\string\ignorespaces{#1}}}{\@currentlabel}
+	}}
+	\xreflabel{#1}
+	\stepcounter{xref}
+}
+%    \end{macrocode}
+%
+% \DescribeMacro{\xref} 
+% The command |\xref| can be used to refer to an item that has been 
+% added to the crossreference table. 
+%    \begin{macrocode}
+\newcommand{\xref}[1]{~[REF \pageref{#1}]}
+%    \end{macrocode}
+%
+% \section{Definitions}
+% This section contains the internal counters and macros that are used
+% to keep track of the crossreference labels. 
+%    \begin{macrocode}
+\def\G@refundefinedtrue{%
+  \gdef\@refundefined{%
+    \@latex@warning@no@line{There were undefined references}}}
+\let\@refundefined\relax
+
+\def\@setref#1#2#3{%
+  \ifx#1\relax
+   \protect\G@refundefinedtrue
+   \nfss@text{\reset@font\bfseries ??}%
+   \@latex@warning{Reference `#3' on page \thepage \space
+             undefined}%
+  \else
+   \expandafter#2#1\null
+  \fi}
+
+\def\ref#1{\expandafter\@setref\csname r@#1\endcsname\@firstoftwo{#1}}
+
+\def\pageref#1{\expandafter\@setref\csname r@#1\endcsname
+                                   \@secondoftwo{#1}}
+\def\@newl@bel#1#2#3{%
+  \@ifundefined{#1@#2}%
+    \relax
+    {\gdef \@multiplelabels {%
+       \@latex@warning@no@line{There were multiply-defined labels}}%
+     \@latex@warning@no@line{Label `#2' multiply defined}}%
+  \global\@namedef{#1@#2}{#3}}
+
+\def\newlabel{\@newl@bel r}
+\@onlypreamble\@newl@bel
+
+\let \@multiplelabels \relax
+
+\def\xreflabel#1{\@bsphack
+  \protected@write\@auxout{}%
+         {\string\newlabel{#1}{{#1}{\thexref}}}%
+  \@esphack}
+
+\def\refstepcounter#1{\stepcounter{#1}%
+    \protected@edef\@currentlabel
+       {\csname p@#1\endcsname\csname the#1\endcsname}%
+}
+
+\def\@currentlabel{}
+%</crossreference>
+%    \end{macrocode}
+%
+% \section{Example Document}
+% This is a sample document to show how to use the crossreference system
+% when you unpacked the dtx it should have generated this file called
+% xrefexample.tex
+%    \begin{macrocode}
+%<*example>
+\documentclass{article}
+
+\usepackage{crossreference}
+
+\begin{document}
+
+\section{Animals}
+\addxref{Animals}
+Animals can eat other animals\xref{Animals} or plants\xref{Plants}.
+
+\section{Plants}
+\addxref{Plants}
+Plants are mostly green and are eaten by Animals\xref{Animals}.
+
+\section{Books and Writings}
+\addxref{Books and Writings}
+Books and writings are general not read by animals\xref{Animals} or plants\xref{Plants}.
+
+\section{Humans}
+Humans can read books and writings\xref{Books and Writings}.
+\newpage
+\section{Cross-References}
+\crossreferences 
+
+\end{document}
+\endinput
+%</example>
+%    \end{macrocode}
+% \Finale
-- 
cgit v1.2.3

