Back link all headings with respective TOC entry
up vote
0
down vote
favorite
I came across a PDF which mutually links TOC entries and the headings present in the text body. It was created using Adobe Indesign. If I am reading the book and need to take a look at the TOC I can easily click the heading itself to see it in TOC. This will be a helpfull feature if content has many sub-headings. Are there any packages to achieve this functionality. Please guide.
packages links
add a comment |
up vote
0
down vote
favorite
I came across a PDF which mutually links TOC entries and the headings present in the text body. It was created using Adobe Indesign. If I am reading the book and need to take a look at the TOC I can easily click the heading itself to see it in TOC. This will be a helpfull feature if content has many sub-headings. Are there any packages to achieve this functionality. Please guide.
packages links
1
Do yiu really need it ? IMo the bookmarks created by hyperref in conjonction with pdflatex do provide already similar fonctionality, don't they?
– Jhor
yesterday
Yes I need it. It will be helpfull to see larger picture when many sub-topics are discussed. We need to create a label each time for each subheading and refer to it, becomes messy when many headings are involved. I dont know whether a package exists for this purpose.
– Ramaprakasha
yesterday
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I came across a PDF which mutually links TOC entries and the headings present in the text body. It was created using Adobe Indesign. If I am reading the book and need to take a look at the TOC I can easily click the heading itself to see it in TOC. This will be a helpfull feature if content has many sub-headings. Are there any packages to achieve this functionality. Please guide.
packages links
I came across a PDF which mutually links TOC entries and the headings present in the text body. It was created using Adobe Indesign. If I am reading the book and need to take a look at the TOC I can easily click the heading itself to see it in TOC. This will be a helpfull feature if content has many sub-headings. Are there any packages to achieve this functionality. Please guide.
packages links
packages links
asked yesterday
Ramaprakasha
315110
315110
1
Do yiu really need it ? IMo the bookmarks created by hyperref in conjonction with pdflatex do provide already similar fonctionality, don't they?
– Jhor
yesterday
Yes I need it. It will be helpfull to see larger picture when many sub-topics are discussed. We need to create a label each time for each subheading and refer to it, becomes messy when many headings are involved. I dont know whether a package exists for this purpose.
– Ramaprakasha
yesterday
add a comment |
1
Do yiu really need it ? IMo the bookmarks created by hyperref in conjonction with pdflatex do provide already similar fonctionality, don't they?
– Jhor
yesterday
Yes I need it. It will be helpfull to see larger picture when many sub-topics are discussed. We need to create a label each time for each subheading and refer to it, becomes messy when many headings are involved. I dont know whether a package exists for this purpose.
– Ramaprakasha
yesterday
1
1
Do yiu really need it ? IMo the bookmarks created by hyperref in conjonction with pdflatex do provide already similar fonctionality, don't they?
– Jhor
yesterday
Do yiu really need it ? IMo the bookmarks created by hyperref in conjonction with pdflatex do provide already similar fonctionality, don't they?
– Jhor
yesterday
Yes I need it. It will be helpfull to see larger picture when many sub-topics are discussed. We need to create a label each time for each subheading and refer to it, becomes messy when many headings are involved. I dont know whether a package exists for this purpose.
– Ramaprakasha
yesterday
Yes I need it. It will be helpfull to see larger picture when many sub-topics are discussed. We need to create a label each time for each subheading and refer to it, becomes messy when many headings are involved. I dont know whether a package exists for this purpose.
– Ramaprakasha
yesterday
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
First, using etoolbox
's patchcmd
, one can add to the TOC filling a command for the creation of an hypertarget :
patchcmd{addcontentsline}{{#2}{#3}{thepage }}%
{{#2}{#3}{protecthypertarget{back@currentHref}{}thepage }}%
{typeout{*patch success}}{typeout{*patch failure}}
Here I have chosen to alter directly the addcontentsline
command as it is still called by the LaTeX @startsection
(actually @sect
) after its modification by hyperref
. This enable to affect all the titles in the TOC.
Second, one has to add the hyperlink on the sectioning titles. In both article
and book
standard classes, this is achieved by redefinition of the Sectionformat
introduced in @sect
by hyperref
:
AtBeginDocument{renewcommand{Sectionformat}[2]%
{ifnum #2>c@secnumdepth {#1}elsehyperlink{back@currentHref}{#1}fi}}
Finally an MWE is:
% !TEX encoding = UTF-8
documentclass{article}
usepackage[utf8]{inputenc}
usepackage{etoolbox}
usepackage{blindtext}
usepackage{hyperref}
makeatletter
patchcmd{addcontentsline}{{#2}{#3}{thepage }}%
{{#2}{#3}{protecthypertarget{back@currentHref}{}thepage }}%
{typeout{*patch success}}{typeout{*patch failure}}
AtBeginDocument{renewcommand{Sectionformat}[2]%
{ifnum #2>c@secnumdepth {#1}elsehyperlink{back@currentHref}{#1}fi}}
makeatother
begin{document}
tableofcontents
clearpage
Blinddocument
Blinddocument
Blinddocument
Blinddocument
Blinddocument
Blinddocument
end{document}
Of course the ugly link appearance can be improved with the suitable hypersetup{...}
Some caveats :
- This code is rather simple, but will likely conflict with any other classes or packages modifying titles and/or tableofcontents, namely the popular
titlesec
andtitletoc
packages, oretoc
ortocloft
, etc. - Nevertheless, it can surely be adapted to other situations, by looking as the content of the sectioning macro by using
meaning
- In this spirit, the same procedure can be surely be used to modify the chapters in the
book
class, it will require to patch the@makechapterhead
macro. - There is still a small default: the backlink opens the TOC page but the upper visible line is not the linked one, but the one just followingit.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
First, using etoolbox
's patchcmd
, one can add to the TOC filling a command for the creation of an hypertarget :
patchcmd{addcontentsline}{{#2}{#3}{thepage }}%
{{#2}{#3}{protecthypertarget{back@currentHref}{}thepage }}%
{typeout{*patch success}}{typeout{*patch failure}}
Here I have chosen to alter directly the addcontentsline
command as it is still called by the LaTeX @startsection
(actually @sect
) after its modification by hyperref
. This enable to affect all the titles in the TOC.
Second, one has to add the hyperlink on the sectioning titles. In both article
and book
standard classes, this is achieved by redefinition of the Sectionformat
introduced in @sect
by hyperref
:
AtBeginDocument{renewcommand{Sectionformat}[2]%
{ifnum #2>c@secnumdepth {#1}elsehyperlink{back@currentHref}{#1}fi}}
Finally an MWE is:
% !TEX encoding = UTF-8
documentclass{article}
usepackage[utf8]{inputenc}
usepackage{etoolbox}
usepackage{blindtext}
usepackage{hyperref}
makeatletter
patchcmd{addcontentsline}{{#2}{#3}{thepage }}%
{{#2}{#3}{protecthypertarget{back@currentHref}{}thepage }}%
{typeout{*patch success}}{typeout{*patch failure}}
AtBeginDocument{renewcommand{Sectionformat}[2]%
{ifnum #2>c@secnumdepth {#1}elsehyperlink{back@currentHref}{#1}fi}}
makeatother
begin{document}
tableofcontents
clearpage
Blinddocument
Blinddocument
Blinddocument
Blinddocument
Blinddocument
Blinddocument
end{document}
Of course the ugly link appearance can be improved with the suitable hypersetup{...}
Some caveats :
- This code is rather simple, but will likely conflict with any other classes or packages modifying titles and/or tableofcontents, namely the popular
titlesec
andtitletoc
packages, oretoc
ortocloft
, etc. - Nevertheless, it can surely be adapted to other situations, by looking as the content of the sectioning macro by using
meaning
- In this spirit, the same procedure can be surely be used to modify the chapters in the
book
class, it will require to patch the@makechapterhead
macro. - There is still a small default: the backlink opens the TOC page but the upper visible line is not the linked one, but the one just followingit.
add a comment |
up vote
1
down vote
First, using etoolbox
's patchcmd
, one can add to the TOC filling a command for the creation of an hypertarget :
patchcmd{addcontentsline}{{#2}{#3}{thepage }}%
{{#2}{#3}{protecthypertarget{back@currentHref}{}thepage }}%
{typeout{*patch success}}{typeout{*patch failure}}
Here I have chosen to alter directly the addcontentsline
command as it is still called by the LaTeX @startsection
(actually @sect
) after its modification by hyperref
. This enable to affect all the titles in the TOC.
Second, one has to add the hyperlink on the sectioning titles. In both article
and book
standard classes, this is achieved by redefinition of the Sectionformat
introduced in @sect
by hyperref
:
AtBeginDocument{renewcommand{Sectionformat}[2]%
{ifnum #2>c@secnumdepth {#1}elsehyperlink{back@currentHref}{#1}fi}}
Finally an MWE is:
% !TEX encoding = UTF-8
documentclass{article}
usepackage[utf8]{inputenc}
usepackage{etoolbox}
usepackage{blindtext}
usepackage{hyperref}
makeatletter
patchcmd{addcontentsline}{{#2}{#3}{thepage }}%
{{#2}{#3}{protecthypertarget{back@currentHref}{}thepage }}%
{typeout{*patch success}}{typeout{*patch failure}}
AtBeginDocument{renewcommand{Sectionformat}[2]%
{ifnum #2>c@secnumdepth {#1}elsehyperlink{back@currentHref}{#1}fi}}
makeatother
begin{document}
tableofcontents
clearpage
Blinddocument
Blinddocument
Blinddocument
Blinddocument
Blinddocument
Blinddocument
end{document}
Of course the ugly link appearance can be improved with the suitable hypersetup{...}
Some caveats :
- This code is rather simple, but will likely conflict with any other classes or packages modifying titles and/or tableofcontents, namely the popular
titlesec
andtitletoc
packages, oretoc
ortocloft
, etc. - Nevertheless, it can surely be adapted to other situations, by looking as the content of the sectioning macro by using
meaning
- In this spirit, the same procedure can be surely be used to modify the chapters in the
book
class, it will require to patch the@makechapterhead
macro. - There is still a small default: the backlink opens the TOC page but the upper visible line is not the linked one, but the one just followingit.
add a comment |
up vote
1
down vote
up vote
1
down vote
First, using etoolbox
's patchcmd
, one can add to the TOC filling a command for the creation of an hypertarget :
patchcmd{addcontentsline}{{#2}{#3}{thepage }}%
{{#2}{#3}{protecthypertarget{back@currentHref}{}thepage }}%
{typeout{*patch success}}{typeout{*patch failure}}
Here I have chosen to alter directly the addcontentsline
command as it is still called by the LaTeX @startsection
(actually @sect
) after its modification by hyperref
. This enable to affect all the titles in the TOC.
Second, one has to add the hyperlink on the sectioning titles. In both article
and book
standard classes, this is achieved by redefinition of the Sectionformat
introduced in @sect
by hyperref
:
AtBeginDocument{renewcommand{Sectionformat}[2]%
{ifnum #2>c@secnumdepth {#1}elsehyperlink{back@currentHref}{#1}fi}}
Finally an MWE is:
% !TEX encoding = UTF-8
documentclass{article}
usepackage[utf8]{inputenc}
usepackage{etoolbox}
usepackage{blindtext}
usepackage{hyperref}
makeatletter
patchcmd{addcontentsline}{{#2}{#3}{thepage }}%
{{#2}{#3}{protecthypertarget{back@currentHref}{}thepage }}%
{typeout{*patch success}}{typeout{*patch failure}}
AtBeginDocument{renewcommand{Sectionformat}[2]%
{ifnum #2>c@secnumdepth {#1}elsehyperlink{back@currentHref}{#1}fi}}
makeatother
begin{document}
tableofcontents
clearpage
Blinddocument
Blinddocument
Blinddocument
Blinddocument
Blinddocument
Blinddocument
end{document}
Of course the ugly link appearance can be improved with the suitable hypersetup{...}
Some caveats :
- This code is rather simple, but will likely conflict with any other classes or packages modifying titles and/or tableofcontents, namely the popular
titlesec
andtitletoc
packages, oretoc
ortocloft
, etc. - Nevertheless, it can surely be adapted to other situations, by looking as the content of the sectioning macro by using
meaning
- In this spirit, the same procedure can be surely be used to modify the chapters in the
book
class, it will require to patch the@makechapterhead
macro. - There is still a small default: the backlink opens the TOC page but the upper visible line is not the linked one, but the one just followingit.
First, using etoolbox
's patchcmd
, one can add to the TOC filling a command for the creation of an hypertarget :
patchcmd{addcontentsline}{{#2}{#3}{thepage }}%
{{#2}{#3}{protecthypertarget{back@currentHref}{}thepage }}%
{typeout{*patch success}}{typeout{*patch failure}}
Here I have chosen to alter directly the addcontentsline
command as it is still called by the LaTeX @startsection
(actually @sect
) after its modification by hyperref
. This enable to affect all the titles in the TOC.
Second, one has to add the hyperlink on the sectioning titles. In both article
and book
standard classes, this is achieved by redefinition of the Sectionformat
introduced in @sect
by hyperref
:
AtBeginDocument{renewcommand{Sectionformat}[2]%
{ifnum #2>c@secnumdepth {#1}elsehyperlink{back@currentHref}{#1}fi}}
Finally an MWE is:
% !TEX encoding = UTF-8
documentclass{article}
usepackage[utf8]{inputenc}
usepackage{etoolbox}
usepackage{blindtext}
usepackage{hyperref}
makeatletter
patchcmd{addcontentsline}{{#2}{#3}{thepage }}%
{{#2}{#3}{protecthypertarget{back@currentHref}{}thepage }}%
{typeout{*patch success}}{typeout{*patch failure}}
AtBeginDocument{renewcommand{Sectionformat}[2]%
{ifnum #2>c@secnumdepth {#1}elsehyperlink{back@currentHref}{#1}fi}}
makeatother
begin{document}
tableofcontents
clearpage
Blinddocument
Blinddocument
Blinddocument
Blinddocument
Blinddocument
Blinddocument
end{document}
Of course the ugly link appearance can be improved with the suitable hypersetup{...}
Some caveats :
- This code is rather simple, but will likely conflict with any other classes or packages modifying titles and/or tableofcontents, namely the popular
titlesec
andtitletoc
packages, oretoc
ortocloft
, etc. - Nevertheless, it can surely be adapted to other situations, by looking as the content of the sectioning macro by using
meaning
- In this spirit, the same procedure can be surely be used to modify the chapters in the
book
class, it will require to patch the@makechapterhead
macro. - There is still a small default: the backlink opens the TOC page but the upper visible line is not the linked one, but the one just followingit.
edited yesterday
answered yesterday
Jhor
2,0661014
2,0661014
add a comment |
add a comment |
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%2f460688%2fback-link-all-headings-with-respective-toc-entry%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
1
Do yiu really need it ? IMo the bookmarks created by hyperref in conjonction with pdflatex do provide already similar fonctionality, don't they?
– Jhor
yesterday
Yes I need it. It will be helpfull to see larger picture when many sub-topics are discussed. We need to create a label each time for each subheading and refer to it, becomes messy when many headings are involved. I dont know whether a package exists for this purpose.
– Ramaprakasha
yesterday