Cross-referencing forth and backCustomize backref similar to WikipediaBack link all headings with respective...

What's the difference between a cart and a wagon?

Casually inserting sexuality

Did 5.25" floppies undergo a change in magnetic coating?

Can I become debt free or should I file for bankruptcy? How do I manage my debt and finances?

Replacement ford fiesta radiator has extra hose

Find the next monthly expiration date

What is the difference between throw e and throw new Exception(e)?

Multiplication via squaring and addition

How to count occurrences of Friday 13th

Why do members of Congress in committee hearings ask witnesses the same question multiple times?

Book where the good guy lives backwards through time and the bad guy lives forward

Is there a frame of reference in which I was born before I was conceived?

Does music exist in Panem? And if so, what kinds of music?

Are small insurances worth it

CBP Reminds Travelers to Allow 72 Hours for ESTA. Why?

When was drinking water recognized as crucial in marathon running?

Waiting for the gravy at a dinner table

Exponential growth/decay formula: what happened to the other constant of integration?

What is this waxed root vegetable?

How to deny access to SQL Server to certain login over SSMS, but allow over .Net SqlClient Data Provider

How to tighten battery clamp?

Must a tritone substitution use a dominant seventh chord?

Is my plan for fixing my water heater leak bad?

Where is this triangular-shaped space station from?



Cross-referencing forth and back


Customize backref similar to WikipediaBack link all headings with respective TOC entrycustom counter and cross-referencinghyperref and cross-referencingFootnotes, Cross-Referencing and UpdatingCross-referencing specific wordsAppendix and cross-referencingCross-referencing between chaptersCross referencing a figureCross-referencing and chemnumCross-referencing multiple itemsCross-referencing external data













2















I will try to describe my question as clear as possible. First a working example.



documentclass[french,11pt]{article}

usepackage[french]{babel}

usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{kpfonts}
usepackage{geometry}
geometry{ a4paper, total={170mm,257mm}, left=20mm, top=20mm}
usepackage{blindtext}

setlength{parskip}{1.2ex} setlength{parindent}{0em} clubpenalty = 10000 widowpenalty = 10000

usepackage{graphicx,bm,url, amsfonts, latexsym, verbatim, xspace, setspace,mathrsfs,marvosym,wasysym,amsmath, amssymb}
usepackage{caption}
usepackage[caption=false]{subfig}
usepackage{epstopdf}

usepackage[colorlinks=true, linkcolor=red, urlcolor=blue, pdftitle={article}, pdfauthor={DSA}]{hyperref}

usepackage{authblk}

begin{document}

title{BlaBlaBla} author[,1]{Dimitriosthanks{texttt{url{dimitrios.@X.fr}}}} %

date{}

clearpagemaketitle thispagestyle{empty}

begin{itemize}
item blindtext

See reference ref{foo3}.
item blindtext

See reference ref{foo1}.

item blindtext

See reference ref{foo2}.
end{itemize}

newpage

blindtext

begin{enumerate}
itemlabel{foo1} textbf{The foo1 reference}
itemlabel{foo2} blindtext

textbf{The foo2 reference}

itemlabel{foo3} textbf{The foo3 reference}.
end{enumerate}


end{document}


When I click to the link, I move to the associated reference. What I want to achieve is by clicking to an small triangle or a vertical-point-upwards arrow next to the reference to move backwards to the text that the link is. That is, like the forth-and-back effect that wikipedia articles have (see Figure below).



enter image description here










share|improve this question

























  • If you are looking for a bibliography solution and can use biblatex you could have a look at tex.stackexchange.com/q/396713/35864.

    – moewe
    14 hours ago











  • @moewe Thanks, but I don't want a bibliography solution. It was just for provide insight to I want to achieve that I include the image from wikipedia. Sorry for the misunderstanding.

    – dimitris
    14 hours ago











  • This is a bibliographies - related question and not about the cross-referencing between documents or within section/equation numbers. The backref option of hyperref should do what you request

    – Christian Hupfer
    14 hours ago













  • @ChristianHupfer See my comment above. (Thanks for your feedback).

    – dimitris
    14 hours ago











  • @ChristianHupfer I rolled back your edit, because the OP confirmed that while the example screenshot was of a bibliography, the intended use case is not a backref for cite but for the normal label-ref mechanism.

    – moewe
    12 hours ago
















2















I will try to describe my question as clear as possible. First a working example.



documentclass[french,11pt]{article}

usepackage[french]{babel}

usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{kpfonts}
usepackage{geometry}
geometry{ a4paper, total={170mm,257mm}, left=20mm, top=20mm}
usepackage{blindtext}

setlength{parskip}{1.2ex} setlength{parindent}{0em} clubpenalty = 10000 widowpenalty = 10000

usepackage{graphicx,bm,url, amsfonts, latexsym, verbatim, xspace, setspace,mathrsfs,marvosym,wasysym,amsmath, amssymb}
usepackage{caption}
usepackage[caption=false]{subfig}
usepackage{epstopdf}

usepackage[colorlinks=true, linkcolor=red, urlcolor=blue, pdftitle={article}, pdfauthor={DSA}]{hyperref}

usepackage{authblk}

begin{document}

title{BlaBlaBla} author[,1]{Dimitriosthanks{texttt{url{dimitrios.@X.fr}}}} %

date{}

clearpagemaketitle thispagestyle{empty}

begin{itemize}
item blindtext

See reference ref{foo3}.
item blindtext

See reference ref{foo1}.

item blindtext

See reference ref{foo2}.
end{itemize}

newpage

blindtext

begin{enumerate}
itemlabel{foo1} textbf{The foo1 reference}
itemlabel{foo2} blindtext

textbf{The foo2 reference}

itemlabel{foo3} textbf{The foo3 reference}.
end{enumerate}


end{document}


When I click to the link, I move to the associated reference. What I want to achieve is by clicking to an small triangle or a vertical-point-upwards arrow next to the reference to move backwards to the text that the link is. That is, like the forth-and-back effect that wikipedia articles have (see Figure below).



enter image description here










share|improve this question

























  • If you are looking for a bibliography solution and can use biblatex you could have a look at tex.stackexchange.com/q/396713/35864.

    – moewe
    14 hours ago











  • @moewe Thanks, but I don't want a bibliography solution. It was just for provide insight to I want to achieve that I include the image from wikipedia. Sorry for the misunderstanding.

    – dimitris
    14 hours ago











  • This is a bibliographies - related question and not about the cross-referencing between documents or within section/equation numbers. The backref option of hyperref should do what you request

    – Christian Hupfer
    14 hours ago













  • @ChristianHupfer See my comment above. (Thanks for your feedback).

    – dimitris
    14 hours ago











  • @ChristianHupfer I rolled back your edit, because the OP confirmed that while the example screenshot was of a bibliography, the intended use case is not a backref for cite but for the normal label-ref mechanism.

    – moewe
    12 hours ago














2












2








2








I will try to describe my question as clear as possible. First a working example.



documentclass[french,11pt]{article}

usepackage[french]{babel}

usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{kpfonts}
usepackage{geometry}
geometry{ a4paper, total={170mm,257mm}, left=20mm, top=20mm}
usepackage{blindtext}

setlength{parskip}{1.2ex} setlength{parindent}{0em} clubpenalty = 10000 widowpenalty = 10000

usepackage{graphicx,bm,url, amsfonts, latexsym, verbatim, xspace, setspace,mathrsfs,marvosym,wasysym,amsmath, amssymb}
usepackage{caption}
usepackage[caption=false]{subfig}
usepackage{epstopdf}

usepackage[colorlinks=true, linkcolor=red, urlcolor=blue, pdftitle={article}, pdfauthor={DSA}]{hyperref}

usepackage{authblk}

begin{document}

title{BlaBlaBla} author[,1]{Dimitriosthanks{texttt{url{dimitrios.@X.fr}}}} %

date{}

clearpagemaketitle thispagestyle{empty}

begin{itemize}
item blindtext

See reference ref{foo3}.
item blindtext

See reference ref{foo1}.

item blindtext

See reference ref{foo2}.
end{itemize}

newpage

blindtext

begin{enumerate}
itemlabel{foo1} textbf{The foo1 reference}
itemlabel{foo2} blindtext

textbf{The foo2 reference}

itemlabel{foo3} textbf{The foo3 reference}.
end{enumerate}


end{document}


When I click to the link, I move to the associated reference. What I want to achieve is by clicking to an small triangle or a vertical-point-upwards arrow next to the reference to move backwards to the text that the link is. That is, like the forth-and-back effect that wikipedia articles have (see Figure below).



enter image description here










share|improve this question
















I will try to describe my question as clear as possible. First a working example.



documentclass[french,11pt]{article}

usepackage[french]{babel}

usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{kpfonts}
usepackage{geometry}
geometry{ a4paper, total={170mm,257mm}, left=20mm, top=20mm}
usepackage{blindtext}

setlength{parskip}{1.2ex} setlength{parindent}{0em} clubpenalty = 10000 widowpenalty = 10000

usepackage{graphicx,bm,url, amsfonts, latexsym, verbatim, xspace, setspace,mathrsfs,marvosym,wasysym,amsmath, amssymb}
usepackage{caption}
usepackage[caption=false]{subfig}
usepackage{epstopdf}

usepackage[colorlinks=true, linkcolor=red, urlcolor=blue, pdftitle={article}, pdfauthor={DSA}]{hyperref}

usepackage{authblk}

begin{document}

title{BlaBlaBla} author[,1]{Dimitriosthanks{texttt{url{dimitrios.@X.fr}}}} %

date{}

clearpagemaketitle thispagestyle{empty}

begin{itemize}
item blindtext

See reference ref{foo3}.
item blindtext

See reference ref{foo1}.

item blindtext

See reference ref{foo2}.
end{itemize}

newpage

blindtext

begin{enumerate}
itemlabel{foo1} textbf{The foo1 reference}
itemlabel{foo2} blindtext

textbf{The foo2 reference}

itemlabel{foo3} textbf{The foo3 reference}.
end{enumerate}


end{document}


When I click to the link, I move to the associated reference. What I want to achieve is by clicking to an small triangle or a vertical-point-upwards arrow next to the reference to move backwards to the text that the link is. That is, like the forth-and-back effect that wikipedia articles have (see Figure below).



enter image description here







cross-referencing






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 12 hours ago









moewe

92.6k10115351




92.6k10115351










asked 14 hours ago









dimitrisdimitris

354112




354112













  • If you are looking for a bibliography solution and can use biblatex you could have a look at tex.stackexchange.com/q/396713/35864.

    – moewe
    14 hours ago











  • @moewe Thanks, but I don't want a bibliography solution. It was just for provide insight to I want to achieve that I include the image from wikipedia. Sorry for the misunderstanding.

    – dimitris
    14 hours ago











  • This is a bibliographies - related question and not about the cross-referencing between documents or within section/equation numbers. The backref option of hyperref should do what you request

    – Christian Hupfer
    14 hours ago













  • @ChristianHupfer See my comment above. (Thanks for your feedback).

    – dimitris
    14 hours ago











  • @ChristianHupfer I rolled back your edit, because the OP confirmed that while the example screenshot was of a bibliography, the intended use case is not a backref for cite but for the normal label-ref mechanism.

    – moewe
    12 hours ago



















  • If you are looking for a bibliography solution and can use biblatex you could have a look at tex.stackexchange.com/q/396713/35864.

    – moewe
    14 hours ago











  • @moewe Thanks, but I don't want a bibliography solution. It was just for provide insight to I want to achieve that I include the image from wikipedia. Sorry for the misunderstanding.

    – dimitris
    14 hours ago











  • This is a bibliographies - related question and not about the cross-referencing between documents or within section/equation numbers. The backref option of hyperref should do what you request

    – Christian Hupfer
    14 hours ago













  • @ChristianHupfer See my comment above. (Thanks for your feedback).

    – dimitris
    14 hours ago











  • @ChristianHupfer I rolled back your edit, because the OP confirmed that while the example screenshot was of a bibliography, the intended use case is not a backref for cite but for the normal label-ref mechanism.

    – moewe
    12 hours ago

















If you are looking for a bibliography solution and can use biblatex you could have a look at tex.stackexchange.com/q/396713/35864.

– moewe
14 hours ago





If you are looking for a bibliography solution and can use biblatex you could have a look at tex.stackexchange.com/q/396713/35864.

– moewe
14 hours ago













@moewe Thanks, but I don't want a bibliography solution. It was just for provide insight to I want to achieve that I include the image from wikipedia. Sorry for the misunderstanding.

– dimitris
14 hours ago





@moewe Thanks, but I don't want a bibliography solution. It was just for provide insight to I want to achieve that I include the image from wikipedia. Sorry for the misunderstanding.

– dimitris
14 hours ago













This is a bibliographies - related question and not about the cross-referencing between documents or within section/equation numbers. The backref option of hyperref should do what you request

– Christian Hupfer
14 hours ago







This is a bibliographies - related question and not about the cross-referencing between documents or within section/equation numbers. The backref option of hyperref should do what you request

– Christian Hupfer
14 hours ago















@ChristianHupfer See my comment above. (Thanks for your feedback).

– dimitris
14 hours ago





@ChristianHupfer See my comment above. (Thanks for your feedback).

– dimitris
14 hours ago













@ChristianHupfer I rolled back your edit, because the OP confirmed that while the example screenshot was of a bibliography, the intended use case is not a backref for cite but for the normal label-ref mechanism.

– moewe
12 hours ago





@ChristianHupfer I rolled back your edit, because the OP confirmed that while the example screenshot was of a bibliography, the intended use case is not a backref for cite but for the normal label-ref mechanism.

– moewe
12 hours ago










2 Answers
2






active

oldest

votes


















3














Here is an etoolbox-based implementation of a backref-able ref.



Use backrefref{<label>} to create a reference to a <label> that can will be linked back to. Use backreflabel{<label>} to set a label and output the backref marks. Note that backreflabel should be called directly where the <label> anchor attaches. Otherwise you may end up with incorrect link targets.



The solution works by writing info to the .aux file, so it may will need at least two LaTeX runs.



documentclass[french,11pt]{article}
usepackage{babel}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}

usepackage{blindtext}

usepackage{etoolbox}

usepackage[colorlinks]{hyperref}

newcommand*{backrefmarker}{$uparrow$}
newcommand*{backrefmultformat}{textsuperscript}

makeatletter
newcommand*{br@currlabels}{}
newcommand*{br@linklabels}{}

