Hyperlinks, theorems, enumerate, and autoref
Hyperlinks to theorem-like environments that begin with a nested itemize or enumerate are often broken (see for example http://tex.stackexchange.com/a/187647).
Here is a MWE:
documentclass{amsart}
usepackage{hyperref}
newtheorem{theorem}{Theorem}
begin{document}
begin{theorem}
label{bigthm}
begin{itemize}
item A claim.
item Another claim.
end{itemize}
end{theorem}
Let's prove Theorem~ref{bigthm}.
end{document}
This produces a warning:
pdfTeX warning (dest): name{theorem.1} has been
referenced but does not exist, replaced by a fixed one
and the hyperlink doesn’t work.
(By the way, if we use article instead of amsart, then everything works as expected. What makes the AMS document class behave differently?)
One solution is to add leavevmode right after label{bigthm}:
begin{theorem}
label{bigthm}leavevmode
begin{itemize}[...]
This fixes the hyperlink, but of course it also changes the formatting, which I don’t want.
A better solution (thanks, Simon!), which does not change the formatting, is to add phantomsection right before label{bigthm}:
begin{theorem}
phantomsectionlabel{bigthm}
begin{itemize}[...]
Now everything works. Great!
However, this better solution does not work with autoref, alas:
Let's prove~autoref{bigthm}.
now produces Let’s prove section 1. (albeit with a working hyperlink).
So my question is this: Is there a way to fix the hyperlink that works with autoref without changing the formatting?
pdftex hyperref autoref
add a comment |
Hyperlinks to theorem-like environments that begin with a nested itemize or enumerate are often broken (see for example http://tex.stackexchange.com/a/187647).
Here is a MWE:
documentclass{amsart}
usepackage{hyperref}
newtheorem{theorem}{Theorem}
begin{document}
begin{theorem}
label{bigthm}
begin{itemize}
item A claim.
item Another claim.
end{itemize}
end{theorem}
Let's prove Theorem~ref{bigthm}.
end{document}
This produces a warning:
pdfTeX warning (dest): name{theorem.1} has been
referenced but does not exist, replaced by a fixed one
and the hyperlink doesn’t work.
(By the way, if we use article instead of amsart, then everything works as expected. What makes the AMS document class behave differently?)
One solution is to add leavevmode right after label{bigthm}:
begin{theorem}
label{bigthm}leavevmode
begin{itemize}[...]
This fixes the hyperlink, but of course it also changes the formatting, which I don’t want.
A better solution (thanks, Simon!), which does not change the formatting, is to add phantomsection right before label{bigthm}:
begin{theorem}
phantomsectionlabel{bigthm}
begin{itemize}[...]
Now everything works. Great!
However, this better solution does not work with autoref, alas:
Let's prove~autoref{bigthm}.
now produces Let’s prove section 1. (albeit with a working hyperlink).
So my question is this: Is there a way to fix the hyperlink that works with autoref without changing the formatting?
pdftex hyperref autoref
Just tryleavevmodelabel{bigthm}, withoutphantomsection
– Christian Hupfer
Jun 2 '17 at 15:39
@ChristianHupfer But that changes the formatting. I don’t want to start a new line.
– Marco Varisco
Jun 2 '17 at 15:57
Withoutleavevmodethe first item starts on the line of header line of the environment, which looks very ugly
– Christian Hupfer
Jun 2 '17 at 16:06
I know, but that’s exactly where I need the first item to start. I don’t particularly like it either, but the house styles of some publishers don’t allow line breaks right after theorem headers.
– Marco Varisco
Jun 2 '17 at 16:10
add a comment |
Hyperlinks to theorem-like environments that begin with a nested itemize or enumerate are often broken (see for example http://tex.stackexchange.com/a/187647).
Here is a MWE:
documentclass{amsart}
usepackage{hyperref}
newtheorem{theorem}{Theorem}
begin{document}
begin{theorem}
label{bigthm}
begin{itemize}
item A claim.
item Another claim.
end{itemize}
end{theorem}
Let's prove Theorem~ref{bigthm}.
end{document}
This produces a warning:
pdfTeX warning (dest): name{theorem.1} has been
referenced but does not exist, replaced by a fixed one
and the hyperlink doesn’t work.
(By the way, if we use article instead of amsart, then everything works as expected. What makes the AMS document class behave differently?)
One solution is to add leavevmode right after label{bigthm}:
begin{theorem}
label{bigthm}leavevmode
begin{itemize}[...]
This fixes the hyperlink, but of course it also changes the formatting, which I don’t want.
A better solution (thanks, Simon!), which does not change the formatting, is to add phantomsection right before label{bigthm}:
begin{theorem}
phantomsectionlabel{bigthm}
begin{itemize}[...]
Now everything works. Great!
However, this better solution does not work with autoref, alas:
Let's prove~autoref{bigthm}.
now produces Let’s prove section 1. (albeit with a working hyperlink).
So my question is this: Is there a way to fix the hyperlink that works with autoref without changing the formatting?
pdftex hyperref autoref
Hyperlinks to theorem-like environments that begin with a nested itemize or enumerate are often broken (see for example http://tex.stackexchange.com/a/187647).
Here is a MWE:
documentclass{amsart}
usepackage{hyperref}
newtheorem{theorem}{Theorem}
begin{document}
begin{theorem}
label{bigthm}
begin{itemize}
item A claim.
item Another claim.
end{itemize}
end{theorem}
Let's prove Theorem~ref{bigthm}.
end{document}
This produces a warning:
pdfTeX warning (dest): name{theorem.1} has been
referenced but does not exist, replaced by a fixed one
and the hyperlink doesn’t work.
(By the way, if we use article instead of amsart, then everything works as expected. What makes the AMS document class behave differently?)
One solution is to add leavevmode right after label{bigthm}:
begin{theorem}
label{bigthm}leavevmode
begin{itemize}[...]
This fixes the hyperlink, but of course it also changes the formatting, which I don’t want.
A better solution (thanks, Simon!), which does not change the formatting, is to add phantomsection right before label{bigthm}:
begin{theorem}
phantomsectionlabel{bigthm}
begin{itemize}[...]
Now everything works. Great!
However, this better solution does not work with autoref, alas:
Let's prove~autoref{bigthm}.
now produces Let’s prove section 1. (albeit with a working hyperlink).
So my question is this: Is there a way to fix the hyperlink that works with autoref without changing the formatting?
pdftex hyperref autoref
pdftex hyperref autoref
asked Jun 2 '17 at 15:18
Marco VariscoMarco Varisco
300314
300314
Just tryleavevmodelabel{bigthm}, withoutphantomsection
– Christian Hupfer
Jun 2 '17 at 15:39
@ChristianHupfer But that changes the formatting. I don’t want to start a new line.
– Marco Varisco
Jun 2 '17 at 15:57
Withoutleavevmodethe first item starts on the line of header line of the environment, which looks very ugly
– Christian Hupfer
Jun 2 '17 at 16:06
I know, but that’s exactly where I need the first item to start. I don’t particularly like it either, but the house styles of some publishers don’t allow line breaks right after theorem headers.
– Marco Varisco
Jun 2 '17 at 16:10
add a comment |
Just tryleavevmodelabel{bigthm}, withoutphantomsection
– Christian Hupfer
Jun 2 '17 at 15:39
@ChristianHupfer But that changes the formatting. I don’t want to start a new line.
– Marco Varisco
Jun 2 '17 at 15:57
Withoutleavevmodethe first item starts on the line of header line of the environment, which looks very ugly
– Christian Hupfer
Jun 2 '17 at 16:06
I know, but that’s exactly where I need the first item to start. I don’t particularly like it either, but the house styles of some publishers don’t allow line breaks right after theorem headers.
– Marco Varisco
Jun 2 '17 at 16:10
Just try
leavevmodelabel{bigthm}, without phantomsection– Christian Hupfer
Jun 2 '17 at 15:39
Just try
leavevmodelabel{bigthm}, without phantomsection– Christian Hupfer
Jun 2 '17 at 15:39
@ChristianHupfer But that changes the formatting. I don’t want to start a new line.
– Marco Varisco
Jun 2 '17 at 15:57
@ChristianHupfer But that changes the formatting. I don’t want to start a new line.
– Marco Varisco
Jun 2 '17 at 15:57
Without
leavevmode the first item starts on the line of header line of the environment, which looks very ugly– Christian Hupfer
Jun 2 '17 at 16:06
Without
leavevmode the first item starts on the line of header line of the environment, which looks very ugly– Christian Hupfer
Jun 2 '17 at 16:06
I know, but that’s exactly where I need the first item to start. I don’t particularly like it either, but the house styles of some publishers don’t allow line breaks right after theorem headers.
– Marco Varisco
Jun 2 '17 at 16:10
I know, but that’s exactly where I need the first item to start. I don’t particularly like it either, but the house styles of some publishers don’t allow line breaks right after theorem headers.
– Marco Varisco
Jun 2 '17 at 16:10
add a comment |
2 Answers
2
active
oldest
votes
A version with a fakephantomsection, that uses @currenvir, i.e. the current environment name in order to get the correct autoref name.
This is basically the same what phantomsection does, but using the correct environment name.
The problem is known and mentioned in the documentation of amsart:
• Other problems inherent in amsthm.
◦ Hyperlinking the first item
when a theorem begins with a list
documentclass{amsart}
usepackage{hyperref}
newtheorem{theorem}{Theorem}
makeatletter
newcommand{fakephantomsection}{%
Hy@MakeCurrentHref{@currenvir.theHy@linkcounter}
Hy@raisedlink{hyper@anchorstart{@currentHref}hyper@anchorend}%
}
makeatother
begin{document}
tableofcontents
clearpage
section{Foo}
begin{theorem}
fakephantomsectionlabel{bigthm}
begin{itemize}
item A claim.
item Another claim.
end{itemize}
end{theorem}
Let's prove Theorem~ref{bigthm} autoref{bigthm}.
end{document}

This is great. Thank you so much, Christian! And thanks also for answering my other parenthetical question.
– Marco Varisco
Jun 2 '17 at 17:13
@MarcoVarisco: You're welcome. Happy TeXing!
– Christian Hupfer
Jun 3 '17 at 19:50
add a comment |
I am using this modification of the command proposed in the other answer:
newcommand*{fakephantomsection}{%
Hy@GlobalStepCountHy@linkcounter%
Hy@MakeCurrentHref{@currenvir.theHy@linkcounter}%
Hy@raisedlink{hyper@anchorstart{@currentHref}hyper@anchorend}%
}
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%2f372922%2fhyperlinks-theorems-enumerate-and-autoref%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
A version with a fakephantomsection, that uses @currenvir, i.e. the current environment name in order to get the correct autoref name.
This is basically the same what phantomsection does, but using the correct environment name.
The problem is known and mentioned in the documentation of amsart:
• Other problems inherent in amsthm.
◦ Hyperlinking the first item
when a theorem begins with a list
documentclass{amsart}
usepackage{hyperref}
newtheorem{theorem}{Theorem}
makeatletter
newcommand{fakephantomsection}{%
Hy@MakeCurrentHref{@currenvir.theHy@linkcounter}
Hy@raisedlink{hyper@anchorstart{@currentHref}hyper@anchorend}%
}
makeatother
begin{document}
tableofcontents
clearpage
section{Foo}
begin{theorem}
fakephantomsectionlabel{bigthm}
begin{itemize}
item A claim.
item Another claim.
end{itemize}
end{theorem}
Let's prove Theorem~ref{bigthm} autoref{bigthm}.
end{document}

This is great. Thank you so much, Christian! And thanks also for answering my other parenthetical question.
– Marco Varisco
Jun 2 '17 at 17:13
@MarcoVarisco: You're welcome. Happy TeXing!
– Christian Hupfer
Jun 3 '17 at 19:50
add a comment |
A version with a fakephantomsection, that uses @currenvir, i.e. the current environment name in order to get the correct autoref name.
This is basically the same what phantomsection does, but using the correct environment name.
The problem is known and mentioned in the documentation of amsart:
• Other problems inherent in amsthm.
◦ Hyperlinking the first item
when a theorem begins with a list
documentclass{amsart}
usepackage{hyperref}
newtheorem{theorem}{Theorem}
makeatletter
newcommand{fakephantomsection}{%
Hy@MakeCurrentHref{@currenvir.theHy@linkcounter}
Hy@raisedlink{hyper@anchorstart{@currentHref}hyper@anchorend}%
}
makeatother
begin{document}
tableofcontents
clearpage
section{Foo}
begin{theorem}
fakephantomsectionlabel{bigthm}
begin{itemize}
item A claim.
item Another claim.
end{itemize}
end{theorem}
Let's prove Theorem~ref{bigthm} autoref{bigthm}.
end{document}

This is great. Thank you so much, Christian! And thanks also for answering my other parenthetical question.
– Marco Varisco
Jun 2 '17 at 17:13
@MarcoVarisco: You're welcome. Happy TeXing!
– Christian Hupfer
Jun 3 '17 at 19:50
add a comment |
A version with a fakephantomsection, that uses @currenvir, i.e. the current environment name in order to get the correct autoref name.
This is basically the same what phantomsection does, but using the correct environment name.
The problem is known and mentioned in the documentation of amsart:
• Other problems inherent in amsthm.
◦ Hyperlinking the first item
when a theorem begins with a list
documentclass{amsart}
usepackage{hyperref}
newtheorem{theorem}{Theorem}
makeatletter
newcommand{fakephantomsection}{%
Hy@MakeCurrentHref{@currenvir.theHy@linkcounter}
Hy@raisedlink{hyper@anchorstart{@currentHref}hyper@anchorend}%
}
makeatother
begin{document}
tableofcontents
clearpage
section{Foo}
begin{theorem}
fakephantomsectionlabel{bigthm}
begin{itemize}
item A claim.
item Another claim.
end{itemize}
end{theorem}
Let's prove Theorem~ref{bigthm} autoref{bigthm}.
end{document}

A version with a fakephantomsection, that uses @currenvir, i.e. the current environment name in order to get the correct autoref name.
This is basically the same what phantomsection does, but using the correct environment name.
The problem is known and mentioned in the documentation of amsart:
• Other problems inherent in amsthm.
◦ Hyperlinking the first item
when a theorem begins with a list
documentclass{amsart}
usepackage{hyperref}
newtheorem{theorem}{Theorem}
makeatletter
newcommand{fakephantomsection}{%
Hy@MakeCurrentHref{@currenvir.theHy@linkcounter}
Hy@raisedlink{hyper@anchorstart{@currentHref}hyper@anchorend}%
}
makeatother
begin{document}
tableofcontents
clearpage
section{Foo}
begin{theorem}
fakephantomsectionlabel{bigthm}
begin{itemize}
item A claim.
item Another claim.
end{itemize}
end{theorem}
Let's prove Theorem~ref{bigthm} autoref{bigthm}.
end{document}

edited Jun 2 '17 at 17:15
answered Jun 2 '17 at 16:35
Christian HupferChristian Hupfer
149k14196391
149k14196391
This is great. Thank you so much, Christian! And thanks also for answering my other parenthetical question.
– Marco Varisco
Jun 2 '17 at 17:13
@MarcoVarisco: You're welcome. Happy TeXing!
– Christian Hupfer
Jun 3 '17 at 19:50
add a comment |
This is great. Thank you so much, Christian! And thanks also for answering my other parenthetical question.
– Marco Varisco
Jun 2 '17 at 17:13
@MarcoVarisco: You're welcome. Happy TeXing!
– Christian Hupfer
Jun 3 '17 at 19:50
This is great. Thank you so much, Christian! And thanks also for answering my other parenthetical question.
– Marco Varisco
Jun 2 '17 at 17:13
This is great. Thank you so much, Christian! And thanks also for answering my other parenthetical question.
– Marco Varisco
Jun 2 '17 at 17:13
@MarcoVarisco: You're welcome. Happy TeXing!
– Christian Hupfer
Jun 3 '17 at 19:50
@MarcoVarisco: You're welcome. Happy TeXing!
– Christian Hupfer
Jun 3 '17 at 19:50
add a comment |
I am using this modification of the command proposed in the other answer:
newcommand*{fakephantomsection}{%
Hy@GlobalStepCountHy@linkcounter%
Hy@MakeCurrentHref{@currenvir.theHy@linkcounter}%
Hy@raisedlink{hyper@anchorstart{@currentHref}hyper@anchorend}%
}
add a comment |
I am using this modification of the command proposed in the other answer:
newcommand*{fakephantomsection}{%
Hy@GlobalStepCountHy@linkcounter%
Hy@MakeCurrentHref{@currenvir.theHy@linkcounter}%
Hy@raisedlink{hyper@anchorstart{@currentHref}hyper@anchorend}%
}
add a comment |
I am using this modification of the command proposed in the other answer:
newcommand*{fakephantomsection}{%
Hy@GlobalStepCountHy@linkcounter%
Hy@MakeCurrentHref{@currenvir.theHy@linkcounter}%
Hy@raisedlink{hyper@anchorstart{@currentHref}hyper@anchorend}%
}
I am using this modification of the command proposed in the other answer:
newcommand*{fakephantomsection}{%
Hy@GlobalStepCountHy@linkcounter%
Hy@MakeCurrentHref{@currenvir.theHy@linkcounter}%
Hy@raisedlink{hyper@anchorstart{@currentHref}hyper@anchorend}%
}
answered Jan 19 at 15:27
Lasse KliemannLasse Kliemann
274
274
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%2f372922%2fhyperlinks-theorems-enumerate-and-autoref%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
Just try
leavevmodelabel{bigthm}, withoutphantomsection– Christian Hupfer
Jun 2 '17 at 15:39
@ChristianHupfer But that changes the formatting. I don’t want to start a new line.
– Marco Varisco
Jun 2 '17 at 15:57
Without
leavevmodethe first item starts on the line of header line of the environment, which looks very ugly– Christian Hupfer
Jun 2 '17 at 16:06
I know, but that’s exactly where I need the first item to start. I don’t particularly like it either, but the house styles of some publishers don’t allow line breaks right after theorem headers.
– Marco Varisco
Jun 2 '17 at 16:10