I'd like to know how packages like cleveref actually work. As far as I know, \ref gives back the value of the counter that was incremented through \refstepcounter. However, it can only give the value of the counter. Nothing about the name or other info about the environment is known. So I'm wondering how cleveref works, and I'd like to create a reference command with similar functions myself.
Asked
Active
Viewed 56 times
1
cleveref.dtxin your TeX distribution and compile it twice in LaTeX. The output file,cleveref.pdf, will contain a new section, numbered "16 Implementation". This section, more than 200 pages long [!], contains all implementation details of the package. Please let us know if you have questions about some of the material in section 16. – Mico Mar 24 '23 at 09:53\labelto add two lines to the aux file, one for use with\refand one with information about the type for use with\cref. This is possible because LaTeX has only a very limited concept of scope or namespaces, so each package can redefine commands from other packages, built-in commands or user commands without any issue. – Marijn Mar 25 '23 at 15:48