2023-10-16 16:24:38 +02:00
|
|
|
\NeedsTeXFormat{LaTeX2e}
|
|
|
|
\ProvidesPackage{jrpie-yaref}[2023/07/28 - yet another ref]
|
|
|
|
|
|
|
|
\RequirePackage{hyperref}
|
|
|
|
\RequirePackage{amstext}
|
2023-11-14 23:13:39 +01:00
|
|
|
\RequirePackage{xspace}
|
2023-10-16 16:24:38 +02:00
|
|
|
|
2024-02-16 23:28:14 +01:00
|
|
|
\newwrite\yaref@output
|
|
|
|
\immediate\openout\yaref@output=\jobname.yaref.json
|
|
|
|
\write\yaref@output{data = [}
|
|
|
|
|
|
|
|
\newcounter{yarefproof@depth}
|
|
|
|
\setcounter{yarefproof@depth}{0}
|
|
|
|
|
|
|
|
\edef\yaref@hastag{\string#}%
|
|
|
|
|
|
|
|
\let\yaref@oldlabel\label
|
|
|
|
\def\publicurl{https://josia-notes.users.abstractnonsen.se/w23-logic-2/logic2.pdf}
|
|
|
|
|
|
|
|
\newenvironment{yarefproof}[1]{%
|
|
|
|
\ifnum\the\value{yarefproof@depth}=0%
|
|
|
|
\global\def\yarefproof@current{#1}%
|
|
|
|
\fi%
|
|
|
|
\addtocounter{yarefproof@depth}{1}%
|
|
|
|
\begin{refproof}{#1}% Depth: \theyarefproof@depth
|
|
|
|
}{%
|
|
|
|
\end{refproof}%
|
|
|
|
\addtocounter{yarefproof@depth}{-1}%
|
|
|
|
%\ifnum\yarefproof@depth=0%
|
|
|
|
% \def\yarefproof@current{nothing}%
|
|
|
|
%\fi%
|
|
|
|
%\let\yarefproof@current=\undefined%
|
|
|
|
\ignorespacesafterend%
|
|
|
|
}
|
|
|
|
|
|
|
|
\newcommand{\yaref@writedependency}[1]{%
|
|
|
|
\ifnum\the\value{yarefproof@depth}=0%
|
|
|
|
% not in a proof environment
|
|
|
|
%\write\yaref@output{EDGE: #1 - \theyarefproof@depth}%
|
|
|
|
\else%
|
|
|
|
\ifcsname yarefproof@current\endcsname%
|
|
|
|
\write\yaref@output{{data: {id:"#1\yarefproof@current", source:"#1", target: "\yarefproof@current"}},}%
|
|
|
|
\else%
|
|
|
|
% in a proof env, but no label defined ???
|
|
|
|
%\write\yaref@output{{#1 - ERROR}}%
|
|
|
|
\fi%
|
|
|
|
\fi%
|
|
|
|
}
|
|
|
|
|
2023-10-16 16:24:38 +02:00
|
|
|
\newcommand{\yaref@text@large}[1]{%
|
|
|
|
\ifcsname yaref@longlabel@#1\endcsname%
|
|
|
|
\hyperref[#1]{\csname yaref@longlabel@#1\endcsname\ (\ref*{#1})}%
|
|
|
|
\else%
|
|
|
|
\autoref{#1}%
|
|
|
|
\fi%
|
|
|
|
}
|
|
|
|
\newcommand{\yaref@text@small}[1]{%
|
|
|
|
\ifcsname yaref@shortlabel@#1\endcsname%
|
|
|
|
\hyperref[#1]{\csname yaref@shortlabel@#1\endcsname}%
|
|
|
|
\else%
|
|
|
|
(\ref{#1})%
|
|
|
|
\fi%
|
|
|
|
}
|
|
|
|
\newcommand{\yaref@math@large}[1]{%
|
|
|
|
\text{\yaref@text@large{#1}}%
|
|
|
|
}
|
|
|
|
\newcommand{\yaref@math@small}[1]{%
|
|
|
|
\text{\yaref@text@small{#1}}%
|
|
|
|
}
|
|
|
|
\newcommand{\yaref@math@verysmall}[1]{%
|
|
|
|
\yaref@math@small{#1}%
|
|
|
|
}
|
|
|
|
|
|
|
|
\newcommand{\yalabel}[3]{%
|
2024-02-16 23:28:14 +01:00
|
|
|
\yaref@oldlabel{#3}%
|
2023-10-16 16:24:38 +02:00
|
|
|
\write\@auxout{\noexpand\expandafter\noexpand\gdef\noexpand\csname yaref@longlabel@#3\noexpand\endcsname{#1}}%
|
|
|
|
\write\@auxout{\noexpand\expandafter\noexpand\gdef\noexpand\csname yaref@shortlabel@#3\noexpand\endcsname{#2}}%
|
2024-02-16 23:28:14 +01:00
|
|
|
\write\yaref@output{{data: {id: "#3", label: "#1", short: "#2", href: "\publicurl\yaref@hastag\getrefbykeydefault{#3}{anchor}{}"}},}%
|
2023-10-16 16:24:38 +02:00
|
|
|
\expandafter\gdef\csname yaref@longlabel@#3\endcsname{#1}%
|
|
|
|
\expandafter\gdef\csname yaref@shortlabel@#3\endcsname{#2}%
|
|
|
|
}
|
|
|
|
|
|
|
|
\newcommand{\yaref}[1]{%
|
2024-02-16 23:28:14 +01:00
|
|
|
\yaref@writedependency{#1}%
|
2023-10-16 16:24:38 +02:00
|
|
|
\relax\ifmmode%
|
|
|
|
\mathchoice
|
|
|
|
{\yaref@math@large{#1}} % display style
|
|
|
|
{\yaref@math@large{#1}} % text style
|
|
|
|
{\yaref@math@small{#1}} % script style
|
|
|
|
{\yaref@math@verysmall{#1}} % scriptscript style
|
|
|
|
\else%
|
2023-11-14 23:13:39 +01:00
|
|
|
\yaref@text@large{#1}\xspace%
|
2023-10-16 16:24:38 +02:00
|
|
|
\fi%
|
|
|
|
}
|
2023-11-13 15:50:08 +01:00
|
|
|
% Force a small reference
|
|
|
|
\newcommand{\yarefs}[1]{%
|
2024-02-16 23:28:14 +01:00
|
|
|
%\yaref@writedependency{#1}%
|
2023-11-13 15:50:08 +01:00
|
|
|
\relax\ifmmode%
|
2023-11-14 23:13:39 +01:00
|
|
|
\yaref@math@verysmall{#1}% scriptscript style
|
2023-11-13 15:50:08 +01:00
|
|
|
\else%
|
2023-11-14 23:13:39 +01:00
|
|
|
\yaref@text@small{#1}\xspace%
|
2023-11-13 15:50:08 +01:00
|
|
|
\fi%
|
|
|
|
}
|
2024-02-16 23:28:14 +01:00
|
|
|
\renewcommand{\label}[1]{%
|
|
|
|
\yaref@oldlabel{#1}%
|
|
|
|
% \getrefbykeydefault{#1}{name}{}
|
|
|
|
\write\yaref@output{{data: {id: "#1", label: "\getrefnumber{#1}", href: "\publicurl\yaref@hastag\getrefbykeydefault{#1}{anchor}{}"}},}%
|
|
|
|
}
|
|
|
|
|
|
|
|
\AtEndDocument{\write\yaref@output{{}]}}
|