Posts

Showing posts with the label Cleveref

Can \cref Be Made To Ignore Spaces?

Image
Answer : Normalization with removal of spaces before and after label names and removing of empty entries. The following example uses the comma parser of package kvsetkeys for parsing the label name list of the referencing commands of package cleveref . The internal \@cref with the list in its second argument is redefined for this: \documentclass{article} \usepackage{cleveref} \usepackage{kvsetkeys} \makeatletter \let\org@@cref\@cref \renewcommand*{\@cref}[2]{% \begingroup \toks@={}% \comma@parse{#2}\add@cref@item \edef\process@me{\endgroup \noexpand\org@@cref{#1}{\the\toks@}% }\process@me } \newcommand*{\add@cref@item}[1]{% \expandafter\ifx\expandafter\\\the\toks@\\% \toks@{#1}% \else \toks@\expandafter{\the\toks@,#1}% \fi } \makeatother \begin{document} \noindent We can use \cref{1,2}, and now \cref{1, 2},\\ and even with a leading or trailing comma: \Cref{ , 1 , 2 ,}. \section{Section 1} \label{1} \section{Section ...