summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/stex/sref
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2012-03-30 23:23:02 +0000
committerKarl Berry <karl@freefriends.org>2012-03-30 23:23:02 +0000
commit849996eca72af498b48b10fbea7f14c4b9d21b8f (patch)
tree2d40d42dfc9fc0b0622212cc220868f98345305f /Master/texmf-dist/tex/latex/stex/sref
parentd82e1c23973fd0271f93686f487bd1cee8dcd947 (diff)
restore stex (ca. 28jan12)
git-svn-id: svn://tug.org/texlive/trunk@25792 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/stex/sref')
-rw-r--r--Master/texmf-dist/tex/latex/stex/sref/sref.sty105
-rw-r--r--Master/texmf-dist/tex/latex/stex/sref/sref.sty.ltxml56
2 files changed, 161 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/stex/sref/sref.sty b/Master/texmf-dist/tex/latex/stex/sref/sref.sty
new file mode 100644
index 00000000000..1cc4034f812
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/stex/sref/sref.sty
@@ -0,0 +1,105 @@
+%%
+%% This is file `sref.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% sref.dtx (with options: `package')
+%%
+\NeedsTeXFormat{LaTeX2e}[1999/12/01]
+\ProvidesPackage{sref}[2012/01/28 v1.0 Semantic Cross-References]
+\DeclareOption{showmeta}{\PassOptionsToPackage{\CurrentOption}{metakeys}}
+\newif\ifextrefs\extrefsfalse
+\DeclareOption{extrefs}{\extrefstrue}
+\ProcessOptions
+\RequirePackage{metakeys}
+\newcommand{\sref}[2][]{%
+\@ifundefined{sref@part}{\sref@hlink[#1]{#2}}{\sref@hlink[#1]{\sref@part @#2}}}
+\newcommand{\srefs}[3][]{%
+\def\@test{#1}\ifx\@test\@empty\sref{#2} and \sref{#3}\else #1\fi}
+\newcommand{\srefl}[3][]{%
+\def\@test{#1}\ifx\@test\@empty\sref{#2} to \sref{#3}\else #1\fi}
+\newcommand{\spageref}[1]{%
+\@ifundefined{sref@part}{\sref@pageref{#1}}{\sref@pageref{\sref@part @#1}}}
+\newif\ifhref\hreffalse
+\AtBeginDocument{\@ifpackageloaded{hyperref}{\hreftrue}{\hreffalse}}
+\newcommand\sref@href@ifh[2]{\ifhref\href{#1}{#2}\else#2\fi}
+\newcommand\sref@hlink@ifh[2]{\ifhref\hyperlink{#1}{#2}\else#2\fi}
+\newcommand\sref@target@ifh[2]{\ifhref\hypertarget{#1}{#2}\else#2\fi}
+\def\sref@target%
+{\ifx\sref@id\@empty\else%
+\edef\@target{sref@\@ifundefined{sref@part}{}{\sref@part @}\sref@id @target}
+\sref@target@ifh\@target{}\fi}
+\newcommand\@sref@def[3]{\expandafter\gdef\csname sref@#1@#2\endcsname{#3}}
+\ifextrefs\newwrite\refs@file\else\def\refs@file{\@auxout}\fi
+\newcommand\sref@def[3]{%\@sref@def{#1}{#2}{#3}%
+\protected@write\refs@file{}{\string\@sref@def{#1}{#2}{#3}}}
+\addmetakey{srefaddidkey}{prefix}
+\newcommand\srefaddidkey[2][]{\metasetkeys{srefaddidkey}{#1}%
+\@metakeys@ext@clear@keys{#2}{sref@id}{}% id cannot have a default
+\metakeys@ext@clear@keys{#2}{id}{}%
+\metakeys@ext@showkeys{#2}{id}%
+\define@key{#2}{id}{\edef\sref@id{\srefaddidkey@prefix ##1}%
+\expandafter\edef\csname #2@id\endcsname{\srefaddidkey@prefix ##1}}}
+\newcommand\makeextrefs[1]{\gdef\sref@part{#1}%
+\makeatletter
+\IfFileExists{\jobname.refs}{\input{\jobname.refs}}{}%
+\immediate\openout\refs@file=\jobname.refs
+\makeatother}
+\newcommand\sref@label[2]{%
+\sref@def{\@ifundefined{sref@part}{}{\sref@part @}#2}{page}{\thepage}%
+\sref@def{\@ifundefined{sref@part}{}{\sref@part @}#2}{label}{#1}}
+\newcommand\sreflabel[2]{\message{sreflabel: #1, #2}\sref@label{#1 \@currentlabel}{#2}}
+\newcommand\sref@label@id[1]{\ifx\sref@id\@empty\else\sref@label{#1}{\sref@id}\fi}
+\newcommand{\sref@hlink}[2][]{\def\@test{#1}%
+\@ifundefined{sref@#2@label}%
+{\protect\G@refundefinedtrue\@latex@warning{reference #2 undefined}??}%
+{\sref@hlink@ifh{sref@#2@target}{\ifx\@test\@empty\@nameuse{sref@#2@label}\else #1\fi}}}
+\newcommand{\sref@page@label}[1]{p.~{#1}}
+\newcommand{\sref@pageref}[1]{\@ifundefined{sref@#1@page}%
+{\protect\G@refundefinedtrue\@latex@warning{reference #1 undefined}\sref@page@label{??}}%
+{\sref@hlink@ifh{sref@#1@target}{\sref@page@label{\@nameuse{sref@#1@page}}}}}
+\newcommand{\sref@href}[3][]{\def\@test{#1}%
+\@ifundefined{sref@#2@label}%
+{\protect\G@refundefinedtrue\@latex@warning{reference #2 undefined}??}%
+{\@ifundefined{sref@#3@URI}%
+{\protect\G@refundefinedtrue\@latex@warning{external refs of type #3 undefined}??}%
+{\edef\@uri{\@nameuse{sref@#3@URI}.pdf\#sref@#2@target}
+\edef\@label{\ifx\@test\@empty\@nameuse{sref@#2@label}\else #1\fi}
+\sref@href@ifh\@uri\@label}}}
+\ifextrefs
+\newcommand{\extref}[3][]{\def\theextref{\sref@href[#1]{#2@#3}{#2}}%
+\csname doextref@#2\endcsname}
+\else
+\newcommand{\extref}[3][]{\sref[#1]{#3}}
+\fi
+\ifextrefs
+\newcommand{\extpageref}[3][]{\def\theextref{\sref@pageref[#1]{#2@#3}{#2}}%
+\csname doextpageref@#2\endcsname}
+\else
+\newcommand{\extpageref}[3][]{\spageref[#1]{#3}}
+\fi
+\newcommand\extrefstyle[2]{\expandafter\gdef\csname doextref@#1\endcsname{#2}}
+\newcommand\extpagerefstyle[2]{\expandafter\gdef\csname doextpageref@#1\endcsname{#2}}
+\newcommand{\inputrefs}[2]{%
+\@namedef{sref@#1@URI}{#2}
+\makeatletter%
+\IfFileExists{#2.refs}{\input{#2.refs}}
+ {\PackageError{sref}{Reference file #1.refs does not exist}
+ {Maybe you have to run LaTeX on #2.tex first}}
+\makeatother}
+\srefaddidkey{sequation}
+\def\sref@sequation@heading{equation}
+\newenvironment{sequation}[1][]{\metasetkeys{sequation}{#1}%
+\ifx\sref@id\@empty\begin{displaymath}\else% no id, using equation*
+\begin{equation}\sref@target\sref@label@id{\sref@sequation@heading~(\theequation)}\fi}
+{\ifx\sref@id\@empty\end{displaymath}\else\end{equation}\fi}
+\newenvironment{seqnarray}[1][]%
+{\metasetkeys{sequation}{#1}\begin{eqnarray*}\sref@target%
+\sref@label@id{\sref@sequation@heading~(\theequation)}}
+{\end{eqnarray*}}
+\newcommand\withcite[2]{#2~\cite{#1}}
+\newenvironment{withcitation}[1]{\def\citeit{\cite{#1}}}{}
+\endinput
+%%
+%% End of file `sref.sty'.
diff --git a/Master/texmf-dist/tex/latex/stex/sref/sref.sty.ltxml b/Master/texmf-dist/tex/latex/stex/sref/sref.sty.ltxml
new file mode 100644
index 00000000000..5d888c6715a
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/stex/sref/sref.sty.ltxml
@@ -0,0 +1,56 @@
+package LaTeXML::Package::Pool;
+use strict;
+use LaTeXML::Package;
+DeclareOption('extrefs','');
+RequirePackage('metakeys');
+sub withhash {'#';}
+DefConstructor('\sref[]{}',
+ "<omdoc:oref href='&withhash()#2'/>");
+DefConstructor('\srefs[]{}',
+ "<omdoc:oref href='&withhash()#2'/>");
+DefConstructor('\srefl[]{}',
+ "<omdoc:oref href='&withhash()#2'/>");
+DefConstructor('\spageref{}',
+ "<omdoc:oref href='&withhash()#1'/>");
+DefConstructor('\makeextrefs{}','');
+DefConstructor('\extref[]{}{}',
+ "<omdoc:oref href='#2@#3'/>");
+DefConstructor('\theextref','');
+DefConstructor('\extpageref[]{}{}',
+ "<omdoc:oref href='#2@#3'/>");
+DefConstructor('\theextref','');
+DefConstructor('\extrefstyle{}{}',"");
+DefConstructor('\extrefstyle{}{}',"");
+DefConstructor('\inputrefs{}{}','');
+DefEnvironment('{sequation} OptionalKeyVals',
+ "<ltx:equation "
+ . "?&KeyVal(#1,'id')(xml:id='&KeyVal(#1,'id')' "
+ . "refnum='#refnum')(xml:id='#id')>"
+ . "<ltx:Math mode='display'>"
+ . "<ltx:XMath>#body</ltx:XMath>"
+ . "</ltx:Math>"
+ . "</ltx:equation>",
+ mode=>'display_math',
+ properties=> sub { RefStepCounter('equation') },
+ locked=>1);
+DefMacro('\seqnarray OptionalKeyVals','\begin{eqnarray*}');
+DefMacro('\endseqnarray','\end{eqnarray*}');
+DefMacro('\withcite{}{}','\begin{withcitation}{#1}#2\citeit\end{withcitation}');
+DefConstructor('\citeit',"<omdoc:citation/> ",
+afterConstruct => sub {
+ my ($document,$whatsit) = @_;
+ # LibXML acrobatics, since we can't talk about the xml:id prior to construction's end
+ # (and please do correct me if this is inaccurate)
+ my $node = $document->getNode;
+ my ($citenode) = $document->findnodes('preceding-sibling::omdoc:citation',$node);
+ my ($phrase_parent) = $document->findnodes('ancestor::ltx:text[@xml:id]',$node);
+ return unless (defined $phrase_parent) && (defined $citenode);
+ my $id = $phrase_parent->getAttribute('xml:id');
+ my $refs = $phrase_parent->getAttribute('citeit-refs');
+ $phrase_parent->removeAttribute('citeit-refs');
+ $citenode->setAttribute('for',$id);
+ $citenode->setAttribute('refs',$refs);
+});#$
+DefEnvironment('{withcitation}{}',
+ "<ltx:text citeit-refs='#1'>#body</ltx:text>");
+1;