I'm typing a lot of linguistic examples and I would like label formatting to gain flexibility, i.e. setting up presets would be great.
That is, I'd like to be able to have ready-to-use setups available according to which example I am putting forward, especially with the idea of faithfully reproducing examples by specific authors from specific books. For example :
(1) a. (i) (standard),
(1) A. a.
(1) 1. A.
(1) 1. A. a.
etc.
I use
Philexwhich is basically a wrapper forLinguex.See the example below, which I would like to be able to reproduce,
- but it requires 4 levels i.e. (1) A. 1. a.;
- and must handle references to prime examples (only superficially supported by Philex):
Philex, thanks to its \subformat and \subsubformat commands, lets you customize each set of subexamples and that way, you can freely navigate between the patterns.However only 3 levels are available, and besides, you have to manually customize the sets, while ideally, presets would be convenient.
We could include vertical spacing parameters, as in Alan Munn's macros (https://tex.stackexchange.com/a/636371/262813) :
\topsep\csname lngxtopsep\roman{ExDepth}\endcsname \itemsep\csname lngxitemsep\roman{ExDepth}\endcsname
I also want to keep ability to refer to ranges. But depending on both the type of formatting used for a given sublevel, and on the delimiter, different commands are used in the value of \crefrangelabelformat :
when no stripping is involved, I want the traditional (1)-(3), or (a)-(c), or (i)-(iii) style, cf. my question here:
for (1a-e)-style, \crefstripprefix is used
- cf. https://tex.stackexchange.com/a/634181/262813 (thanks to gusbrs);
for (1a.i-iii)-style, \StrCut from package
xstringdoes the job, but there must be a delimiter (cf. red ellipsis on snapshot)- cf. https://tex.stackexchange.com/a/635636/262813 (thanks to Andrew Swann);
I want to keep local referencing to subexamples, i.e. parent sublabel skipping :
to skip only 1 level, as in (a), (b), or (a)-(c), Philex has \rfx and \rnx ;
if we want to skip the first and second levels as in (i), (ii), or (i-iii), and if a dot is involved as seen above, the
refcountpackage is called, so as to use the \gobbletodot and \getrefkeybykeydefault macros- cf. Any way to reference a particular component of a label? (thanks to Ulrich Diez);
- if some other delimiter than a dot is used, it is still to determine how we should do it;
ranges may involve level-skipping : we may define new commands as I suggest here :
I'm not asking for every aspect of the \crefrange issue to be addressed in this single post, however it could be nice if at least we could define different commands for different presets, e.g. :
- \standard for (1) a. (i)
- \classic for (1) A. a.
- \fancy for (1) 1. A.
- \complex for (1) A. a. (i)
- \lakoff for (1) A. 1. a.
- \crazy for (1) A. 1. a. (i)
- etc.
MWE :
\documentclass{report}
\usepackage{philex}
\usepackage{cleveref}
\usepackage{xstring}
% Ranges of subexamples
\crefname{ExNo}{}{}
\crefname{SubExNo}{}{}
\crefname{SubSubExNo}{}{}
\creflabelformat{ExNo}{#2#1#3} % The output of the \cref command doesn't include parentheses.
\creflabelformat{SubExNo}{#2#1#3}
\creflabelformat{SubSubExNo}{#2#1#3}
\crefrangelabelformat{ExNo}{#3#1#4--#5#2#6}
\crefrangelabelformat{SubExNo}{#3#1#4--#5\crefstripprefix{#1}{#2}#6}
\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\prefrange[2]{(\crefrange{#1}{#2})}
\begin{document}
\phildashes{}{.} % Adds a dot between sublevels 2 and 3 in references. Nothing between sublevels 1 and 2.
\subformat{a}{}{.} % Level 2 is of the form “a.”
\subsubformat{i}{(}{)} % Level 3 is of the form “(i)”
\lb{main}{This is the main level.
\lba{sub}{This is the sublevel.
\lba{subsub-a}{This is the subsublevel.}
\lbz{subsub-b}{Third level too.}}}
\phildashes{-}{.} % Adds a hyphen between sublevels 1 and 2, a dot between 2 and 3.
\subformat{A}{}{.} % Level 2 is of the form “A.”
\subsubformat{a}{}{.} % Level 3 is of the form “a.”
\lb{main2}{This is the main level.
\lba{sub2}{This is the sublevel.
\lba{subsub-a2}{This is the subsublevel.}
\lbz{subsub-b2}{Third level too.}}}
\phildashes{:}{} % Adds a colon between levels 1 and 2, and nothing between 2 and 3.
\subformat{1}{}{.} % Level 2 is of the form “1.”
\subsubformat{A}{}{.} % Level 3 is of the form “A.”
\lb{main3}{This is the main level.
\lba{sub3}{This is the sublevel.
\lba{subsub-a3}{This is the subsublevel.}
\lbz{subsub-b3}{Third level too.}}}
\rf{subsub-a} \rn{subsub-a} \rfx{subsub-a} \rnx{subsub-a}
\rf{subsub-a2} \rn{subsub-a2} \rfx{subsub-a2} \rnx{subsub-a2}
\rf{subsub-a3} \rn{subsub-a3} \rfx{subsub-a3} \rnx{subsub-a3}
\crefrange{subsub-a}{subsub-b} \prefrange{subsub-a}{subsub-b}
\crefrange{subsub-a2}{subsub-b2} \prefrange{subsub-a2}{subsub-b2}
\crefrange{subsub-a3}{subsub-b3} \prefrange{subsub-a3}{subsub-b3} % Here we would need \crefstripprefix instead of mystriptocolon, since there is no delimiter and we don't have roman numbering.
\vspace{10pt}
\noindent I would like to be able to freely navigate between presets, ideally creating
\begin{itemize}
\item a \textbackslash SubSubSubExNo counter
\item and maybe a \textbackslash SubSubSubSubExNo counter
\item specifying for each sublevel in each preset :
\begin{enumerate}
\item the vertical spacing;
\item the label format : arabic, alph, roman, etc.;
\item the delimiters : nothing, colon, hyphen, etc.;
\item values for \textbackslash creflabelformat and \textbackslash crefrangelabelformat, including prefix stripping and parent sublabel skipping.
\end{enumerate}
\end{itemize}
\end{document}
The big problem I have is that I cannot redefine \crefrangelabelformat{SubSubExNo}, since it is taken into account only if defined in the preamble.
I would like to be able to define it as
- {#3#1#4--#5\mystriptocolon{#1}{#2}#6}
when using Roman numbering after a separator, and as
- {#3#1#4--#5\crefstripprefix{#1}{#2}#6}
when using Alph or Arabic without a separator.
- I asked a new question about that issue, here :
How to adapt \crefrangelabelformat to subexample formatting?