newcommand*{backrefref}[1]{%
listgadd{br@currlabels}{#1}%
ifltxcounter{br@curr@#1}
{}
{newcounter{br@curr@#1}
csgdef{thebr@curr@#1}{alph{br@curr@#1}}}%
{refstepcounter{br@curr@#1}%
label{br@#1@thevalue{br@curr@#1}}}%
ref{#1}}


newcommand*{backreflabel}[1]{%
label{#1}%
backreflabel@display{#1}}

newcommand*{backreflabel@display}[1]{%
ifltxcounter{br@link@#1}
{ifnumequal{value{br@link@#1}}{1}
{hyperref[br@#1@1]{backrefmarker}}
{ifnumgreater{value{br@link@#1}}{1}
{backrefmarker
backrefmultformat{backreflabel@display@loop{#1}}}
{textbf{??}}}}
{textbf{??}}}

newcounter{br@label@loop}

newcommand*{backreflabel@display@loop}[1]{%
setcounter{br@label@loop}{0}%
whileboolexpr{test {ifnumless{value{br@label@loop}}{value{br@link@#1}}}}
{stepcounter{br@label@loop}%
ref{br@#1@thevalue{br@label@loop}}}}


newcommand*{br@aux@readlabel}[2]{%
ifinlist{#1}{br@linklabels}
{}
{listgadd{br@linklabels}{#1}}%
ifltxcounter{br@link@#1}
{}
{newcounter{br@link@#1}}%
setcounter{br@link@#1}{#2}}

newcommand*{br@writelabel}[1]{%
ifltxcounter{br@link@#1}
{ifnumequal{value{br@curr@#1}}{value{br@link@#1}}
{}
{@latex@warning@no@line{%
Label(s) may have changed.
Rerun to get cross-references right}}}
{@latex@warning@no@line{%
Label(s) may have changed.
Rerun to get cross-references right}}%
immediatewrite@mainaux{stringbr@aux@readlabel{#1}{thevalue{br@curr@#1}}}}

AtEndDocument{%
forlistloop{br@writelabel}{br@currlabels}}
makeatother

begin{document}

begin{itemize}
item blindtext

See reference backrefref{foo3}.
item blindtext

See reference backrefref{foo1}.

item blindtext

See reference backrefref{foo2}.
end{itemize}

clearpage

blindtext

begin{enumerate}
itembackreflabel{foo1} textbf{The foo1 reference}
itembackreflabel{foo2} blindtext

textbf{The foo2 reference}

itembackreflabel{foo3} textbf{The foo3 reference}.
end{enumerate}

clearpage

See reference backrefref{foo1}.
See reference backrefref{foo2}.

clearpage

See reference backrefref{foo2}.
end{document}


Wikipedia-like backrefs for <code>ref</code>--<code>label</code>






share|improve this answer
























  • Wow! Exactly what I wanted it! Thank you very much! Bravo!

    – dimitris
    12 hours ago



















0














This is more an extended comment than a real answer.



I agree with previous comments for the easy way to do that with backref package or more precisely the backref option passed to hyperref at load time. But it could be interesting to extend it to label and not only to cite. In my answer to question Back link all headings with respective TOC entry
I have provided a solution that could be used as a starting point.



But this raises a problem of ambiguity : the reference to a label is unique, but the reverse direction is not, as you could reference a single label several times.



Furthermore, the future references are not known at creation of the label, and even if you decide to fix the ambiguity by choosing to back link to last (or first) reference, you will have to write it to .aux file and read it back at the next compilation, which becomes much more involved.



If you really need that, and left me a delay of a few days, I could extend the above quoted solution to labels.



By the way the requested feature is implemented out of the box in several popular pdf viewers, as they can keep a trace of browsing history, thus lifting the ambiguity problem.






share|improve this answer
























  • Thanks for this answer. I understand from your words and the comments that this is not trivial (as I thought:-)!). Is there an easier way to achieve such a forth-and-back behavior? I saw with backref option. Is there an example somewhere ? And the upwards arrow in wiki manner?

    – dimitris
    13 hours ago











  • What do you mean by "an easier way" ? Is the pdf viewer feature not sufficient ? For which subject are you looking for an example ?

    – Jhor
    13 hours ago











  • I apologize for not being clear. If my understanding is correct the easiest way to achieve the requested feature with a common pdf viewer? backref option was a couple of times mentioned. Where can I found an example of its usage in the current context? Thanks again for your time!

    – dimitris
    13 hours ago











  • Sorry but backref can not help "in the current context" as it works only for bibliography. It produces beside each bibliogaphic item the list of section numbers (or pages if you use pagebackref) where the reference has been cited.

    – Jhor
    13 hours ago











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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f477661%2fcross-referencing-forth-and-back%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









3














Here is an etoolbox-based implementation of a backref-able ref.



Use backrefref{<label>} to create a reference to a <label> that can will be linked back to. Use backreflabel{<label>} to set a label and output the backref marks. Note that backreflabel should be called directly where the <label> anchor attaches. Otherwise you may end up with incorrect link targets.



The solution works by writing info to the .aux file, so it may will need at least two LaTeX runs.



documentclass[french,11pt]{article}
usepackage{babel}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}

usepackage{blindtext}

usepackage{etoolbox}

usepackage[colorlinks]{hyperref}

newcommand*{backrefmarker}{$uparrow$}
newcommand*{backrefmultformat}{textsuperscript}

makeatletter
newcommand*{br@currlabels}{}
newcommand*{br@linklabels}{}

newcommand*{backrefref}[1]{%
listgadd{br@currlabels}{#1}%
ifltxcounter{br@curr@#1}
{}
{newcounter{br@curr@#1}
csgdef{thebr@curr@#1}{alph{br@curr@#1}}}%
{refstepcounter{br@curr@#1}%
label{br@#1@thevalue{br@curr@#1}}}%
ref{#1}}


newcommand*{backreflabel}[1]{%
label{#1}%
backreflabel@display{#1}}

newcommand*{backreflabel@display}[1]{%
ifltxcounter{br@link@#1}
{ifnumequal{value{br@link@#1}}{1}
{hyperref[br@#1@1]{backrefmarker}}
{ifnumgreater{value{br@link@#1}}{1}
{backrefmarker
backrefmultformat{backreflabel@display@loop{#1}}}
{textbf{??}}}}
{textbf{??}}}

newcounter{br@label@loop}

newcommand*{backreflabel@display@loop}[1]{%
setcounter{br@label@loop}{0}%
whileboolexpr{test {ifnumless{value{br@label@loop}}{value{br@link@#1}}}}
{stepcounter{br@label@loop}%
ref{br@#1@thevalue{br@label@loop}}}}


newcommand*{br@aux@readlabel}[2]{%
ifinlist{#1}{br@linklabels}
{}
{listgadd{br@linklabels}{#1}}%
ifltxcounter{br@link@#1}
{}
{newcounter{br@link@#1}}%
setcounter{br@link@#1}{#2}}

newcommand*{br@writelabel}[1]{%
ifltxcounter{br@link@#1}
{ifnumequal{value{br@curr@#1}}{value{br@link@#1}}
{}
{@latex@warning@no@line{%
Label(s) may have changed.
Rerun to get cross-references right}}}
{@latex@warning@no@line{%
Label(s) may have changed.
Rerun to get cross-references right}}%
immediatewrite@mainaux{stringbr@aux@readlabel{#1}{thevalue{br@curr@#1}}}}

AtEndDocument{%
forlistloop{br@writelabel}{br@currlabels}}
makeatother

begin{document}

begin{itemize}
item blindtext

See reference backrefref{foo3}.
item blindtext

See reference backrefref{foo1}.

item blindtext

See reference backrefref{foo2}.
end{itemize}

clearpage

blindtext

begin{enumerate}
itembackreflabel{foo1} textbf{The foo1 reference}
itembackreflabel{foo2} blindtext

textbf{The foo2 reference}

itembackreflabel{foo3} textbf{The foo3 reference}.
end{enumerate}

clearpage

See reference backrefref{foo1}.
See reference backrefref{foo2}.

clearpage

See reference backrefref{foo2}.
end{document}


Wikipedia-like backrefs for <code>ref</code>--<code>label</code>






share|improve this answer
























  • Wow! Exactly what I wanted it! Thank you very much! Bravo!

    – dimitris
    12 hours ago
















3














Here is an etoolbox-based implementation of a backref-able ref.



Use backrefref{<label>} to create a reference to a <label> that can will be linked back to. Use backreflabel{<label>} to set a label and output the backref marks. Note that backreflabel should be called directly where the <label> anchor attaches. Otherwise you may end up with incorrect link targets.



The solution works by writing info to the .aux file, so it may will need at least two LaTeX runs.



documentclass[french,11pt]{article}
usepackage{babel}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}

usepackage{blindtext}

usepackage{etoolbox}

usepackage[colorlinks]{hyperref}

newcommand*{backrefmarker}{$uparrow$}
newcommand*{backrefmultformat}{textsuperscript}

makeatletter
newcommand*{br@currlabels}{}
newcommand*{br@linklabels}{}

newcommand*{backrefref}[1]{%
listgadd{br@currlabels}{#1}%
ifltxcounter{br@curr@#1}
{}
{newcounter{br@curr@#1}
csgdef{thebr@curr@#1}{alph{br@curr@#1}}}%
{refstepcounter{br@curr@#1}%
label{br@#1@thevalue{br@curr@#1}}}%
ref{#1}}


newcommand*{backreflabel}[1]{%
label{#1}%
backreflabel@display{#1}}

newcommand*{backreflabel@display}[1]{%
ifltxcounter{br@link@#1}
{ifnumequal{value{br@link@#1}}{1}
{hyperref[br@#1@1]{backrefmarker}}
{ifnumgreater{value{br@link@#1}}{1}
{backrefmarker
backrefmultformat{backreflabel@display@loop{#1}}}
{textbf{??}}}}
{textbf{??}}}

newcounter{br@label@loop}

newcommand*{backreflabel@display@loop}[1]{%
setcounter{br@label@loop}{0}%
whileboolexpr{test {ifnumless{value{br@label@loop}}{value{br@link@#1}}}}
{stepcounter{br@label@loop}%
ref{br@#1@thevalue{br@label@loop}}}}


newcommand*{br@aux@readlabel}[2]{%
ifinlist{#1}{br@linklabels}
{}
{listgadd{br@linklabels}{#1}}%
ifltxcounter{br@link@#1}
{}
{newcounter{br@link@#1}}%
setcounter{br@link@#1}{#2}}

newcommand*{br@writelabel}[1]{%
ifltxcounter{br@link@#1}
{ifnumequal{value{br@curr@#1}}{value{br@link@#1}}
{}
{@latex@warning@no@line{%
Label(s) may have changed.
Rerun to get cross-references right}}}
{@latex@warning@no@line{%
Label(s) may have changed.
Rerun to get cross-references right}}%
immediatewrite@mainaux{stringbr@aux@readlabel{#1}{thevalue{br@curr@#1}}}}

AtEndDocument{%
forlistloop{br@writelabel}{br@currlabels}}
makeatother

begin{document}

begin{itemize}
item blindtext

See reference backrefref{foo3}.
item blindtext

See reference backrefref{foo1}.

item blindtext

See reference backrefref{foo2}.
end{itemize}

clearpage

blindtext

begin{enumerate}
itembackreflabel{foo1} textbf{The foo1 reference}
itembackreflabel{foo2} blindtext

textbf{The foo2 reference}

itembackreflabel{foo3} textbf{The foo3 reference}.
end{enumerate}

clearpage

See reference backrefref{foo1}.
See reference backrefref{foo2}.

clearpage

See reference backrefref{foo2}.
end{document}


Wikipedia-like backrefs for <code>ref</code>--<code>label</code>






share|improve this answer
























  • Wow! Exactly what I wanted it! Thank you very much! Bravo!

    – dimitris
    12 hours ago














3












3








3







Here is an etoolbox-based implementation of a backref-able ref.



Use backrefref{<label>} to create a reference to a <label> that can will be linked back to. Use backreflabel{<label>} to set a label and output the backref marks. Note that backreflabel should be called directly where the <label> anchor attaches. Otherwise you may end up with incorrect link targets.



The solution works by writing info to the .aux file, so it may will need at least two LaTeX runs.



documentclass[french,11pt]{article}
usepackage{babel}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}

usepackage{blindtext}

usepackage{etoolbox}

usepackage[colorlinks]{hyperref}

newcommand*{backrefmarker}{$uparrow$}
newcommand*{backrefmultformat}{textsuperscript}

makeatletter
newcommand*{br@currlabels}{}
newcommand*{br@linklabels}{}

newcommand*{backrefref}[1]{%
listgadd{br@currlabels}{#1}%
ifltxcounter{br@curr@#1}
{}
{newcounter{br@curr@#1}
csgdef{thebr@curr@#1}{alph{br@curr@#1}}}%
{refstepcounter{br@curr@#1}%
label{br@#1@thevalue{br@curr@#1}}}%
ref{#1}}


newcommand*{backreflabel}[1]{%
label{#1}%
backreflabel@display{#1}}

newcommand*{backreflabel@display}[1]{%
ifltxcounter{br@link@#1}
{ifnumequal{value{br@link@#1}}{1}
{hyperref[br@#1@1]{backrefmarker}}
{ifnumgreater{value{br@link@#1}}{1}
{backrefmarker
backrefmultformat{backreflabel@display@loop{#1}}}
{textbf{??}}}}
{textbf{??}}}

newcounter{br@label@loop}

newcommand*{backreflabel@display@loop}[1]{%
setcounter{br@label@loop}{0}%
whileboolexpr{test {ifnumless{value{br@label@loop}}{value{br@link@#1}}}}
{stepcounter{br@label@loop}%
ref{br@#1@thevalue{br@label@loop}}}}


newcommand*{br@aux@readlabel}[2]{%
ifinlist{#1}{br@linklabels}
{}
{listgadd{br@linklabels}{#1}}%
ifltxcounter{br@link@#1}
{}
{newcounter{br@link@#1}}%
setcounter{br@link@#1}{#2}}

newcommand*{br@writelabel}[1]{%
ifltxcounter{br@link@#1}
{ifnumequal{value{br@curr@#1}}{value{br@link@#1}}
{}
{@latex@warning@no@line{%
Label(s) may have changed.
Rerun to get cross-references right}}}
{@latex@warning@no@line{%
Label(s) may have changed.
Rerun to get cross-references right}}%
immediatewrite@mainaux{stringbr@aux@readlabel{#1}{thevalue{br@curr@#1}}}}

AtEndDocument{%
forlistloop{br@writelabel}{br@currlabels}}
makeatother

begin{document}

begin{itemize}
item blindtext

See reference backrefref{foo3}.
item blindtext

See reference backrefref{foo1}.

item blindtext

See reference backrefref{foo2}.
end{itemize}

clearpage

blindtext

begin{enumerate}
itembackreflabel{foo1} textbf{The foo1 reference}
itembackreflabel{foo2} blindtext

textbf{The foo2 reference}

itembackreflabel{foo3} textbf{The foo3 reference}.
end{enumerate}

clearpage

See reference backrefref{foo1}.
See reference backrefref{foo2}.

clearpage

See reference backrefref{foo2}.
end{document}


Wikipedia-like backrefs for <code>ref</code>--<code>label</code>






share|improve this answer













Here is an etoolbox-based implementation of a backref-able ref.



Use backrefref{<label>} to create a reference to a <label> that can will be linked back to. Use backreflabel{<label>} to set a label and output the backref marks. Note that backreflabel should be called directly where the <label> anchor attaches. Otherwise you may end up with incorrect link targets.



The solution works by writing info to the .aux file, so it may will need at least two LaTeX runs.



documentclass[french,11pt]{article}
usepackage{babel}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}

usepackage{blindtext}

usepackage{etoolbox}

usepackage[colorlinks]{hyperref}

newcommand*{backrefmarker}{$uparrow$}
newcommand*{backrefmultformat}{textsuperscript}

makeatletter
newcommand*{br@currlabels}{}
newcommand*{br@linklabels}{}

newcommand*{backrefref}[1]{%
listgadd{br@currlabels}{#1}%
ifltxcounter{br@curr@#1}
{}
{newcounter{br@curr@#1}
csgdef{thebr@curr@#1}{alph{br@curr@#1}}}%
{refstepcounter{br@curr@#1}%
label{br@#1@thevalue{br@curr@#1}}}%
ref{#1}}


newcommand*{backreflabel}[1]{%
label{#1}%
backreflabel@display{#1}}

newcommand*{backreflabel@display}[1]{%
ifltxcounter{br@link@#1}
{ifnumequal{value{br@link@#1}}{1}
{hyperref[br@#1@1]{backrefmarker}}
{ifnumgreater{value{br@link@#1}}{1}
{backrefmarker
backrefmultformat{backreflabel@display@loop{#1}}}
{textbf{??}}}}
{textbf{??}}}

newcounter{br@label@loop}

newcommand*{backreflabel@display@loop}[1]{%
setcounter{br@label@loop}{0}%
whileboolexpr{test {ifnumless{value{br@label@loop}}{value{br@link@#1}}}}
{stepcounter{br@label@loop}%
ref{br@#1@thevalue{br@label@loop}}}}


newcommand*{br@aux@readlabel}[2]{%
ifinlist{#1}{br@linklabels}
{}
{listgadd{br@linklabels}{#1}}%
ifltxcounter{br@link@#1}
{}
{newcounter{br@link@#1}}%
setcounter{br@link@#1}{#2}}

newcommand*{br@writelabel}[1]{%
ifltxcounter{br@link@#1}
{ifnumequal{value{br@curr@#1}}{value{br@link@#1}}
{}
{@latex@warning@no@line{%
Label(s) may have changed.
Rerun to get cross-references right}}}
{@latex@warning@no@line{%
Label(s) may have changed.
Rerun to get cross-references right}}%
immediatewrite@mainaux{stringbr@aux@readlabel{#1}{thevalue{br@curr@#1}}}}

AtEndDocument{%
forlistloop{br@writelabel}{br@currlabels}}
makeatother

begin{document}

begin{itemize}
item blindtext

See reference backrefref{foo3}.
item blindtext

See reference backrefref{foo1}.

item blindtext

See reference backrefref{foo2}.
end{itemize}

clearpage

blindtext

begin{enumerate}
itembackreflabel{foo1} textbf{The foo1 reference}
itembackreflabel{foo2} blindtext

textbf{The foo2 reference}

itembackreflabel{foo3} textbf{The foo3 reference}.
end{enumerate}

clearpage

See reference backrefref{foo1}.
See reference backrefref{foo2}.

clearpage

See reference backrefref{foo2}.
end{document}


Wikipedia-like backrefs for <code>ref</code>--<code>label</code>







share|improve this answer












share|improve this answer



share|improve this answer










answered 12 hours ago









moewemoewe

92.6k10115351




92.6k10115351













  • Wow! Exactly what I wanted it! Thank you very much! Bravo!

    – dimitris
    12 hours ago



















  • Wow! Exactly what I wanted it! Thank you very much! Bravo!

    – dimitris
    12 hours ago

















Wow! Exactly what I wanted it! Thank you very much! Bravo!

– dimitris
12 hours ago





Wow! Exactly what I wanted it! Thank you very much! Bravo!

– dimitris
12 hours ago











0














This is more an extended comment than a real answer.



I agree with previous comments for the easy way to do that with backref package or more precisely the backref option passed to hyperref at load time. But it could be interesting to extend it to label and not only to cite. In my answer to question Back link all headings with respective TOC entry
I have provided a solution that could be used as a starting point.



But this raises a problem of ambiguity : the reference to a label is unique, but the reverse direction is not, as you could reference a single label several times.



Furthermore, the future references are not known at creation of the label, and even if you decide to fix the ambiguity by choosing to back link to last (or first) reference, you will have to write it to .aux file and read it back at the next compilation, which becomes much more involved.



If you really need that, and left me a delay of a few days, I could extend the above quoted solution to labels.



By the way the requested feature is implemented out of the box in several popular pdf viewers, as they can keep a trace of browsing history, thus lifting the ambiguity problem.






share|improve this answer
























  • Thanks for this answer. I understand from your words and the comments that this is not trivial (as I thought:-)!). Is there an easier way to achieve such a forth-and-back behavior? I saw with backref option. Is there an example somewhere ? And the upwards arrow in wiki manner?

    – dimitris
    13 hours ago











  • What do you mean by "an easier way" ? Is the pdf viewer feature not sufficient ? For which subject are you looking for an example ?

    – Jhor
    13 hours ago











  • I apologize for not being clear. If my understanding is correct the easiest way to achieve the requested feature with a common pdf viewer? backref option was a couple of times mentioned. Where can I found an example of its usage in the current context? Thanks again for your time!

    – dimitris
    13 hours ago











  • Sorry but backref can not help "in the current context" as it works only for bibliography. It produces beside each bibliogaphic item the list of section numbers (or pages if you use pagebackref) where the reference has been cited.

    – Jhor
    13 hours ago
















0














This is more an extended comment than a real answer.



I agree with previous comments for the easy way to do that with backref package or more precisely the backref option passed to hyperref at load time. But it could be interesting to extend it to label and not only to cite. In my answer to question Back link all headings with respective TOC entry
I have provided a solution that could be used as a starting point.



But this raises a problem of ambiguity : the reference to a label is unique, but the reverse direction is not, as you could reference a single label several times.



Furthermore, the future references are not known at creation of the label, and even if you decide to fix the ambiguity by choosing to back link to last (or first) reference, you will have to write it to .aux file and read it back at the next compilation, which becomes much more involved.



If you really need that, and left me a delay of a few days, I could extend the above quoted solution to labels.



By the way the requested feature is implemented out of the box in several popular pdf viewers, as they can keep a trace of browsing history, thus lifting the ambiguity problem.






share|improve this answer
























  • Thanks for this answer. I understand from your words and the comments that this is not trivial (as I thought:-)!). Is there an easier way to achieve such a forth-and-back behavior? I saw with backref option. Is there an example somewhere ? And the upwards arrow in wiki manner?

    – dimitris
    13 hours ago











  • What do you mean by "an easier way" ? Is the pdf viewer feature not sufficient ? For which subject are you looking for an example ?

    – Jhor
    13 hours ago











  • I apologize for not being clear. If my understanding is correct the easiest way to achieve the requested feature with a common pdf viewer? backref option was a couple of times mentioned. Where can I found an example of its usage in the current context? Thanks again for your time!

    – dimitris
    13 hours ago











  • Sorry but backref can not help "in the current context" as it works only for bibliography. It produces beside each bibliogaphic item the list of section numbers (or pages if you use pagebackref) where the reference has been cited.

    – Jhor
    13 hours ago














0












0








0







This is more an extended comment than a real answer.



I agree with previous comments for the easy way to do that with backref package or more precisely the backref option passed to hyperref at load time. But it could be interesting to extend it to label and not only to cite. In my answer to question Back link all headings with respective TOC entry
I have provided a solution that could be used as a starting point.



But this raises a problem of ambiguity : the reference to a label is unique, but the reverse direction is not, as you could reference a single label several times.



Furthermore, the future references are not known at creation of the label, and even if you decide to fix the ambiguity by choosing to back link to last (or first) reference, you will have to write it to .aux file and read it back at the next compilation, which becomes much more involved.



If you really need that, and left me a delay of a few days, I could extend the above quoted solution to labels.



By the way the requested feature is implemented out of the box in several popular pdf viewers, as they can keep a trace of browsing history, thus lifting the ambiguity problem.






share|improve this answer













This is more an extended comment than a real answer.



I agree with previous comments for the easy way to do that with backref package or more precisely the backref option passed to hyperref at load time. But it could be interesting to extend it to label and not only to cite. In my answer to question Back link all headings with respective TOC entry
I have provided a solution that could be used as a starting point.



But this raises a problem of ambiguity : the reference to a label is unique, but the reverse direction is not, as you could reference a single label several times.



Furthermore, the future references are not known at creation of the label, and even if you decide to fix the ambiguity by choosing to back link to last (or first) reference, you will have to write it to .aux file and read it back at the next compilation, which becomes much more involved.



If you really need that, and left me a delay of a few days, I could extend the above quoted solution to labels.



By the way the requested feature is implemented out of the box in several popular pdf viewers, as they can keep a trace of browsing history, thus lifting the ambiguity problem.







share|improve this answer












share|improve this answer



share|improve this answer










answered 14 hours ago









JhorJhor

2,4871114




2,4871114













  • Thanks for this answer. I understand from your words and the comments that this is not trivial (as I thought:-)!). Is there an easier way to achieve such a forth-and-back behavior? I saw with backref option. Is there an example somewhere ? And the upwards arrow in wiki manner?

    – dimitris
    13 hours ago











  • What do you mean by "an easier way" ? Is the pdf viewer feature not sufficient ? For which subject are you looking for an example ?

    – Jhor
    13 hours ago











  • I apologize for not being clear. If my understanding is correct the easiest way to achieve the requested feature with a common pdf viewer? backref option was a couple of times mentioned. Where can I found an example of its usage in the current context? Thanks again for your time!

    – dimitris
    13 hours ago











  • Sorry but backref can not help "in the current context" as it works only for bibliography. It produces beside each bibliogaphic item the list of section numbers (or pages if you use pagebackref) where the reference has been cited.

    – Jhor
    13 hours ago



















  • Thanks for this answer. I understand from your words and the comments that this is not trivial (as I thought:-)!). Is there an easier way to achieve such a forth-and-back behavior? I saw with backref option. Is there an example somewhere ? And the upwards arrow in wiki manner?

    – dimitris
    13 hours ago











  • What do you mean by "an easier way" ? Is the pdf viewer feature not sufficient ? For which subject are you looking for an example ?

    – Jhor
    13 hours ago











  • I apologize for not being clear. If my understanding is correct the easiest way to achieve the requested feature with a common pdf viewer? backref option was a couple of times mentioned. Where can I found an example of its usage in the current context? Thanks again for your time!

    – dimitris
    13 hours ago











  • Sorry but backref can not help "in the current context" as it works only for bibliography. It produces beside each bibliogaphic item the list of section numbers (or pages if you use pagebackref) where the reference has been cited.

    – Jhor
    13 hours ago

















Thanks for this answer. I understand from your words and the comments that this is not trivial (as I thought:-)!). Is there an easier way to achieve such a forth-and-back behavior? I saw with backref option. Is there an example somewhere ? And the upwards arrow in wiki manner?

– dimitris
13 hours ago





Thanks for this answer. I understand from your words and the comments that this is not trivial (as I thought:-)!). Is there an easier way to achieve such a forth-and-back behavior? I saw with backref option. Is there an example somewhere ? And the upwards arrow in wiki manner?

– dimitris
13 hours ago













What do you mean by "an easier way" ? Is the pdf viewer feature not sufficient ? For which subject are you looking for an example ?

– Jhor
13 hours ago





What do you mean by "an easier way" ? Is the pdf viewer feature not sufficient ? For which subject are you looking for an example ?

– Jhor
13 hours ago













I apologize for not being clear. If my understanding is correct the easiest way to achieve the requested feature with a common pdf viewer? backref option was a couple of times mentioned. Where can I found an example of its usage in the current context? Thanks again for your time!

– dimitris
13 hours ago





I apologize for not being clear. If my understanding is correct the easiest way to achieve the requested feature with a common pdf viewer? backref option was a couple of times mentioned. Where can I found an example of its usage in the current context? Thanks again for your time!

– dimitris
13 hours ago













Sorry but backref can not help "in the current context" as it works only for bibliography. It produces beside each bibliogaphic item the list of section numbers (or pages if you use pagebackref) where the reference has been cited.

– Jhor
13 hours ago





Sorry but backref can not help "in the current context" as it works only for bibliography. It produces beside each bibliogaphic item the list of section numbers (or pages if you use pagebackref) where the reference has been cited.

– Jhor
13 hours ago


















draft saved

draft discarded




















































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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f477661%2fcross-referencing-forth-and-back%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

El tren de la libertad Índice Antecedentes "Porque yo decido" Desarrollo de la...

Puerta de Hutt Referencias Enlaces externos Menú de navegación15°58′00″S 5°42′00″O /...

Castillo d'Acher Características Menú de navegación