交叉引用:子标签跳过变体

交叉引用:子标签跳过变体

在交叉引用语言实例时,我使用它zref来定义用于引用对或范围的命令。

对于每个命令,我都有两个“跳过”变体mainskipmaxskip,用于在明确的上下文中进行本地引用;它们分别跳过一个或两个标记。

我的问题是这样的:我不想增加命令,而是想将这些变体变成引用命令的可选参数:

\cleverange[mainskip]{Ref1}{Ref2}, \cleverange[maxskip]{Ref1}{Ref2}

\clevepair[mainskip]{Ref1}{Ref2}, \clevepair[maxskip]{Ref1}{Ref2}

当然它也可能适用于常规引用,不涉及范围或对。

平均能量损失

\documentclass{article}

\usepackage{zref-user}
\usepackage{philex}

\renewcommand{\label}{\zlabel}

\newcommand{\na}{n\textbackslash a}

\makeatletter

\zref@newprop{theexno}{\arabic{ExNo}}
\zref@newprop{thesubexno}{\arabic{altsub}}
\zref@newprop{theexdepth}{\theExDepth}

\zref@newprop{mainstrip}{\ifnum\theExDepth=3\alph{altsub}.\roman{altsubsub}\else\alph{altsub}\fi}

\zref@newprop{maxstrip}{\ifnum\theExDepth=3\roman{altsubsub}\else{\ifnum\theExDepth=2\alph{altsub}\else\arabic{ExNo}\fi}\fi}


\zref@newprop{mainskip}{\ifnum\theExDepth=1\arabic{ExNo}\else{%
    \ifnum\theExDepth=2\alph{altsub}%
    \else\alph{altsub}.\roman{altsubsub}\fi}%
    \fi}
    
\zref@newprop{maxskip}{\ifnum\theExDepth=3\roman{altsubsub}\else{%
    \ifnum\theExDepth=2\alph{altsub}\else\arabic{ExNo}\fi}%
    \fi}%


\zref@addprops{main}{theexno,thesubexno,theexdepth,mainstrip,maxstrip,mainskip,maxskip}


% Clever Stripping

