I'm getting the error Illegal parameter number in definition of \setuplateloadedpackages. for the following code. It seems like newcommand can't recognise that the "macro arguments"
passed to crefformat are not its own, but placeholders to be substituted later by cleveref. I have also tried defining \setuplateloadedpackages using \def and \let, to no avail.
\newcommand*{\setuplateloadedpackages}{
% Configure styles for references.
\crefformat{section}{\S#2#1#3}
\crefformat{subsection}{\S#2#1#3}
\crefformat{subsubsection}{\S#2#1#3}
\crefrangeformat{section}{\S\S#3#1#4 to~#5#2#6}
\crefmultiformat{section}{\S\S#2#1#3}{ and~#2#1#3}{, #2#1#3}{ and~#2#1#3}
}
#symbols if you are defining macros inside another macro:\crefformat{section}{\S##2##1##3}. You need to double the number of#s for eac nesting level. – moewe Jan 27 '21 at 05:10\crefformat{<counter>}{<code>}basically works like\def/\newcommand, but once you know that, the linked question is a good duplicate. If you'd prefer a separate answer instead, just let me know, I could type something up later. – moewe Jan 27 '21 at 06:51