Put section number in reference to subsection, but not in title
The below code produces
I'm wondering if it's possible to have the subsections show up as i, ii, etc, on the subsection title (because it's clear which section they're in when they show up), but as 1.i, 1.ii, etc. when I refer to them. (So that the reader can distinguish between 1.i and 2.i, for instance.)
Possibilities:
- Just enter the section number manually when I refer to it. This is
worst, since it isn't robust to renumbering the sections. - Find a way to store the section number of
Fruit Section
, and use
that when I make the reference. This is OK, but not robust to
changing which sectionApples
is a part of. - Inside
Apples
, get the current section somehow, store it, and then
refer to it. This would be robust, but would have to be done every time I want to make such a reference. - Better once-and-for-all solution to this problem.
.
documentclass{article}
usepackage{hyperref}
renewcommandthesubsection{roman{subsection}}
begin{document}
section{Fruit Section}
subsection{Apples} label{Apples-subsec}
subsection{Bananas} label{Bananas-subsec}
section{Vegetable Section}
subsection{Kale}
section{Conclusion}
As we recall from sections ref{Apples-subsec} and ref{Bananas-subsec}, apples and bananas are healthy to eat.
end{document}
hyperref cross-referencing numbering
add a comment |
The below code produces
I'm wondering if it's possible to have the subsections show up as i, ii, etc, on the subsection title (because it's clear which section they're in when they show up), but as 1.i, 1.ii, etc. when I refer to them. (So that the reader can distinguish between 1.i and 2.i, for instance.)
Possibilities:
- Just enter the section number manually when I refer to it. This is
worst, since it isn't robust to renumbering the sections. - Find a way to store the section number of
Fruit Section
, and use
that when I make the reference. This is OK, but not robust to
changing which sectionApples
is a part of. - Inside
Apples
, get the current section somehow, store it, and then
refer to it. This would be robust, but would have to be done every time I want to make such a reference. - Better once-and-for-all solution to this problem.
.
documentclass{article}
usepackage{hyperref}
renewcommandthesubsection{roman{subsection}}
begin{document}
section{Fruit Section}
subsection{Apples} label{Apples-subsec}
subsection{Bananas} label{Bananas-subsec}
section{Vegetable Section}
subsection{Kale}
section{Conclusion}
As we recall from sections ref{Apples-subsec} and ref{Bananas-subsec}, apples and bananas are healthy to eat.
end{document}
hyperref cross-referencing numbering
1
I general I think users are going to be confused when they are browsing through the document that there are more than one section that are namedi
. It is probably doable using some hackery,but I would not recommend it.
– daleif
Jun 21 '18 at 14:45
@daleif I for one bin such documents...if the author cannot be bothered to use proper structure in the document, why should I be bothered reading it?
– naphaneal
Jun 21 '18 at 16:26
@naphaneal there apparently is a kind of "cult" around this way of numbering, I have a colleague who adhere to it. But as mentioned, I pity the reader.
– daleif
Jun 21 '18 at 16:28
add a comment |
The below code produces
I'm wondering if it's possible to have the subsections show up as i, ii, etc, on the subsection title (because it's clear which section they're in when they show up), but as 1.i, 1.ii, etc. when I refer to them. (So that the reader can distinguish between 1.i and 2.i, for instance.)
Possibilities:
- Just enter the section number manually when I refer to it. This is
worst, since it isn't robust to renumbering the sections. - Find a way to store the section number of
Fruit Section
, and use
that when I make the reference. This is OK, but not robust to
changing which sectionApples
is a part of. - Inside
Apples
, get the current section somehow, store it, and then
refer to it. This would be robust, but would have to be done every time I want to make such a reference. - Better once-and-for-all solution to this problem.
.
documentclass{article}
usepackage{hyperref}
renewcommandthesubsection{roman{subsection}}
begin{document}
section{Fruit Section}
subsection{Apples} label{Apples-subsec}
subsection{Bananas} label{Bananas-subsec}
section{Vegetable Section}
subsection{Kale}
section{Conclusion}
As we recall from sections ref{Apples-subsec} and ref{Bananas-subsec}, apples and bananas are healthy to eat.
end{document}
hyperref cross-referencing numbering
The below code produces
I'm wondering if it's possible to have the subsections show up as i, ii, etc, on the subsection title (because it's clear which section they're in when they show up), but as 1.i, 1.ii, etc. when I refer to them. (So that the reader can distinguish between 1.i and 2.i, for instance.)
Possibilities:
- Just enter the section number manually when I refer to it. This is
worst, since it isn't robust to renumbering the sections. - Find a way to store the section number of
Fruit Section
, and use
that when I make the reference. This is OK, but not robust to
changing which sectionApples
is a part of. - Inside
Apples
, get the current section somehow, store it, and then
refer to it. This would be robust, but would have to be done every time I want to make such a reference. - Better once-and-for-all solution to this problem.
.
documentclass{article}
usepackage{hyperref}
renewcommandthesubsection{roman{subsection}}
begin{document}
section{Fruit Section}
subsection{Apples} label{Apples-subsec}
subsection{Bananas} label{Bananas-subsec}
section{Vegetable Section}
subsection{Kale}
section{Conclusion}
As we recall from sections ref{Apples-subsec} and ref{Bananas-subsec}, apples and bananas are healthy to eat.
end{document}
hyperref cross-referencing numbering
hyperref cross-referencing numbering
asked Jun 21 '18 at 14:40
Eric AuldEric Auld
3731515
3731515
1
I general I think users are going to be confused when they are browsing through the document that there are more than one section that are namedi
. It is probably doable using some hackery,but I would not recommend it.
– daleif
Jun 21 '18 at 14:45
@daleif I for one bin such documents...if the author cannot be bothered to use proper structure in the document, why should I be bothered reading it?
– naphaneal
Jun 21 '18 at 16:26
@naphaneal there apparently is a kind of "cult" around this way of numbering, I have a colleague who adhere to it. But as mentioned, I pity the reader.
– daleif
Jun 21 '18 at 16:28
add a comment |
1
I general I think users are going to be confused when they are browsing through the document that there are more than one section that are namedi
. It is probably doable using some hackery,but I would not recommend it.
– daleif
Jun 21 '18 at 14:45
@daleif I for one bin such documents...if the author cannot be bothered to use proper structure in the document, why should I be bothered reading it?
– naphaneal
Jun 21 '18 at 16:26
@naphaneal there apparently is a kind of "cult" around this way of numbering, I have a colleague who adhere to it. But as mentioned, I pity the reader.
– daleif
Jun 21 '18 at 16:28
1
1
I general I think users are going to be confused when they are browsing through the document that there are more than one section that are named
i
. It is probably doable using some hackery,but I would not recommend it.– daleif
Jun 21 '18 at 14:45
I general I think users are going to be confused when they are browsing through the document that there are more than one section that are named
i
. It is probably doable using some hackery,but I would not recommend it.– daleif
Jun 21 '18 at 14:45
@daleif I for one bin such documents...if the author cannot be bothered to use proper structure in the document, why should I be bothered reading it?
– naphaneal
Jun 21 '18 at 16:26
@daleif I for one bin such documents...if the author cannot be bothered to use proper structure in the document, why should I be bothered reading it?
– naphaneal
Jun 21 '18 at 16:26
@naphaneal there apparently is a kind of "cult" around this way of numbering, I have a colleague who adhere to it. But as mentioned, I pity the reader.
– daleif
Jun 21 '18 at 16:28
@naphaneal there apparently is a kind of "cult" around this way of numbering, I have a colleague who adhere to it. But as mentioned, I pity the reader.
– daleif
Jun 21 '18 at 16:28
add a comment |
1 Answer
1
active
oldest
votes
You can use p@<counter>
to add something before the actual counter value in references. To quote source2e
(§22.1)
p@foo
Macro that expands to a printed ‘reference prefix’ of counter foo. Anyref
to a value created by counter foo will produce the expansion ofp@foothefoo
when thelabel
command is executed.
So
makeatletter
renewcommand*{p@subsection}{thesection.}
makeatother
would add the section and a dot whenever you reference a subsection.
documentclass{article}
usepackage{hyperref}
renewcommandthesubsection{roman{subsection}}
makeatletter
renewcommand*{p@subsection}{thesection.}
makeatother
begin{document}
section{Fruit Section}
subsection{Apples} label{Apples-subsec}
subsection{Bananas} label{Bananas-subsec}
section{Vegetable Section}
subsection{Kale}
section{Conclusion}
As we recall from sections ref{Apples-subsec} and ref{Bananas-subsec}, apples and bananas are healthy to eat.
end{document}
Having seen the result I would probably not do this, especially if the subsections can be longer, and would include the section number for subsections also in the headings.
Is there a way to show the section number for only one reference in the document, but not in general? I tried puttingmakeatletter renewcommand...
inside a group along with the reference I'm making, but it didn't work. (I'm guessingmakeatletter renewcommand...
wants to be in the preamble.)
– Eric Auld
Jun 21 '18 at 16:24
@EricAuld What exactly are you thinking of? As far as I am aware thep@foo
setting active at the time of defining thelabel
governs all of its later uses inref
no matter what their environment setting w.r.tp@foo
is. So if you want something more complicated a different solution is probably needed. Please ask a new question about that.
– moewe
Jun 21 '18 at 16:29
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%2f437402%2fput-section-number-in-reference-to-subsection-but-not-in-title%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can use p@<counter>
to add something before the actual counter value in references. To quote source2e
(§22.1)
p@foo
Macro that expands to a printed ‘reference prefix’ of counter foo. Anyref
to a value created by counter foo will produce the expansion ofp@foothefoo
when thelabel
command is executed.
So
makeatletter
renewcommand*{p@subsection}{thesection.}
makeatother
would add the section and a dot whenever you reference a subsection.
documentclass{article}
usepackage{hyperref}
renewcommandthesubsection{roman{subsection}}
makeatletter
renewcommand*{p@subsection}{thesection.}
makeatother
begin{document}
section{Fruit Section}
subsection{Apples} label{Apples-subsec}
subsection{Bananas} label{Bananas-subsec}
section{Vegetable Section}
subsection{Kale}
section{Conclusion}
As we recall from sections ref{Apples-subsec} and ref{Bananas-subsec}, apples and bananas are healthy to eat.
end{document}
Having seen the result I would probably not do this, especially if the subsections can be longer, and would include the section number for subsections also in the headings.
Is there a way to show the section number for only one reference in the document, but not in general? I tried puttingmakeatletter renewcommand...
inside a group along with the reference I'm making, but it didn't work. (I'm guessingmakeatletter renewcommand...
wants to be in the preamble.)
– Eric Auld
Jun 21 '18 at 16:24
@EricAuld What exactly are you thinking of? As far as I am aware thep@foo
setting active at the time of defining thelabel
governs all of its later uses inref
no matter what their environment setting w.r.tp@foo
is. So if you want something more complicated a different solution is probably needed. Please ask a new question about that.
– moewe
Jun 21 '18 at 16:29
add a comment |
You can use p@<counter>
to add something before the actual counter value in references. To quote source2e
(§22.1)
p@foo
Macro that expands to a printed ‘reference prefix’ of counter foo. Anyref
to a value created by counter foo will produce the expansion ofp@foothefoo
when thelabel
command is executed.
So
makeatletter
renewcommand*{p@subsection}{thesection.}
makeatother
would add the section and a dot whenever you reference a subsection.
documentclass{article}
usepackage{hyperref}
renewcommandthesubsection{roman{subsection}}
makeatletter
renewcommand*{p@subsection}{thesection.}
makeatother
begin{document}
section{Fruit Section}
subsection{Apples} label{Apples-subsec}
subsection{Bananas} label{Bananas-subsec}
section{Vegetable Section}
subsection{Kale}
section{Conclusion}
As we recall from sections ref{Apples-subsec} and ref{Bananas-subsec}, apples and bananas are healthy to eat.
end{document}
Having seen the result I would probably not do this, especially if the subsections can be longer, and would include the section number for subsections also in the headings.
Is there a way to show the section number for only one reference in the document, but not in general? I tried puttingmakeatletter renewcommand...
inside a group along with the reference I'm making, but it didn't work. (I'm guessingmakeatletter renewcommand...
wants to be in the preamble.)
– Eric Auld
Jun 21 '18 at 16:24
@EricAuld What exactly are you thinking of? As far as I am aware thep@foo
setting active at the time of defining thelabel
governs all of its later uses inref
no matter what their environment setting w.r.tp@foo
is. So if you want something more complicated a different solution is probably needed. Please ask a new question about that.
– moewe
Jun 21 '18 at 16:29
add a comment |
You can use p@<counter>
to add something before the actual counter value in references. To quote source2e
(§22.1)
p@foo
Macro that expands to a printed ‘reference prefix’ of counter foo. Anyref
to a value created by counter foo will produce the expansion ofp@foothefoo
when thelabel
command is executed.
So
makeatletter
renewcommand*{p@subsection}{thesection.}
makeatother
would add the section and a dot whenever you reference a subsection.
documentclass{article}
usepackage{hyperref}
renewcommandthesubsection{roman{subsection}}
makeatletter
renewcommand*{p@subsection}{thesection.}
makeatother
begin{document}
section{Fruit Section}
subsection{Apples} label{Apples-subsec}
subsection{Bananas} label{Bananas-subsec}
section{Vegetable Section}
subsection{Kale}
section{Conclusion}
As we recall from sections ref{Apples-subsec} and ref{Bananas-subsec}, apples and bananas are healthy to eat.
end{document}
Having seen the result I would probably not do this, especially if the subsections can be longer, and would include the section number for subsections also in the headings.
You can use p@<counter>
to add something before the actual counter value in references. To quote source2e
(§22.1)
p@foo
Macro that expands to a printed ‘reference prefix’ of counter foo. Anyref
to a value created by counter foo will produce the expansion ofp@foothefoo
when thelabel
command is executed.
So
makeatletter
renewcommand*{p@subsection}{thesection.}
makeatother
would add the section and a dot whenever you reference a subsection.
documentclass{article}
usepackage{hyperref}
renewcommandthesubsection{roman{subsection}}
makeatletter
renewcommand*{p@subsection}{thesection.}
makeatother
begin{document}
section{Fruit Section}
subsection{Apples} label{Apples-subsec}
subsection{Bananas} label{Bananas-subsec}
section{Vegetable Section}
subsection{Kale}
section{Conclusion}
As we recall from sections ref{Apples-subsec} and ref{Bananas-subsec}, apples and bananas are healthy to eat.
end{document}
Having seen the result I would probably not do this, especially if the subsections can be longer, and would include the section number for subsections also in the headings.
edited Jun 21 '18 at 15:34
answered Jun 21 '18 at 14:49
moewemoewe
91.4k10114346
91.4k10114346
Is there a way to show the section number for only one reference in the document, but not in general? I tried puttingmakeatletter renewcommand...
inside a group along with the reference I'm making, but it didn't work. (I'm guessingmakeatletter renewcommand...
wants to be in the preamble.)
– Eric Auld
Jun 21 '18 at 16:24
@EricAuld What exactly are you thinking of? As far as I am aware thep@foo
setting active at the time of defining thelabel
governs all of its later uses inref
no matter what their environment setting w.r.tp@foo
is. So if you want something more complicated a different solution is probably needed. Please ask a new question about that.
– moewe
Jun 21 '18 at 16:29
add a comment |
Is there a way to show the section number for only one reference in the document, but not in general? I tried puttingmakeatletter renewcommand...
inside a group along with the reference I'm making, but it didn't work. (I'm guessingmakeatletter renewcommand...
wants to be in the preamble.)
– Eric Auld
Jun 21 '18 at 16:24
@EricAuld What exactly are you thinking of? As far as I am aware thep@foo
setting active at the time of defining thelabel
governs all of its later uses inref
no matter what their environment setting w.r.tp@foo
is. So if you want something more complicated a different solution is probably needed. Please ask a new question about that.
– moewe
Jun 21 '18 at 16:29
Is there a way to show the section number for only one reference in the document, but not in general? I tried putting
makeatletter renewcommand...
inside a group along with the reference I'm making, but it didn't work. (I'm guessing makeatletter renewcommand...
wants to be in the preamble.)– Eric Auld
Jun 21 '18 at 16:24
Is there a way to show the section number for only one reference in the document, but not in general? I tried putting
makeatletter renewcommand...
inside a group along with the reference I'm making, but it didn't work. (I'm guessing makeatletter renewcommand...
wants to be in the preamble.)– Eric Auld
Jun 21 '18 at 16:24
@EricAuld What exactly are you thinking of? As far as I am aware the
p@foo
setting active at the time of defining the label
governs all of its later uses in ref
no matter what their environment setting w.r.t p@foo
is. So if you want something more complicated a different solution is probably needed. Please ask a new question about that.– moewe
Jun 21 '18 at 16:29
@EricAuld What exactly are you thinking of? As far as I am aware the
p@foo
setting active at the time of defining the label
governs all of its later uses in ref
no matter what their environment setting w.r.t p@foo
is. So if you want something more complicated a different solution is probably needed. Please ask a new question about that.– moewe
Jun 21 '18 at 16:29
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%2f437402%2fput-section-number-in-reference-to-subsection-but-not-in-title%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
I general I think users are going to be confused when they are browsing through the document that there are more than one section that are named
i
. It is probably doable using some hackery,but I would not recommend it.– daleif
Jun 21 '18 at 14:45
@daleif I for one bin such documents...if the author cannot be bothered to use proper structure in the document, why should I be bothered reading it?
– naphaneal
Jun 21 '18 at 16:26
@naphaneal there apparently is a kind of "cult" around this way of numbering, I have a colleague who adhere to it. But as mentioned, I pity the reader.
– daleif
Jun 21 '18 at 16:28