\newcommand{\pairequal}[2]{%
        \ifnum\zref@extract{#1}{theexno}=\zref@extract{#2}{theexno}{%
            \ifnum\zref@extract{#1}{thesubexno}=\zref@extract{#2}{thesubexno}(\zref{#1},\,\zref[maxstrip]{#2})%
            \else (\zref{#1},\,\zref[mainstrip]{#2})\fi}%
        \else (\zref{#1}) and (\zref{#2})\fi}%
            
\newcommand{\rangeequal}[2]{%
        \ifnum\zref@extract{#1}{theexno}=\zref@extract{#2}{theexno}{%
            \ifnum\zref@extract{#1}{thesubexno}=\zref@extract{#2}{thesubexno}(\zref{#1}--\zref[maxstrip]{#2})%
            \else (\zref{#1}--\zref[mainstrip]{#2})\fi}%
        \else(\zref{#1})--(\zref{#2})\fi}%
        
\newcommand{\cleverange}[2]{%
    \ifnum\zref@extract{#1}{theexdepth}=\zref@extract{#2}{theexdepth}\rangeequal{#1}{#2}%
    \else(\zref{#1})--(\zref{#2})\fi}

\newcommand{\clevepair}[2]{%
    \ifnum\zref@extract{#1}{theexdepth}=\zref@extract{#2}{theexdepth}\pairequal{#1}{#2}%
    \else(\zref{#1}) and (\zref{#2})\fi}

\newcommand{\xzref}[1]{(\zref{#1})}
% Skipping Variants

% A. Main Skip

\newcommand{\mainskippairequal}[2]{%
        \ifnum\zref@extract{#1}{theexno}=\zref@extract{#2}{theexno}{%
            \ifnum\zref@extract{#1}{thesubexno}=\zref@extract{#2}{thesubexno}(\zref[mainskip]{#1},\,\zref[maxstrip]{#2})%
            \else (\zref[mainskip]{#1}) and (\zref[mainstrip]{#2})\fi}%
        \else (\zref[mainskip]{#1},\,\zref[mainskip]{#2})\fi}%
            
\newcommand{\mainskiprangeequal}[2]{%
        \ifnum\zref@extract{#1}{theexno}=\zref@extract{#2}{theexno}{%
            \ifnum\zref@extract{#1}{thesubexno}=\zref@extract{#2}{thesubexno}(\zref[mainskip]{#1}--\zref[maxstrip]{#2})%
            \else (\zref[mainskip]{#1})--(\zref[mainskip]{#2})\fi}%
        \else (\zref[mainskip]{#1}--\zref[mainskip]{#2})\fi}

\newcommand{\mainskipcleverange}[2]{%
    \ifnum\zref@extract{#1}{theexdepth}=\zref@extract{#2}{theexdepth}\mainskiprangeequal{#1}{#2}%
    \else (\zref[mainskip]{#1}--\zref[mainskip]{#2})\fi}

\newcommand{\mainskipclevepair}[2]{%
    \ifnum\zref@extract{#1}{theexdepth}=\zref@extract{#2}{theexdepth}\mainskippairequal{#1}{#2}%
    \else (\zref[mainskip]{#1},\,\zref[mainskip]{#2})\fi}


% B. Max Skip

\newcommand{\maxskippairequal}[2]{%
        \ifnum\zref@extract{#1}{theexno}=\zref@extract{#2}{theexno}%
            {\ifnum\zref@extract{#1}{thesubexno}=\zref@extract{#2}{thesubexno}(\zref[maxskip]{#1}) and (\zref[maxskip]{#2})%
            \else(\zref[maxskip]{#1}) and (\zref[maxskip]{#2})\fi}%
        \else(\zref[maxskip]{#1},\,\zref[maxskip]{#2})\fi}%
            
\newcommand{\maxskiprangeequal}[2]{%
        \ifnum\zref@extract{#1}{theexno}=\zref@extract{#2}{theexno}{%
            \ifnum\zref@extract{#1}{thesubexno}=\zref@extract{#2}{thesubexno}(\zref[maxskip]{#1})--(\zref[maxskip]{#2})%
            \else(\zref[maxskip]{#1})--(\zref[maxskip]{#2})\fi}%
        \else(\zref[maxskip]{#1}--\zref[maxskip]{#2})\fi}

\newcommand{\maxskipcleverange}[2]{%
    \ifnum\zref@extract{#1}{theexdepth}=\zref@extract{#2}{theexdepth}\maxskiprangeequal{#1}{#2}%
    \else(\zref[maxskip]{#1}--\zref[maxskip]{#2})\fi}

\newcommand{\maxskipclevepair}[2]{%
    \ifnum\zref@extract{#1}{theexdepth}=\zref@extract{#2}{theexdepth}\maxskippairequal{#1}{#2}%
    \else(\zref[maxskip]{#1},\,\zref[maxskip]{#2})\fi}

\makeatother


\begin{document}

\phildashes{}{.} 
\subformat{a}{}{.}     


\lb{main1}{Example One.
    \lba{sub11}{Subexample One-One.
        \lba{subsub111}{Subsubexample One-One-One.}
        \lbb{subsub112}{Subsubexample One-One-Two.}
        \lbz{subsub113}{Subsubexample One-One-Three.}}
    \lbz{sub12}{Subexample One-Two.
        \lba{subsub121}{Subsubexample One-Two-One.}
        \lbz{subsub122}{Subsubexample One-Two-Two.}}}

\lb{main2}{Example Two. 
        \lba{sub21}{Subexample Two-One.}
        \lbz{sub22}{Subexample Two-Two.}}

\vspace{3ex}

\textbf{Clever Ranges} (full - mainskip - maxskip)\vspace{1ex}

\begin{tabular}[c]{lll}

\cleverange{main1}{main2} & \na & \na\\

\cleverange{sub11}{sub12} & \mainskipcleverange{sub11}{sub12} & \na\\

\cleverange{sub11}{sub22} & \na & \na\\

\cleverange{subsub111}{subsub113} & \mainskipcleverange{subsub111}{subsub113} & \maxskipcleverange{subsub111}{subsub113}\\

\cleverange{subsub113}{subsub122} & \mainskipcleverange{subsub113}{subsub122} & \na

\end{tabular}

\vspace{2ex}


------------------\vspace{2ex}

\textbf{Clever Pairs} (full - mainskip - maxskip)\vspace{1ex}

\begin{tabular}[c]{lll}

\clevepair{main1}{main2} & \na & \na\\

\clevepair{sub11}{sub12} & \mainskipclevepair{sub11}{sub12} & \na\\

\clevepair{sub11}{sub22} & \na & \na\\

\clevepair{subsub111}{subsub113} & \mainskipclevepair{subsub111}{subsub113} & \maxskipclevepair{subsub111}{subsub113}\\

\clevepair{subsub113}{subsub122} & \mainskipclevepair{subsub113}{subsub122} & \na

\end{tabular}

\end{document}

在此处输入图片描述

相关内容