我使用 Cleveref 来引用子示例,例如“2a–c”。现在我想使用 crefrange 来引用 1ai–ii。
\documentclass[a4paper,12pt]{report}
\usepackage{philex}
\usepackage{cleveref}
% Tells Cleveref to refer to a range of subexamples without repeating the number of the example.
\crefname{ExNo}{}{}
\crefname{SubExNo}{}{}
\renewcommand{\theExNo}{\arabic{ExNo}}
\renewcommand{\theSubExNo}{\theExNo\alph{SubExNo}}
\creflabelformat{SubExNo}{(#2#1#3)}
\creflabelformat{ExNo}{(#2#1#3)}
\crefrangelabelformat{SubExNo}{(#3#1#4--#5\crefstripprefix{#1}{#2}#6)}
% Now I define the subsublevel :
\crefname{SubSubExNo}{}{}
\renewcommand{\theSubSubExNo}{\theSubExNo\roman{SubSubExNo}}
\creflabelformat{SubSubExNo}{(#2#1#3)}
\crefrangelabelformat{SubSubExNo}{(#3#1#4--#5#2#6)}
\begin{document}
\ex. \label{lakintpur}
\a. \label{lakintpura}\a. Greg's intention was to overthrow the government. \label{intention}
\b. Greg's purpose was to overthrow the government. \label{purpose}
\z.\b.\label{lakintpurb}\a. Greg intended to overthrow the government. \label{intendv}
\b.*Greg purposed to overthrow the government. \label{purposev}
With \crefrange{lakintpura}{lakintpurb}, I can refer to a range of subexamples, 1a–b.
\par \textbf{Now I want to use crefrange to refer to 1ai–ii.}
\vspace{0.5cm}
It would also be nice to have a delimiter, since it would improve readability,
especially in such examples as "2i:i-iii" (where the first i is an actual
letter). Now using Philex syntax :
\lb{cool}{We would like no delimiter
\phildashes{}{:}
\subformat{a}{}{.}
\lba{coola}{before reference to this.}
\lba{coolb}{but a colon before reference to this}
\lbb{coolc}{and this}}
\rf{coolb} and \rf{coolc} are cool but, now referring to
\crefrange{coolb}{coolc}, I would like the result (2a:i–ii).
% Please note : as pointed out by gusbrs, crefstripprefix won't work since in i-ii, i-iii, i-iv, ii-iii and ii-iv it will skip the first "i" of the second number as being part of the prefix.
\end{document}
非常感谢。
答案1
在这种情况下,您可以使用xstring
包在冒号处剪切前缀。下面提供了一个宏\mystriptocolon
,如果前缀子字符串对两个项目都是公共的,则删除直到(第一个)冒号的部分,否则保持不变。
\documentclass[a4paper,12pt]{report}
\usepackage{philex}
\usepackage{xstring}
\usepackage{cleveref}
% Tells Cleveref to refer to a range of subexamples without repeating
% the number of the example.
\crefname{ExNo}{}{}
\crefname{SubExNo}{}{}
\renewcommand{\theExNo}{\arabic{ExNo}}
\renewcommand{\theSubExNo}{\theExNo\alph{SubExNo}}
\creflabelformat{SubExNo}{(#2#1#3)}
\creflabelformat{ExNo}{(#2#1#3)}
\crefrangelabelformat{SubExNo}{(#3#1#4--#5\crefstripprefix{#1}{#2}#6)}
% Now I define the subsublevel :
\crefname{SubSubExNo}{}{}
\renewcommand{\theSubSubExNo}{\theSubExNo\roman{SubSubExNo}}
\creflabelformat{SubSubExNo}{(#2#1#3)}
\newcommand{\mystriptocolon}[2]{\StrCut{#1}{:}{\myonea}{\myoneb}%
\StrCut{#2}{:}{\mytwoa}{\mytwob}%
\IfStrEq{\myonea}{\mytwoa}{\mytwob}{#2}}
\crefrangelabelformat{SubSubExNo}{(#3#1#4--#5\mystriptocolon{#1}{#2}#6)}
\begin{document}
\ex. \label{lakintpur}
\a. \label{lakintpura}\a. Greg's intention was to overthrow the
government. \label{intention}
\b. Greg's purpose was to overthrow the government. \label{purpose}
\z.\b.\label{lakintpurb}\a. Greg intended to overthrow the
government. \label{intendv}
\b.*Greg purposed to overthrow the government. \label{purposev}
With \crefrange{lakintpura}{lakintpurb}, I can refer to a range of
subexamples, 1a--b.
\paragraph{Now I want to use crefrange to refer to 1ai–ii.}
It would also be nice to have a delimiter, since it would improve
readability, especially in such examples as ``2i:i--iii'' (where the
first ``i'' is an actual letter). Now using Philex syntax :
\lb{cool}{We would like no delimiter
\phildashes{}{:}
\subformat{a}{}{.}
\lba{coola}{before reference to this.}
\lba{coolb}{but a colon before reference to this}
\lbb{coolc}{and this}}
\rf{coolb} and \rf{coolc} are cool and referring to
\crefrange{coolb}{coolc} gives the result (2a:i--ii).
Note that \crefrange{intention}{coolc} also works.
\end{document}
答案2
运行文档时,您会得到??
subsubexample 引用的 ,但也会得到一个cleveref
警告:“标签类型‘SubSubExNo’的 cref 引用范围格式未定义”。事实上,这正是所缺少的。设置一个可以像文档中已有的其他一样。但是,由于罗马数字,使用\crefstripprefix
不适用于级别SubSubExNo
,因为它通过删除范围内两个引用开头的公共部分来完成工作。要设置SubSubExNo
不带范围压缩的格式,您可以使用:
\documentclass[a4paper,12pt]{report}
% Linguistic Examples
\usepackage{philex}
% Tells Cleveref to refer to a range of subexamples without repeating the number of the example.
\usepackage{cleveref}
% Refer to Subexample Ranges
\crefname{ExNo}{}{}
\crefname{SubExNo}{}{}
\crefname{SubSubExNo}{}{}
\creflabelformat{ExNo}{(#2#1#3)}
\creflabelformat{SubExNo}{(#2#1#3)}
\creflabelformat{SubSubExNo}{(#2#1#3)}
\crefrangelabelformat{SubExNo}{(#3#1#4--#5\crefstripprefix{#1}{#2}#6)}
% You may prefer to use this instead, for symmetry with `SubSubExNo`.
% \crefrangelabelformat{SubExNo}{(#3#1#4--#5#2#6)}
% `\crefstripprefix` won't work well here because of the roman numbering.
\crefrangelabelformat{SubSubExNo}{(#3#1#4--#5#2#6)}
\begin{document}
\ex. \label{lakintpur}
\a. \label{lakintpura}\a. Greg's intention was to overthrow the government. \label{intention}
\b. Greg's purpose was to overthrow the government. \label{purpose}
\z.\b.\label{lakintpurb}\a. Greg intended to overthrow the government. \label{intendv}
\b.*Greg purposed to overthrow the government. \label{purposev}
With \crefrange{lakintpura}{lakintpurb}, I can refer to a range of
subexamples, 1a–b.
\textbf{Now I want to use crefrange to refer to 1ai–ii.}
\vspace{0.5cm}
It would also be nice to have a delimiter, since it would improve readability,
especially in such examples as "2i:i-iii" (where the first i is an actual
letter). Now using Philex syntax :
\lb{cool}{We would like no delimiter
\phildashes{}{:}
\subformat{a}{}{.}
\lba{coola}{before reference to this.}
\lba{coolb}{but a colon before reference to this}
\lbb{coolc}{and this}}
\rf{coolb} and \rf{coolc} are cool but, now referring to
\crefrange{coolb}{coolc}, I want the result (2a:i–ii) with brackets and
without the `?? bug.'
\end{document}
答案3
现在提到页面...(注意:此处冒号已被点替换)
\documentclass{report}
\usepackage{xstring}
\usepackage{etoolbox}
\usepackage{cleveref}
\usepackage{philex} % Includes linguex and cgloss4e
\AtEndPreamble{
\phildashes{}{.} % Adds a dot between levels 2 and 3 in references. Nothing between levels 1 and 2.
\subformat{a}{}{.} % Level 2 is of the form “a.”
\subsubformat{i}{(}{)}} % Level 3 is of the form “(i)”
\crefname{ExNo}{}{}
\crefname{SubExNo}{}{}
\crefname{SubSubExNo}{}{}
\renewcommand{\theExNo}{\arabic{ExNo}} % Level 1 = number
\renewcommand{\theSubExNo}{\theExNo\alph{SubExNo}} % Level 2 = small letter
\renewcommand{\theSubSubExNo}{\theSubExNo\roman{SubSubExNo}} % Level 3 = small roman
\creflabelformat{ExNo}{#2#1#3} % No parentheses.
\creflabelformat{SubExNo}{#2#1#3}
\creflabelformat{SubSubExNo}{#2#1#3}
\crefrangelabelformat{SubExNo}{#3#1#4--#5\crefstripprefix{#1}{#2}#6} % No parentheses.
\newcommand{\mystriptocolon}[2]{\StrCut{#1}{.}{\myonea}{\myoneb}%
\StrCut{#2}{.}{\mytwoa}{\mytwob}%
\IfStrEq{\myonea}{\mytwoa}{\mytwob}{#2}}
\crefrangelabelformat{SubSubExNo}{#3#1#4--#5\mystriptocolon{#1}{#2}#6}
\newcommand\pref[1]{(\cref{#1})} % pref = (cref)
\newcommand\prefrange[2]{(\crefrange{#1}{#2})} % prefrange = (crefrange)
\newcommand\crefpage[1]{\cref{#1}, \cpageref{#1}} % Number without parentheses, followed by page number after comma.
\newcommand\prefpage[1]{\pref{#1} (\cpageref{#1})} % Number between parentheses, followed by page number between parentheses.
\newcommand\crefrangepage[2]{\crefrange{#1}{#2}, \cpageref{#1,#2}} % Range without parentheses, followed by page number after comma.
\newcommand\prefrangepage[2]{\prefrange{#1}{#2} (\cpageref{#1,#2})} % Range between parentheses, followed by page number between parentheses.
\begin{document}
\lb{variation}{\textbf{Structural variation in relation with the source V} \vspace{0.3cm}
\lba{coalition}{Transitive AS setup \vspace{0.2cm}
\lba{coalition-n}{la formation d'une coalition par les transfuges\\
`the formation of a coalition by the defectors'} \vspace{0.2cm}
\lbz{coalition-v}{Les transfuges formèrent une coalition.\\
`The defectors formed a coalition.'}}\vspace{0.4cm}
\lbb{cliff}{Unaccusative AS setup \vspace{0.2cm}
\lba{cliff-n}{la formation spontanée d'une falaise\\
`the spontaneous formation of a cliff'} \vspace{0.2cm}
\lbz{cliff-v}{Une falaise se forma.\\
`A cliff formed.'}}\vspace{0.4cm}
\lbz{result}{Non-AS- readings \vspace{0.4cm}
\lba{simple-event}{\textsl{\textit{Simple event} reading} \vspace{0.2cm}\\
Nous avons suivi une formation intensive.\\
`We attended an intensive training course.'} \vspace{0.4cm}
\lbb{manner}{\textsl{\textit{Manner} reading} \vspace{0.2cm}\\
On peut comprendre ce mot en observant sa formation.\\
`One may understand this word by looking at its formation.'}
\lbz{object}{\textsl{\textit{Object} reading} \vspace{0.2cm}\\
Le soldat se retrouva face à une formation de chars ennemis.\\
`The soldier found himself in front of an enemy tank formation.'}}}
\noindent ... As seen in \prefrange{manner}{object} (cf. \crefrange{manner}{object}). \\
... As seen in \prefrangepage{manner}{object} (cf. \crefrangepage{manner}{object})
\end{document}
另请参阅: