List references to labels of figures and tables
I have a large document with > 100 tables in the appendix and many references at various points in the document.
Is there a way to create a list of references in the sense of finding all ref{...}
s to tables and figures in the text.
Example:
Consider the folling document with two pages of text and a section where all the referenced tables are listed.
documentclass{article}
begin{document}
section{text}
blabla ref{fo} blabla ref{fi} blabla ref{th}
clearpage
blabla ref{on} blabla ref{tw}
section{tables}
begin{table}caption{on}label{on}end{table}
begin{table}caption{tw}label{tw}end{table}
begin{table}caption{th}label{th}end{table}
begin{table}caption{fo}label{fo}end{table}
begin{table}caption{fi}label{fi}end{table}
end{document}
Now I'd like to have something like listofreferences
telling me that tables 4 5 and 3 were referenced on page 1 and tables 1 and 2 were referenced on page 2
floats cross-referencing
add a comment |
I have a large document with > 100 tables in the appendix and many references at various points in the document.
Is there a way to create a list of references in the sense of finding all ref{...}
s to tables and figures in the text.
Example:
Consider the folling document with two pages of text and a section where all the referenced tables are listed.
documentclass{article}
begin{document}
section{text}
blabla ref{fo} blabla ref{fi} blabla ref{th}
clearpage
blabla ref{on} blabla ref{tw}
section{tables}
begin{table}caption{on}label{on}end{table}
begin{table}caption{tw}label{tw}end{table}
begin{table}caption{th}label{th}end{table}
begin{table}caption{fo}label{fo}end{table}
begin{table}caption{fi}label{fi}end{table}
end{document}
Now I'd like to have something like listofreferences
telling me that tables 4 5 and 3 were referenced on page 1 and tables 1 and 2 were referenced on page 2
floats cross-referencing
I am not trying to list the tables and where they are, but the references!
– sheß
Mar 2 '18 at 13:40
add a comment |
I have a large document with > 100 tables in the appendix and many references at various points in the document.
Is there a way to create a list of references in the sense of finding all ref{...}
s to tables and figures in the text.
Example:
Consider the folling document with two pages of text and a section where all the referenced tables are listed.
documentclass{article}
begin{document}
section{text}
blabla ref{fo} blabla ref{fi} blabla ref{th}
clearpage
blabla ref{on} blabla ref{tw}
section{tables}
begin{table}caption{on}label{on}end{table}
begin{table}caption{tw}label{tw}end{table}
begin{table}caption{th}label{th}end{table}
begin{table}caption{fo}label{fo}end{table}
begin{table}caption{fi}label{fi}end{table}
end{document}
Now I'd like to have something like listofreferences
telling me that tables 4 5 and 3 were referenced on page 1 and tables 1 and 2 were referenced on page 2
floats cross-referencing
I have a large document with > 100 tables in the appendix and many references at various points in the document.
Is there a way to create a list of references in the sense of finding all ref{...}
s to tables and figures in the text.
Example:
Consider the folling document with two pages of text and a section where all the referenced tables are listed.
documentclass{article}
begin{document}
section{text}
blabla ref{fo} blabla ref{fi} blabla ref{th}
clearpage
blabla ref{on} blabla ref{tw}
section{tables}
begin{table}caption{on}label{on}end{table}
begin{table}caption{tw}label{tw}end{table}
begin{table}caption{th}label{th}end{table}
begin{table}caption{fo}label{fo}end{table}
begin{table}caption{fi}label{fi}end{table}
end{document}
Now I'd like to have something like listofreferences
telling me that tables 4 5 and 3 were referenced on page 1 and tables 1 and 2 were referenced on page 2
floats cross-referencing
floats cross-referencing
edited Mar 3 '18 at 18:09
Christian Hupfer
150k15199394
150k15199394
asked Mar 2 '18 at 13:19
sheßsheß
1,50811328
1,50811328
I am not trying to list the tables and where they are, but the references!
– sheß
Mar 2 '18 at 13:40
add a comment |
I am not trying to list the tables and where they are, but the references!
– sheß
Mar 2 '18 at 13:40
I am not trying to list the tables and where they are, but the references!
– sheß
Mar 2 '18 at 13:40
I am not trying to list the tables and where they are, but the references!
– sheß
Mar 2 '18 at 13:40
add a comment |
2 Answers
2
active
oldest
votes
Something like this?
The code redefines ref
and grabs the label name, puts it in a seq
list and and grabs the page number of the current position where it appears, storing in a sequence as well. Those lists are then stored to the .lor
file which is retrieved with listofreferences
.
The macro trackonlylabeltypes
stores the label types that should be tracked, e.g. figure
or table
, all others are ignored, unless nottrackallfalse
is used.
Please note that the code may fail since crtrefcounter
tries to determine the underlying counter using some heuristics. If unsure, use nottrackallfalse
.
documentclass{article}
usepackage{letltxmacro}
usepackage{xparse}
usepackage{hyperref}
usepackage{cleveref}
usepackage{crossreftools}
ExplSyntaxOn
seq_new:N g_label_names_seq
seq_new:N g_trackonly_labeltype_seq
NewDocumentCommand{trackonlylabeltypes}{+m}{%
clist_map_inline:nn {#1} {
seq_gput_right:Nn g_trackonly_labeltype_seq {##1}
}
}
NewDocumentCommand{addlabelname}{+m}{%
clist_map_inline:nn {#1} {
seq_if_in:NnF g_label_names_seq {##1} {
seq_gput_right:Nn g_label_names_seq {##1}
seq_new:c {g_label_ ##1 _seq }
}
}
}
NewDocumentCommand{addlabelpos}{+m}{%
seq_gput_right:cx {g_label_ #1 _seq } {thepage}%
}
NewDocumentCommand{addlistofrefentry}{}{%
seq_map_inline:Nn g_label_names_seq {
addtocontents{lor}{protectcontentsline{section}{cref*{##1} }{seq_use:cn {g_label_ ##1 _seq } {,space}}{}{}}
}%
}
NewDocumentCommand{CheckIfInTrackTypesT}{+m+m}{%
seq_if_in:NxT g_trackonly_labeltype_seq { crtrefcounter{#1}} {#2}%
}
ExplSyntaxOff
NewDocumentCommand{writelistofreferences}{}{%
addtocontents{lor}{protectcontentsline{section}{Referenced Value}{Page(s)}{}{}addvspace{15pt}par}%
% Loop through labels
addlistofrefentry%
}
makeatletter
NewDocumentCommand{listofreferences}{}{%
clearpage
section*{List of reference positions}
@starttoc{lor}%
}
newififnottrackall
nottrackalltrue
AtBeginDocument{%
LetLtxMacro{origref}{ref}
RenewDocumentCommand{ref}{s+m}{%
% Check for label existence first
@ifundefined{r@#2}{%
}{% Only add the label if the type is correct
ifnottrackall
CheckIfInTrackTypesT{#2}{%
addlabelname{#2}%
addlabelpos{#2}%
}%
else
addlabelname{#2}%
addlabelpos{#2}%
fi
}%
IfBooleanTF{#1}{%
origref*{#2}%
}{%
origref{#2}%
}%
}
}
makeatother
AtEndDocument{%
writelistofreferences
}
usepackage{blindtext}
begin{document}
trackonlylabeltypes{figure,table,equation}
tableofcontents
listofreferences
section{text} label{Footext}
See ref{einstein}
blindtext ref{fo} blabla ref{fi} blabla ref{th} but ref{Footext}
clearpage
blabla ref{on} blabla ref{tw}
begin{equation}
E = mc^{2} label{einstein}
end{equation}
clearpage
blindtext
section{Normal section}
See ref{on} too and ref{fo}
section{tables}
begin{table}caption{on}label{on}end{table}
begin{table}caption{tw}label{tw}end{table}
begin{table}caption{th}label{th}end{table}
begin{table}caption{fo}label{fo}end{table}
begin{table}caption{fi}label{fi}end{table}
end{document}
end{document}
I wonder if one could do this using float?
– John Kormylo
Mar 2 '18 at 14:11
@JohnKormylo: What do you mean withusing float
?
– Christian Hupfer
Mar 2 '18 at 14:42
newfloat{references} and captionof{references} could creates a listof{references}. The problem is creating a list of pages.
– John Kormylo
Mar 2 '18 at 21:17
@JohnKormylo: You can go ahead, but I don't want to add even more packages. The problem of storing the labels etc. still persists
– Christian Hupfer
Mar 2 '18 at 21:19
It was just a passing thought.
– John Kormylo
Mar 2 '18 at 21:25
add a comment |
I modified Christan Hupfer's answer to also work with cleveref references and multiple ref's, e.g. Cref{table1,table2}
. I'm posting this as a separate answer, but it's 99% based on Christian's solution:
documentclass{article}
usepackage{letltxmacro,xparse,hyperref,cleveref,crossreftools}
ExplSyntaxOn
seq_new:N g_label_names_seq
seq_new:N g_trackonly_labeltype_seq
NewDocumentCommand{trackonlylabeltypes}{+m}{%
clist_map_inline:nn {#1} {
seq_gput_right:Nn g_trackonly_labeltype_seq {##1}
}
}
NewDocumentCommand{addlabelname}{+m}{%
clist_map_inline:nn {#1} {
seq_if_in:NnF g_label_names_seq {##1} {
seq_gput_right:Nn g_label_names_seq {##1}
seq_new:c {g_label_ ##1 _seq }
}
}
}
NewDocumentCommand{addlabelpos}{+m}{%
seq_gput_right:cx {g_label_ #1 _seq } {thepage}%
}
NewDocumentCommand{addlistofrefentry}{}{%
seq_map_inline:Nn g_label_names_seq {
addtocontents{lor}{protectcontentsline{section}{cref*{##1} }{seq_use:cn {g_label_ ##1 _seq } {,space}}{}{}}
}%
}
NewDocumentCommand{CheckIfInTrackTypesT}{+m+m}{%
seq_if_in:NxT g_trackonly_labeltype_seq { crtrefcounter{#1}} {#2}%
}
NewDocumentCommand{addtolor}{+m}{%
clist_map_inline:nn {#1} {%
ifnottrackallCheckIfInTrackTypesT{##1}{addlabelname{##1}addlabelpos{##1}}elseaddlabelname{##1}addlabelpos{##1}fi%
}%
}
ExplSyntaxOff
NewDocumentCommand{writelistofreferences}{}{%
addtocontents{lor}{protectcontentsline{section}{Referenced Value}{Page(s)}{}{}addvspace{15pt}par}%
addlistofrefentry%
}
NewDocumentCommand{listofreferences}{}{%
clearpage
section*{List of reference positions}
@starttoc{lor}%
}
newififnottrackall
nottrackalltrue
AtBeginDocument{%
LetLtxMacro{origref}{ref}
LetLtxMacro{origcref}{cref}
LetLtxMacro{origCref}{Cref}
RenewDocumentCommand{ref}{s+m}{addtolor{#2}IfBooleanTF{#1}{origref*{#2}}{origref{#2}}}
RenewDocumentCommand{Cref}{s+m}{addtolor{#2}IfBooleanTF{#1}{origCref*{#2}}{origCref{#2}}}
RenewDocumentCommand{cref}{s+m}{addtolor{#2}IfBooleanTF{#1}{origcref*{#2}}{origcref{#2}}}
}
AtEndDocument{writelistofreferences}
usepackage{blindtext}
begin{document}
trackonlylabeltypes{figure,table,equation}
tableofcontents
listofreferences
section{text} label{Footext}
See ref{einstein}
blindtext ref{fo} blabla ref{fi} blabla ref{th} but ref{Footext}
clearpage
blabla ref{on} blabla ref{tw}
begin{equation}
E = mc^{2} label{einstein}
end{equation}
clearpage
blindtext
section{Normal section}
See Cref{on} too and ref{fo}
Both Cref{si,se}
section{tables}
begin{table}caption{on}label{on}end{table}
begin{table}caption{tw}label{tw}end{table}
begin{table}caption{th}label{th}end{table}
begin{table}caption{fo}label{fo}end{table}
begin{table}caption{fi}label{fi}end{table}
begin{table}caption{si}label{si}end{table}
begin{table}caption{se}label{se}end{table}
end{document}
end{document}
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f418102%2flist-references-to-labels-of-figures-and-tables%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Something like this?
The code redefines ref
and grabs the label name, puts it in a seq
list and and grabs the page number of the current position where it appears, storing in a sequence as well. Those lists are then stored to the .lor
file which is retrieved with listofreferences
.
The macro trackonlylabeltypes
stores the label types that should be tracked, e.g. figure
or table
, all others are ignored, unless nottrackallfalse
is used.
Please note that the code may fail since crtrefcounter
tries to determine the underlying counter using some heuristics. If unsure, use nottrackallfalse
.
documentclass{article}
usepackage{letltxmacro}
usepackage{xparse}
usepackage{hyperref}
usepackage{cleveref}
usepackage{crossreftools}
ExplSyntaxOn
seq_new:N g_label_names_seq
seq_new:N g_trackonly_labeltype_seq
NewDocumentCommand{trackonlylabeltypes}{+m}{%
clist_map_inline:nn {#1} {
seq_gput_right:Nn g_trackonly_labeltype_seq {##1}
}
}
NewDocumentCommand{addlabelname}{+m}{%
clist_map_inline:nn {#1} {
seq_if_in:NnF g_label_names_seq {##1} {
seq_gput_right:Nn g_label_names_seq {##1}
seq_new:c {g_label_ ##1 _seq }
}
}
}
NewDocumentCommand{addlabelpos}{+m}{%
seq_gput_right:cx {g_label_ #1 _seq } {thepage}%
}
NewDocumentCommand{addlistofrefentry}{}{%
seq_map_inline:Nn g_label_names_seq {
addtocontents{lor}{protectcontentsline{section}{cref*{##1} }{seq_use:cn {g_label_ ##1 _seq } {,space}}{}{}}
}%
}
NewDocumentCommand{CheckIfInTrackTypesT}{+m+m}{%
seq_if_in:NxT g_trackonly_labeltype_seq { crtrefcounter{#1}} {#2}%
}
ExplSyntaxOff
NewDocumentCommand{writelistofreferences}{}{%
addtocontents{lor}{protectcontentsline{section}{Referenced Value}{Page(s)}{}{}addvspace{15pt}par}%
% Loop through labels
addlistofrefentry%
}
makeatletter
NewDocumentCommand{listofreferences}{}{%
clearpage
section*{List of reference positions}
@starttoc{lor}%
}
newififnottrackall
nottrackalltrue
AtBeginDocument{%
LetLtxMacro{origref}{ref}
RenewDocumentCommand{ref}{s+m}{%
% Check for label existence first
@ifundefined{r@#2}{%
}{% Only add the label if the type is correct
ifnottrackall
CheckIfInTrackTypesT{#2}{%
addlabelname{#2}%
addlabelpos{#2}%
}%
else
addlabelname{#2}%
addlabelpos{#2}%
fi
}%
IfBooleanTF{#1}{%
origref*{#2}%
}{%
origref{#2}%
}%
}
}
makeatother
AtEndDocument{%
writelistofreferences
}
usepackage{blindtext}
begin{document}
trackonlylabeltypes{figure,table,equation}
tableofcontents
listofreferences
section{text} label{Footext}
See ref{einstein}
blindtext ref{fo} blabla ref{fi} blabla ref{th} but ref{Footext}
clearpage
blabla ref{on} blabla ref{tw}
begin{equation}
E = mc^{2} label{einstein}
end{equation}
clearpage
blindtext
section{Normal section}
See ref{on} too and ref{fo}
section{tables}
begin{table}caption{on}label{on}end{table}
begin{table}caption{tw}label{tw}end{table}
begin{table}caption{th}label{th}end{table}
begin{table}caption{fo}label{fo}end{table}
begin{table}caption{fi}label{fi}end{table}
end{document}
end{document}
I wonder if one could do this using float?
– John Kormylo
Mar 2 '18 at 14:11
@JohnKormylo: What do you mean withusing float
?
– Christian Hupfer
Mar 2 '18 at 14:42
newfloat{references} and captionof{references} could creates a listof{references}. The problem is creating a list of pages.
– John Kormylo
Mar 2 '18 at 21:17
@JohnKormylo: You can go ahead, but I don't want to add even more packages. The problem of storing the labels etc. still persists
– Christian Hupfer
Mar 2 '18 at 21:19
It was just a passing thought.
– John Kormylo
Mar 2 '18 at 21:25
add a comment |
Something like this?
The code redefines ref
and grabs the label name, puts it in a seq
list and and grabs the page number of the current position where it appears, storing in a sequence as well. Those lists are then stored to the .lor
file which is retrieved with listofreferences
.
The macro trackonlylabeltypes
stores the label types that should be tracked, e.g. figure
or table
, all others are ignored, unless nottrackallfalse
is used.
Please note that the code may fail since crtrefcounter
tries to determine the underlying counter using some heuristics. If unsure, use nottrackallfalse
.
documentclass{article}
usepackage{letltxmacro}
usepackage{xparse}
usepackage{hyperref}
usepackage{cleveref}
usepackage{crossreftools}
ExplSyntaxOn
seq_new:N g_label_names_seq
seq_new:N g_trackonly_labeltype_seq
NewDocumentCommand{trackonlylabeltypes}{+m}{%
clist_map_inline:nn {#1} {
seq_gput_right:Nn g_trackonly_labeltype_seq {##1}
}
}
NewDocumentCommand{addlabelname}{+m}{%
clist_map_inline:nn {#1} {
seq_if_in:NnF g_label_names_seq {##1} {
seq_gput_right:Nn g_label_names_seq {##1}
seq_new:c {g_label_ ##1 _seq }
}
}
}
NewDocumentCommand{addlabelpos}{+m}{%
seq_gput_right:cx {g_label_ #1 _seq } {thepage}%
}
NewDocumentCommand{addlistofrefentry}{}{%
seq_map_inline:Nn g_label_names_seq {
addtocontents{lor}{protectcontentsline{section}{cref*{##1} }{seq_use:cn {g_label_ ##1 _seq } {,space}}{}{}}
}%
}
NewDocumentCommand{CheckIfInTrackTypesT}{+m+m}{%
seq_if_in:NxT g_trackonly_labeltype_seq { crtrefcounter{#1}} {#2}%
}
ExplSyntaxOff
NewDocumentCommand{writelistofreferences}{}{%
addtocontents{lor}{protectcontentsline{section}{Referenced Value}{Page(s)}{}{}addvspace{15pt}par}%
% Loop through labels
addlistofrefentry%
}
makeatletter
NewDocumentCommand{listofreferences}{}{%
clearpage
section*{List of reference positions}
@starttoc{lor}%
}
newififnottrackall
nottrackalltrue
AtBeginDocument{%
LetLtxMacro{origref}{ref}
RenewDocumentCommand{ref}{s+m}{%
% Check for label existence first
@ifundefined{r@#2}{%
}{% Only add the label if the type is correct
ifnottrackall
CheckIfInTrackTypesT{#2}{%
addlabelname{#2}%
addlabelpos{#2}%
}%
else
addlabelname{#2}%
addlabelpos{#2}%
fi
}%
IfBooleanTF{#1}{%
origref*{#2}%
}{%
origref{#2}%
}%
}
}
makeatother
AtEndDocument{%
writelistofreferences
}
usepackage{blindtext}
begin{document}
trackonlylabeltypes{figure,table,equation}
tableofcontents
listofreferences
section{text} label{Footext}
See ref{einstein}
blindtext ref{fo} blabla ref{fi} blabla ref{th} but ref{Footext}
clearpage
blabla ref{on} blabla ref{tw}
begin{equation}
E = mc^{2} label{einstein}
end{equation}
clearpage
blindtext
section{Normal section}
See ref{on} too and ref{fo}
section{tables}
begin{table}caption{on}label{on}end{table}
begin{table}caption{tw}label{tw}end{table}
begin{table}caption{th}label{th}end{table}
begin{table}caption{fo}label{fo}end{table}
begin{table}caption{fi}label{fi}end{table}
end{document}
end{document}
I wonder if one could do this using float?
– John Kormylo
Mar 2 '18 at 14:11
@JohnKormylo: What do you mean withusing float
?
– Christian Hupfer
Mar 2 '18 at 14:42
newfloat{references} and captionof{references} could creates a listof{references}. The problem is creating a list of pages.
– John Kormylo
Mar 2 '18 at 21:17
@JohnKormylo: You can go ahead, but I don't want to add even more packages. The problem of storing the labels etc. still persists
– Christian Hupfer
Mar 2 '18 at 21:19
It was just a passing thought.
– John Kormylo
Mar 2 '18 at 21:25
add a comment |
Something like this?
The code redefines ref
and grabs the label name, puts it in a seq
list and and grabs the page number of the current position where it appears, storing in a sequence as well. Those lists are then stored to the .lor
file which is retrieved with listofreferences
.
The macro trackonlylabeltypes
stores the label types that should be tracked, e.g. figure
or table
, all others are ignored, unless nottrackallfalse
is used.
Please note that the code may fail since crtrefcounter
tries to determine the underlying counter using some heuristics. If unsure, use nottrackallfalse
.
documentclass{article}
usepackage{letltxmacro}
usepackage{xparse}
usepackage{hyperref}
usepackage{cleveref}
usepackage{crossreftools}
ExplSyntaxOn
seq_new:N g_label_names_seq
seq_new:N g_trackonly_labeltype_seq
NewDocumentCommand{trackonlylabeltypes}{+m}{%
clist_map_inline:nn {#1} {
seq_gput_right:Nn g_trackonly_labeltype_seq {##1}
}
}
NewDocumentCommand{addlabelname}{+m}{%
clist_map_inline:nn {#1} {
seq_if_in:NnF g_label_names_seq {##1} {
seq_gput_right:Nn g_label_names_seq {##1}
seq_new:c {g_label_ ##1 _seq }
}
}
}
NewDocumentCommand{addlabelpos}{+m}{%
seq_gput_right:cx {g_label_ #1 _seq } {thepage}%
}
NewDocumentCommand{addlistofrefentry}{}{%
seq_map_inline:Nn g_label_names_seq {
addtocontents{lor}{protectcontentsline{section}{cref*{##1} }{seq_use:cn {g_label_ ##1 _seq } {,space}}{}{}}
}%
}
NewDocumentCommand{CheckIfInTrackTypesT}{+m+m}{%
seq_if_in:NxT g_trackonly_labeltype_seq { crtrefcounter{#1}} {#2}%
}
ExplSyntaxOff
NewDocumentCommand{writelistofreferences}{}{%
addtocontents{lor}{protectcontentsline{section}{Referenced Value}{Page(s)}{}{}addvspace{15pt}par}%
% Loop through labels
addlistofrefentry%
}
makeatletter
NewDocumentCommand{listofreferences}{}{%
clearpage
section*{List of reference positions}
@starttoc{lor}%
}
newififnottrackall
nottrackalltrue
AtBeginDocument{%
LetLtxMacro{origref}{ref}
RenewDocumentCommand{ref}{s+m}{%
% Check for label existence first
@ifundefined{r@#2}{%
}{% Only add the label if the type is correct
ifnottrackall
CheckIfInTrackTypesT{#2}{%
addlabelname{#2}%
addlabelpos{#2}%
}%
else
addlabelname{#2}%
addlabelpos{#2}%
fi
}%
IfBooleanTF{#1}{%
origref*{#2}%
}{%
origref{#2}%
}%
}
}
makeatother
AtEndDocument{%
writelistofreferences
}
usepackage{blindtext}
begin{document}
trackonlylabeltypes{figure,table,equation}
tableofcontents
listofreferences
section{text} label{Footext}
See ref{einstein}
blindtext ref{fo} blabla ref{fi} blabla ref{th} but ref{Footext}
clearpage
blabla ref{on} blabla ref{tw}
begin{equation}
E = mc^{2} label{einstein}
end{equation}
clearpage
blindtext
section{Normal section}
See ref{on} too and ref{fo}
section{tables}
begin{table}caption{on}label{on}end{table}
begin{table}caption{tw}label{tw}end{table}
begin{table}caption{th}label{th}end{table}
begin{table}caption{fo}label{fo}end{table}
begin{table}caption{fi}label{fi}end{table}
end{document}
end{document}
Something like this?
The code redefines ref
and grabs the label name, puts it in a seq
list and and grabs the page number of the current position where it appears, storing in a sequence as well. Those lists are then stored to the .lor
file which is retrieved with listofreferences
.
The macro trackonlylabeltypes
stores the label types that should be tracked, e.g. figure
or table
, all others are ignored, unless nottrackallfalse
is used.
Please note that the code may fail since crtrefcounter
tries to determine the underlying counter using some heuristics. If unsure, use nottrackallfalse
.
documentclass{article}
usepackage{letltxmacro}
usepackage{xparse}
usepackage{hyperref}
usepackage{cleveref}
usepackage{crossreftools}
ExplSyntaxOn
seq_new:N g_label_names_seq
seq_new:N g_trackonly_labeltype_seq
NewDocumentCommand{trackonlylabeltypes}{+m}{%
clist_map_inline:nn {#1} {
seq_gput_right:Nn g_trackonly_labeltype_seq {##1}
}
}
NewDocumentCommand{addlabelname}{+m}{%
clist_map_inline:nn {#1} {
seq_if_in:NnF g_label_names_seq {##1} {
seq_gput_right:Nn g_label_names_seq {##1}
seq_new:c {g_label_ ##1 _seq }
}
}
}
NewDocumentCommand{addlabelpos}{+m}{%
seq_gput_right:cx {g_label_ #1 _seq } {thepage}%
}
NewDocumentCommand{addlistofrefentry}{}{%
seq_map_inline:Nn g_label_names_seq {
addtocontents{lor}{protectcontentsline{section}{cref*{##1} }{seq_use:cn {g_label_ ##1 _seq } {,space}}{}{}}
}%
}
NewDocumentCommand{CheckIfInTrackTypesT}{+m+m}{%
seq_if_in:NxT g_trackonly_labeltype_seq { crtrefcounter{#1}} {#2}%
}
ExplSyntaxOff
NewDocumentCommand{writelistofreferences}{}{%
addtocontents{lor}{protectcontentsline{section}{Referenced Value}{Page(s)}{}{}addvspace{15pt}par}%
% Loop through labels
addlistofrefentry%
}
makeatletter
NewDocumentCommand{listofreferences}{}{%
clearpage
section*{List of reference positions}
@starttoc{lor}%
}
newififnottrackall
nottrackalltrue
AtBeginDocument{%
LetLtxMacro{origref}{ref}
RenewDocumentCommand{ref}{s+m}{%
% Check for label existence first
@ifundefined{r@#2}{%
}{% Only add the label if the type is correct
ifnottrackall
CheckIfInTrackTypesT{#2}{%
addlabelname{#2}%
addlabelpos{#2}%
}%
else
addlabelname{#2}%
addlabelpos{#2}%
fi
}%
IfBooleanTF{#1}{%
origref*{#2}%
}{%
origref{#2}%
}%
}
}
makeatother
AtEndDocument{%
writelistofreferences
}
usepackage{blindtext}
begin{document}
trackonlylabeltypes{figure,table,equation}
tableofcontents
listofreferences
section{text} label{Footext}
See ref{einstein}
blindtext ref{fo} blabla ref{fi} blabla ref{th} but ref{Footext}
clearpage
blabla ref{on} blabla ref{tw}
begin{equation}
E = mc^{2} label{einstein}
end{equation}
clearpage
blindtext
section{Normal section}
See ref{on} too and ref{fo}
section{tables}
begin{table}caption{on}label{on}end{table}
begin{table}caption{tw}label{tw}end{table}
begin{table}caption{th}label{th}end{table}
begin{table}caption{fo}label{fo}end{table}
begin{table}caption{fi}label{fi}end{table}
end{document}
end{document}
edited Mar 2 '18 at 14:42
answered Mar 2 '18 at 13:58
Christian HupferChristian Hupfer
150k15199394
150k15199394
I wonder if one could do this using float?
– John Kormylo
Mar 2 '18 at 14:11
@JohnKormylo: What do you mean withusing float
?
– Christian Hupfer
Mar 2 '18 at 14:42
newfloat{references} and captionof{references} could creates a listof{references}. The problem is creating a list of pages.
– John Kormylo
Mar 2 '18 at 21:17
@JohnKormylo: You can go ahead, but I don't want to add even more packages. The problem of storing the labels etc. still persists
– Christian Hupfer
Mar 2 '18 at 21:19
It was just a passing thought.
– John Kormylo
Mar 2 '18 at 21:25
add a comment |
I wonder if one could do this using float?
– John Kormylo
Mar 2 '18 at 14:11
@JohnKormylo: What do you mean withusing float
?
– Christian Hupfer
Mar 2 '18 at 14:42
newfloat{references} and captionof{references} could creates a listof{references}. The problem is creating a list of pages.
– John Kormylo
Mar 2 '18 at 21:17
@JohnKormylo: You can go ahead, but I don't want to add even more packages. The problem of storing the labels etc. still persists
– Christian Hupfer
Mar 2 '18 at 21:19
It was just a passing thought.
– John Kormylo
Mar 2 '18 at 21:25
I wonder if one could do this using float?
– John Kormylo
Mar 2 '18 at 14:11
I wonder if one could do this using float?
– John Kormylo
Mar 2 '18 at 14:11
@JohnKormylo: What do you mean with
using float
?– Christian Hupfer
Mar 2 '18 at 14:42
@JohnKormylo: What do you mean with
using float
?– Christian Hupfer
Mar 2 '18 at 14:42
newfloat{references} and captionof{references} could creates a listof{references}. The problem is creating a list of pages.
– John Kormylo
Mar 2 '18 at 21:17
newfloat{references} and captionof{references} could creates a listof{references}. The problem is creating a list of pages.
– John Kormylo
Mar 2 '18 at 21:17
@JohnKormylo: You can go ahead, but I don't want to add even more packages. The problem of storing the labels etc. still persists
– Christian Hupfer
Mar 2 '18 at 21:19
@JohnKormylo: You can go ahead, but I don't want to add even more packages. The problem of storing the labels etc. still persists
– Christian Hupfer
Mar 2 '18 at 21:19
It was just a passing thought.
– John Kormylo
Mar 2 '18 at 21:25
It was just a passing thought.
– John Kormylo
Mar 2 '18 at 21:25
add a comment |
I modified Christan Hupfer's answer to also work with cleveref references and multiple ref's, e.g. Cref{table1,table2}
. I'm posting this as a separate answer, but it's 99% based on Christian's solution:
documentclass{article}
usepackage{letltxmacro,xparse,hyperref,cleveref,crossreftools}
ExplSyntaxOn
seq_new:N g_label_names_seq
seq_new:N g_trackonly_labeltype_seq
NewDocumentCommand{trackonlylabeltypes}{+m}{%
clist_map_inline:nn {#1} {
seq_gput_right:Nn g_trackonly_labeltype_seq {##1}
}
}
NewDocumentCommand{addlabelname}{+m}{%
clist_map_inline:nn {#1} {
seq_if_in:NnF g_label_names_seq {##1} {
seq_gput_right:Nn g_label_names_seq {##1}
seq_new:c {g_label_ ##1 _seq }
}
}
}
NewDocumentCommand{addlabelpos}{+m}{%
seq_gput_right:cx {g_label_ #1 _seq } {thepage}%
}
NewDocumentCommand{addlistofrefentry}{}{%
seq_map_inline:Nn g_label_names_seq {
addtocontents{lor}{protectcontentsline{section}{cref*{##1} }{seq_use:cn {g_label_ ##1 _seq } {,space}}{}{}}
}%
}
NewDocumentCommand{CheckIfInTrackTypesT}{+m+m}{%
seq_if_in:NxT g_trackonly_labeltype_seq { crtrefcounter{#1}} {#2}%
}
NewDocumentCommand{addtolor}{+m}{%
clist_map_inline:nn {#1} {%
ifnottrackallCheckIfInTrackTypesT{##1}{addlabelname{##1}addlabelpos{##1}}elseaddlabelname{##1}addlabelpos{##1}fi%
}%
}
ExplSyntaxOff
NewDocumentCommand{writelistofreferences}{}{%
addtocontents{lor}{protectcontentsline{section}{Referenced Value}{Page(s)}{}{}addvspace{15pt}par}%
addlistofrefentry%
}
NewDocumentCommand{listofreferences}{}{%
clearpage
section*{List of reference positions}
@starttoc{lor}%
}
newififnottrackall
nottrackalltrue
AtBeginDocument{%
LetLtxMacro{origref}{ref}
LetLtxMacro{origcref}{cref}
LetLtxMacro{origCref}{Cref}
RenewDocumentCommand{ref}{s+m}{addtolor{#2}IfBooleanTF{#1}{origref*{#2}}{origref{#2}}}
RenewDocumentCommand{Cref}{s+m}{addtolor{#2}IfBooleanTF{#1}{origCref*{#2}}{origCref{#2}}}
RenewDocumentCommand{cref}{s+m}{addtolor{#2}IfBooleanTF{#1}{origcref*{#2}}{origcref{#2}}}
}
AtEndDocument{writelistofreferences}
usepackage{blindtext}
begin{document}
trackonlylabeltypes{figure,table,equation}
tableofcontents
listofreferences
section{text} label{Footext}
See ref{einstein}
blindtext ref{fo} blabla ref{fi} blabla ref{th} but ref{Footext}
clearpage
blabla ref{on} blabla ref{tw}
begin{equation}
E = mc^{2} label{einstein}
end{equation}
clearpage
blindtext
section{Normal section}
See Cref{on} too and ref{fo}
Both Cref{si,se}
section{tables}
begin{table}caption{on}label{on}end{table}
begin{table}caption{tw}label{tw}end{table}
begin{table}caption{th}label{th}end{table}
begin{table}caption{fo}label{fo}end{table}
begin{table}caption{fi}label{fi}end{table}
begin{table}caption{si}label{si}end{table}
begin{table}caption{se}label{se}end{table}
end{document}
end{document}
add a comment |
I modified Christan Hupfer's answer to also work with cleveref references and multiple ref's, e.g. Cref{table1,table2}
. I'm posting this as a separate answer, but it's 99% based on Christian's solution:
documentclass{article}
usepackage{letltxmacro,xparse,hyperref,cleveref,crossreftools}
ExplSyntaxOn
seq_new:N g_label_names_seq
seq_new:N g_trackonly_labeltype_seq
NewDocumentCommand{trackonlylabeltypes}{+m}{%
clist_map_inline:nn {#1} {
seq_gput_right:Nn g_trackonly_labeltype_seq {##1}
}
}
NewDocumentCommand{addlabelname}{+m}{%
clist_map_inline:nn {#1} {
seq_if_in:NnF g_label_names_seq {##1} {
seq_gput_right:Nn g_label_names_seq {##1}
seq_new:c {g_label_ ##1 _seq }
}
}
}
NewDocumentCommand{addlabelpos}{+m}{%
seq_gput_right:cx {g_label_ #1 _seq } {thepage}%
}
NewDocumentCommand{addlistofrefentry}{}{%
seq_map_inline:Nn g_label_names_seq {
addtocontents{lor}{protectcontentsline{section}{cref*{##1} }{seq_use:cn {g_label_ ##1 _seq } {,space}}{}{}}
}%
}
NewDocumentCommand{CheckIfInTrackTypesT}{+m+m}{%
seq_if_in:NxT g_trackonly_labeltype_seq { crtrefcounter{#1}} {#2}%
}
NewDocumentCommand{addtolor}{+m}{%
clist_map_inline:nn {#1} {%
ifnottrackallCheckIfInTrackTypesT{##1}{addlabelname{##1}addlabelpos{##1}}elseaddlabelname{##1}addlabelpos{##1}fi%
}%
}
ExplSyntaxOff
NewDocumentCommand{writelistofreferences}{}{%
addtocontents{lor}{protectcontentsline{section}{Referenced Value}{Page(s)}{}{}addvspace{15pt}par}%
addlistofrefentry%
}
NewDocumentCommand{listofreferences}{}{%
clearpage
section*{List of reference positions}
@starttoc{lor}%
}
newififnottrackall
nottrackalltrue
AtBeginDocument{%
LetLtxMacro{origref}{ref}
LetLtxMacro{origcref}{cref}
LetLtxMacro{origCref}{Cref}
RenewDocumentCommand{ref}{s+m}{addtolor{#2}IfBooleanTF{#1}{origref*{#2}}{origref{#2}}}
RenewDocumentCommand{Cref}{s+m}{addtolor{#2}IfBooleanTF{#1}{origCref*{#2}}{origCref{#2}}}
RenewDocumentCommand{cref}{s+m}{addtolor{#2}IfBooleanTF{#1}{origcref*{#2}}{origcref{#2}}}
}
AtEndDocument{writelistofreferences}
usepackage{blindtext}
begin{document}
trackonlylabeltypes{figure,table,equation}
tableofcontents
listofreferences
section{text} label{Footext}
See ref{einstein}
blindtext ref{fo} blabla ref{fi} blabla ref{th} but ref{Footext}
clearpage
blabla ref{on} blabla ref{tw}
begin{equation}
E = mc^{2} label{einstein}
end{equation}
clearpage
blindtext
section{Normal section}
See Cref{on} too and ref{fo}
Both Cref{si,se}
section{tables}
begin{table}caption{on}label{on}end{table}
begin{table}caption{tw}label{tw}end{table}
begin{table}caption{th}label{th}end{table}
begin{table}caption{fo}label{fo}end{table}
begin{table}caption{fi}label{fi}end{table}
begin{table}caption{si}label{si}end{table}
begin{table}caption{se}label{se}end{table}
end{document}
end{document}
add a comment |
I modified Christan Hupfer's answer to also work with cleveref references and multiple ref's, e.g. Cref{table1,table2}
. I'm posting this as a separate answer, but it's 99% based on Christian's solution:
documentclass{article}
usepackage{letltxmacro,xparse,hyperref,cleveref,crossreftools}
ExplSyntaxOn
seq_new:N g_label_names_seq
seq_new:N g_trackonly_labeltype_seq
NewDocumentCommand{trackonlylabeltypes}{+m}{%
clist_map_inline:nn {#1} {
seq_gput_right:Nn g_trackonly_labeltype_seq {##1}
}
}
NewDocumentCommand{addlabelname}{+m}{%
clist_map_inline:nn {#1} {
seq_if_in:NnF g_label_names_seq {##1} {
seq_gput_right:Nn g_label_names_seq {##1}
seq_new:c {g_label_ ##1 _seq }
}
}
}
NewDocumentCommand{addlabelpos}{+m}{%
seq_gput_right:cx {g_label_ #1 _seq } {thepage}%
}
NewDocumentCommand{addlistofrefentry}{}{%
seq_map_inline:Nn g_label_names_seq {
addtocontents{lor}{protectcontentsline{section}{cref*{##1} }{seq_use:cn {g_label_ ##1 _seq } {,space}}{}{}}
}%
}
NewDocumentCommand{CheckIfInTrackTypesT}{+m+m}{%
seq_if_in:NxT g_trackonly_labeltype_seq { crtrefcounter{#1}} {#2}%
}
NewDocumentCommand{addtolor}{+m}{%
clist_map_inline:nn {#1} {%
ifnottrackallCheckIfInTrackTypesT{##1}{addlabelname{##1}addlabelpos{##1}}elseaddlabelname{##1}addlabelpos{##1}fi%
}%
}
ExplSyntaxOff
NewDocumentCommand{writelistofreferences}{}{%
addtocontents{lor}{protectcontentsline{section}{Referenced Value}{Page(s)}{}{}addvspace{15pt}par}%
addlistofrefentry%
}
NewDocumentCommand{listofreferences}{}{%
clearpage
section*{List of reference positions}
@starttoc{lor}%
}
newififnottrackall
nottrackalltrue
AtBeginDocument{%
LetLtxMacro{origref}{ref}
LetLtxMacro{origcref}{cref}
LetLtxMacro{origCref}{Cref}
RenewDocumentCommand{ref}{s+m}{addtolor{#2}IfBooleanTF{#1}{origref*{#2}}{origref{#2}}}
RenewDocumentCommand{Cref}{s+m}{addtolor{#2}IfBooleanTF{#1}{origCref*{#2}}{origCref{#2}}}
RenewDocumentCommand{cref}{s+m}{addtolor{#2}IfBooleanTF{#1}{origcref*{#2}}{origcref{#2}}}
}
AtEndDocument{writelistofreferences}
usepackage{blindtext}
begin{document}
trackonlylabeltypes{figure,table,equation}
tableofcontents
listofreferences
section{text} label{Footext}
See ref{einstein}
blindtext ref{fo} blabla ref{fi} blabla ref{th} but ref{Footext}
clearpage
blabla ref{on} blabla ref{tw}
begin{equation}
E = mc^{2} label{einstein}
end{equation}
clearpage
blindtext
section{Normal section}
See Cref{on} too and ref{fo}
Both Cref{si,se}
section{tables}
begin{table}caption{on}label{on}end{table}
begin{table}caption{tw}label{tw}end{table}
begin{table}caption{th}label{th}end{table}
begin{table}caption{fo}label{fo}end{table}
begin{table}caption{fi}label{fi}end{table}
begin{table}caption{si}label{si}end{table}
begin{table}caption{se}label{se}end{table}
end{document}
end{document}
I modified Christan Hupfer's answer to also work with cleveref references and multiple ref's, e.g. Cref{table1,table2}
. I'm posting this as a separate answer, but it's 99% based on Christian's solution:
documentclass{article}
usepackage{letltxmacro,xparse,hyperref,cleveref,crossreftools}
ExplSyntaxOn
seq_new:N g_label_names_seq
seq_new:N g_trackonly_labeltype_seq
NewDocumentCommand{trackonlylabeltypes}{+m}{%
clist_map_inline:nn {#1} {
seq_gput_right:Nn g_trackonly_labeltype_seq {##1}
}
}
NewDocumentCommand{addlabelname}{+m}{%
clist_map_inline:nn {#1} {
seq_if_in:NnF g_label_names_seq {##1} {
seq_gput_right:Nn g_label_names_seq {##1}
seq_new:c {g_label_ ##1 _seq }
}
}
}
NewDocumentCommand{addlabelpos}{+m}{%
seq_gput_right:cx {g_label_ #1 _seq } {thepage}%
}
NewDocumentCommand{addlistofrefentry}{}{%
seq_map_inline:Nn g_label_names_seq {
addtocontents{lor}{protectcontentsline{section}{cref*{##1} }{seq_use:cn {g_label_ ##1 _seq } {,space}}{}{}}
}%
}
NewDocumentCommand{CheckIfInTrackTypesT}{+m+m}{%
seq_if_in:NxT g_trackonly_labeltype_seq { crtrefcounter{#1}} {#2}%
}
NewDocumentCommand{addtolor}{+m}{%
clist_map_inline:nn {#1} {%
ifnottrackallCheckIfInTrackTypesT{##1}{addlabelname{##1}addlabelpos{##1}}elseaddlabelname{##1}addlabelpos{##1}fi%
}%
}
ExplSyntaxOff
NewDocumentCommand{writelistofreferences}{}{%
addtocontents{lor}{protectcontentsline{section}{Referenced Value}{Page(s)}{}{}addvspace{15pt}par}%
addlistofrefentry%
}
NewDocumentCommand{listofreferences}{}{%
clearpage
section*{List of reference positions}
@starttoc{lor}%
}
newififnottrackall
nottrackalltrue
AtBeginDocument{%
LetLtxMacro{origref}{ref}
LetLtxMacro{origcref}{cref}
LetLtxMacro{origCref}{Cref}
RenewDocumentCommand{ref}{s+m}{addtolor{#2}IfBooleanTF{#1}{origref*{#2}}{origref{#2}}}
RenewDocumentCommand{Cref}{s+m}{addtolor{#2}IfBooleanTF{#1}{origCref*{#2}}{origCref{#2}}}
RenewDocumentCommand{cref}{s+m}{addtolor{#2}IfBooleanTF{#1}{origcref*{#2}}{origcref{#2}}}
}
AtEndDocument{writelistofreferences}
usepackage{blindtext}
begin{document}
trackonlylabeltypes{figure,table,equation}
tableofcontents
listofreferences
section{text} label{Footext}
See ref{einstein}
blindtext ref{fo} blabla ref{fi} blabla ref{th} but ref{Footext}
clearpage
blabla ref{on} blabla ref{tw}
begin{equation}
E = mc^{2} label{einstein}
end{equation}
clearpage
blindtext
section{Normal section}
See Cref{on} too and ref{fo}
Both Cref{si,se}
section{tables}
begin{table}caption{on}label{on}end{table}
begin{table}caption{tw}label{tw}end{table}
begin{table}caption{th}label{th}end{table}
begin{table}caption{fo}label{fo}end{table}
begin{table}caption{fi}label{fi}end{table}
begin{table}caption{si}label{si}end{table}
begin{table}caption{se}label{se}end{table}
end{document}
end{document}
answered Feb 7 at 13:02
sheßsheß
1,50811328
1,50811328
add a comment |
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f418102%2flist-references-to-labels-of-figures-and-tables%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I am not trying to list the tables and where they are, but the references!
– sheß
Mar 2 '18 at 13:40