summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/crossreftools/crossreftools_driver.tex
blob: 490c32539f57263c043c3ecf3749a6d68c45a290 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
%% LaTeX package crossreftools - version 0.1 (2017/10/08 -- 22:58:50)
%% Driver file for crossreftools.sty
%%
%%
%% -------------------------------------------------------------------------------------------
%% Copyright (c) 2017 by Dr. Christian Hupfer <typography dot with dot latex at gmail dot com>
%% -------------------------------------------------------------------------------------------
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%   http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%%
%%
%% This work has the LPPL maintenance status `author-maintained`
%%
%%

\documentclass{book}

\usepackage{crossreftools}


\usepackage{hyperref}
\usepackage{cleveref}


\setlength{\parindent}{0em}

\def\labeltoshow{foochapterlabel}

\def\equationlabeltoshow{fooequationlabel}


\begin{document}


\setcounter{chapter}{16}

Let us refer the usual way: \Cref{\labeltoshow}

\edef\foocntr{\crtcrefcounter{\labeltoshow}}  

The counter for \fbox{\labeltoshow} is \foocntr\ or \crtcrefcounter{\labeltoshow}. It is used on page \crtcrefpage{\labeltoshow}. The value for the misspelled label name is \crtcrefnumber{labeltoshowstuff}, whereas the correct value is \crtcrefnumber{\labeltoshow}. 



The result is \fbox{\crtcrefresult{\labeltoshow}}

\edef\labeltoshowname{\crtcrefname{chapter}}

\section{Extracting the cleveref names}

\begin{itemize}
  
\item The lower case cross reference name for \fbox{\equationlabeltoshow} is \crtcrefnamebylabel{\equationlabeltoshow}, this time using \verb!\crtcrefnamebylabel!; the upper case name is \crtCrefnamebylabel{\equationlabeltoshow}.
\item  Extracting content with  \verb!\crtextractcref!
  \begin{itemize}
  \item counter: \crtextractcref{counter}{\labeltoshow}
  \item number: \crtextractcref{number}{\labeltoshow}
  \item result: \crtextractcref{result}{\labeltoshow}
  \item reference:   \crtextractcref{reference}{\labeltoshow}
  \item page:   \crtextractcref{page}{\labeltoshow}
  \end{itemize}
\end{itemize}

The macro \verb!\crtextractcref! is expandable!\edef\counterof{\crtextractcref{counter}{\labeltoshow}} Using the stored value for counter: \counterof!

\chapter{This is foo}\label{foochapterlabel}

\setcounter{section}{5}
\section{Foo}\label{foosectionlabel}

\begin{equation}
  E=mc^{2}\label{firstequationlabel}
\end{equation}

\begin{equation}
  E=mc^{2}\label{fooequationlabel}
\end{equation}

\end{document}