Label blocks inlcuding section number











up vote
4
down vote

favorite












I want to add section number when referencing blocks. MWE is as follows:



documentclass[serif,12pt,xcolor=dvipsnames]{beamer}
usetheme{Madrid}
usepackage{lipsum}
begin{document}

begin{frame}{Example ref{block1}}
section{}
begin{block}{}label{block1}
lipsum[2]
end{block}
end{frame}

end{document}


This is what I have at the moment:



enter image description here



But I would like to have the following:



enter image description here



Many thanks in advance!










share|improve this question









New contributor




Alex is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • Try documentclass[serif,12pt,xcolor=dvipsnames]{beamer} usetheme{Madrid} usepackage{lipsum} begin{document} section{A section} begin{frame}{Example arabic{section}.ref{block1}} begin{block}{}label{block1} lipsum[2] end{block} end{frame} end{document}
    – marmot
    Nov 20 at 19:31










  • Many thanks @marmot, it works! I was wondering if there is a way to automatically include section number without having to type the section number in front of ref{block1} every time.
    – Alex
    Nov 20 at 19:50






  • 1




    Of course, there is e.g. the numberwithin command that AFAIK comes with amsmath. That is, you need to declare your example to be a "theorem-like" environment that and then say numberwithin{example}{section}. I guess a reasonable starting point would be this answer and say numberwithin{theorem}{section} instead. Of course, it will be better to wait till @samcarter sees this question and gives a real answer. ;-)
    – marmot
    Nov 20 at 19:57










  • I think the main problem is that blocks are not numbered and if you label them, you will get the framenumber. So your document above only works by chance. I'll see if I can add counters to the blocks.
    – samcarter
    Nov 20 at 20:07








  • 1




    @marmot For someone who claims that his crystal ball is missing, you are remarkably good at predicting the future... :)
    – samcarter
    Nov 20 at 20:18

















up vote
4
down vote

favorite












I want to add section number when referencing blocks. MWE is as follows:



documentclass[serif,12pt,xcolor=dvipsnames]{beamer}
usetheme{Madrid}
usepackage{lipsum}
begin{document}

begin{frame}{Example ref{block1}}
section{}
begin{block}{}label{block1}
lipsum[2]
end{block}
end{frame}

end{document}


This is what I have at the moment:



enter image description here



But I would like to have the following:



enter image description here



Many thanks in advance!










share|improve this question









New contributor




Alex is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • Try documentclass[serif,12pt,xcolor=dvipsnames]{beamer} usetheme{Madrid} usepackage{lipsum} begin{document} section{A section} begin{frame}{Example arabic{section}.ref{block1}} begin{block}{}label{block1} lipsum[2] end{block} end{frame} end{document}
    – marmot
    Nov 20 at 19:31










  • Many thanks @marmot, it works! I was wondering if there is a way to automatically include section number without having to type the section number in front of ref{block1} every time.
    – Alex
    Nov 20 at 19:50






  • 1




    Of course, there is e.g. the numberwithin command that AFAIK comes with amsmath. That is, you need to declare your example to be a "theorem-like" environment that and then say numberwithin{example}{section}. I guess a reasonable starting point would be this answer and say numberwithin{theorem}{section} instead. Of course, it will be better to wait till @samcarter sees this question and gives a real answer. ;-)
    – marmot
    Nov 20 at 19:57










  • I think the main problem is that blocks are not numbered and if you label them, you will get the framenumber. So your document above only works by chance. I'll see if I can add counters to the blocks.
    – samcarter
    Nov 20 at 20:07








  • 1




    @marmot For someone who claims that his crystal ball is missing, you are remarkably good at predicting the future... :)
    – samcarter
    Nov 20 at 20:18















up vote
4
down vote

favorite









up vote
4
down vote

favorite











I want to add section number when referencing blocks. MWE is as follows:



documentclass[serif,12pt,xcolor=dvipsnames]{beamer}
usetheme{Madrid}
usepackage{lipsum}
begin{document}

begin{frame}{Example ref{block1}}
section{}
begin{block}{}label{block1}
lipsum[2]
end{block}
end{frame}

end{document}


This is what I have at the moment:



enter image description here



But I would like to have the following:



enter image description here



Many thanks in advance!










share|improve this question









New contributor




Alex is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I want to add section number when referencing blocks. MWE is as follows:



documentclass[serif,12pt,xcolor=dvipsnames]{beamer}
usetheme{Madrid}
usepackage{lipsum}
begin{document}

begin{frame}{Example ref{block1}}
section{}
begin{block}{}label{block1}
lipsum[2]
end{block}
end{frame}

end{document}


This is what I have at the moment:



enter image description here



But I would like to have the following:



enter image description here



Many thanks in advance!







beamer cross-referencing numbering






share|improve this question









New contributor




Alex is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Alex is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Nov 20 at 19:29





















New contributor




Alex is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Nov 20 at 19:08









Alex

233




233




New contributor




Alex is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Alex is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Alex is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • Try documentclass[serif,12pt,xcolor=dvipsnames]{beamer} usetheme{Madrid} usepackage{lipsum} begin{document} section{A section} begin{frame}{Example arabic{section}.ref{block1}} begin{block}{}label{block1} lipsum[2] end{block} end{frame} end{document}
    – marmot
    Nov 20 at 19:31










  • Many thanks @marmot, it works! I was wondering if there is a way to automatically include section number without having to type the section number in front of ref{block1} every time.
    – Alex
    Nov 20 at 19:50






  • 1




    Of course, there is e.g. the numberwithin command that AFAIK comes with amsmath. That is, you need to declare your example to be a "theorem-like" environment that and then say numberwithin{example}{section}. I guess a reasonable starting point would be this answer and say numberwithin{theorem}{section} instead. Of course, it will be better to wait till @samcarter sees this question and gives a real answer. ;-)
    – marmot
    Nov 20 at 19:57










  • I think the main problem is that blocks are not numbered and if you label them, you will get the framenumber. So your document above only works by chance. I'll see if I can add counters to the blocks.
    – samcarter
    Nov 20 at 20:07








  • 1




    @marmot For someone who claims that his crystal ball is missing, you are remarkably good at predicting the future... :)
    – samcarter
    Nov 20 at 20:18




















  • Try documentclass[serif,12pt,xcolor=dvipsnames]{beamer} usetheme{Madrid} usepackage{lipsum} begin{document} section{A section} begin{frame}{Example arabic{section}.ref{block1}} begin{block}{}label{block1} lipsum[2] end{block} end{frame} end{document}
    – marmot
    Nov 20 at 19:31










  • Many thanks @marmot, it works! I was wondering if there is a way to automatically include section number without having to type the section number in front of ref{block1} every time.
    – Alex
    Nov 20 at 19:50






  • 1




    Of course, there is e.g. the numberwithin command that AFAIK comes with amsmath. That is, you need to declare your example to be a "theorem-like" environment that and then say numberwithin{example}{section}. I guess a reasonable starting point would be this answer and say numberwithin{theorem}{section} instead. Of course, it will be better to wait till @samcarter sees this question and gives a real answer. ;-)
    – marmot
    Nov 20 at 19:57










  • I think the main problem is that blocks are not numbered and if you label them, you will get the framenumber. So your document above only works by chance. I'll see if I can add counters to the blocks.
    – samcarter
    Nov 20 at 20:07








  • 1




    @marmot For someone who claims that his crystal ball is missing, you are remarkably good at predicting the future... :)
    – samcarter
    Nov 20 at 20:18


















Try documentclass[serif,12pt,xcolor=dvipsnames]{beamer} usetheme{Madrid} usepackage{lipsum} begin{document} section{A section} begin{frame}{Example arabic{section}.ref{block1}} begin{block}{}label{block1} lipsum[2] end{block} end{frame} end{document}
– marmot
Nov 20 at 19:31




Try documentclass[serif,12pt,xcolor=dvipsnames]{beamer} usetheme{Madrid} usepackage{lipsum} begin{document} section{A section} begin{frame}{Example arabic{section}.ref{block1}} begin{block}{}label{block1} lipsum[2] end{block} end{frame} end{document}
– marmot
Nov 20 at 19:31












Many thanks @marmot, it works! I was wondering if there is a way to automatically include section number without having to type the section number in front of ref{block1} every time.
– Alex
Nov 20 at 19:50




Many thanks @marmot, it works! I was wondering if there is a way to automatically include section number without having to type the section number in front of ref{block1} every time.
– Alex
Nov 20 at 19:50




1




1




Of course, there is e.g. the numberwithin command that AFAIK comes with amsmath. That is, you need to declare your example to be a "theorem-like" environment that and then say numberwithin{example}{section}. I guess a reasonable starting point would be this answer and say numberwithin{theorem}{section} instead. Of course, it will be better to wait till @samcarter sees this question and gives a real answer. ;-)
– marmot
Nov 20 at 19:57




Of course, there is e.g. the numberwithin command that AFAIK comes with amsmath. That is, you need to declare your example to be a "theorem-like" environment that and then say numberwithin{example}{section}. I guess a reasonable starting point would be this answer and say numberwithin{theorem}{section} instead. Of course, it will be better to wait till @samcarter sees this question and gives a real answer. ;-)
– marmot
Nov 20 at 19:57












I think the main problem is that blocks are not numbered and if you label them, you will get the framenumber. So your document above only works by chance. I'll see if I can add counters to the blocks.
– samcarter
Nov 20 at 20:07






I think the main problem is that blocks are not numbered and if you label them, you will get the framenumber. So your document above only works by chance. I'll see if I can add counters to the blocks.
– samcarter
Nov 20 at 20:07






1




1




@marmot For someone who claims that his crystal ball is missing, you are remarkably good at predicting the future... :)
– samcarter
Nov 20 at 20:18






@marmot For someone who claims that his crystal ball is missing, you are remarkably good at predicting the future... :)
– samcarter
Nov 20 at 20:18












1 Answer
1






active

oldest

votes

















up vote
4
down vote



accepted










The problem is actually more tricky than you make it look. The main problem is that blocks are not numbered in beamer and if you label them, you will get the framenumber and not the number of the block.



You can modify the definition of the block environment to include a counter. Once blocks are numbered you can use @marmots great suggestion and use numberwithin{block}{section} to include the section number.



Additional comment: never ever use section inside a frame, this can have serve side-effects.



documentclass[12pt,xcolor=dvipsnames]{beamer}
usefonttheme{serif}
usetheme{Madrid}
usepackage{lipsum}

newcounter{block}
setcounter{block}{0}
numberwithin{block}{section}

setbeamertemplate{block begin}
{%
refstepcounter{block}%
parvskipmedskipamount%
begin{beamerboxesrounded}[upper=block title,lower=block body,shadow=true]%
{raggedrightusebeamerfont*{block title}insertblocktitle}%
raggedright%
usebeamerfont{block body}%
}

begin{document}

section{}
begin{frame}{Example ref{block1}}
begin{block}{}label{block1}
lipsum[2]
end{block}
end{frame}

begin{frame}
content...
end{frame}

begin{frame}{Example ref{block2}}
begin{block}{}label{block2}
lipsum[2]
end{block}
end{frame}

end{document}





share|improve this answer























  • Wow, many thanks @samcarter! This is exactly what I had in mind! That's amazing!
    – Alex
    Nov 20 at 20:14










  • @Alex You're welcome!
    – samcarter
    Nov 20 at 20:19











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


}
});






Alex is a new contributor. Be nice, and check out our Code of Conduct.










 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f461013%2flabel-blocks-inlcuding-section-number%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








up vote
4
down vote



accepted










The problem is actually more tricky than you make it look. The main problem is that blocks are not numbered in beamer and if you label them, you will get the framenumber and not the number of the block.



You can modify the definition of the block environment to include a counter. Once blocks are numbered you can use @marmots great suggestion and use numberwithin{block}{section} to include the section number.



Additional comment: never ever use section inside a frame, this can have serve side-effects.



documentclass[12pt,xcolor=dvipsnames]{beamer}
usefonttheme{serif}
usetheme{Madrid}
usepackage{lipsum}

newcounter{block}
setcounter{block}{0}
numberwithin{block}{section}

setbeamertemplate{block begin}
{%
refstepcounter{block}%
parvskipmedskipamount%
begin{beamerboxesrounded}[upper=block title,lower=block body,shadow=true]%
{raggedrightusebeamerfont*{block title}insertblocktitle}%
raggedright%
usebeamerfont{block body}%
}

begin{document}

section{}
begin{frame}{Example ref{block1}}
begin{block}{}label{block1}
lipsum[2]
end{block}
end{frame}

begin{frame}
content...
end{frame}

begin{frame}{Example ref{block2}}
begin{block}{}label{block2}
lipsum[2]
end{block}
end{frame}

end{document}





share|improve this answer























  • Wow, many thanks @samcarter! This is exactly what I had in mind! That's amazing!
    – Alex
    Nov 20 at 20:14










  • @Alex You're welcome!
    – samcarter
    Nov 20 at 20:19















up vote
4
down vote



accepted










The problem is actually more tricky than you make it look. The main problem is that blocks are not numbered in beamer and if you label them, you will get the framenumber and not the number of the block.



You can modify the definition of the block environment to include a counter. Once blocks are numbered you can use @marmots great suggestion and use numberwithin{block}{section} to include the section number.



Additional comment: never ever use section inside a frame, this can have serve side-effects.



documentclass[12pt,xcolor=dvipsnames]{beamer}
usefonttheme{serif}
usetheme{Madrid}
usepackage{lipsum}

newcounter{block}
setcounter{block}{0}
numberwithin{block}{section}

setbeamertemplate{block begin}
{%
refstepcounter{block}%
parvskipmedskipamount%
begin{beamerboxesrounded}[upper=block title,lower=block body,shadow=true]%
{raggedrightusebeamerfont*{block title}insertblocktitle}%
raggedright%
usebeamerfont{block body}%
}

begin{document}

section{}
begin{frame}{Example ref{block1}}
begin{block}{}label{block1}
lipsum[2]
end{block}
end{frame}

begin{frame}
content...
end{frame}

begin{frame}{Example ref{block2}}
begin{block}{}label{block2}
lipsum[2]
end{block}
end{frame}

end{document}





share|improve this answer























  • Wow, many thanks @samcarter! This is exactly what I had in mind! That's amazing!
    – Alex
    Nov 20 at 20:14










  • @Alex You're welcome!
    – samcarter
    Nov 20 at 20:19













up vote
4
down vote



accepted







up vote
4
down vote



accepted






The problem is actually more tricky than you make it look. The main problem is that blocks are not numbered in beamer and if you label them, you will get the framenumber and not the number of the block.



You can modify the definition of the block environment to include a counter. Once blocks are numbered you can use @marmots great suggestion and use numberwithin{block}{section} to include the section number.



Additional comment: never ever use section inside a frame, this can have serve side-effects.



documentclass[12pt,xcolor=dvipsnames]{beamer}
usefonttheme{serif}
usetheme{Madrid}
usepackage{lipsum}

newcounter{block}
setcounter{block}{0}
numberwithin{block}{section}

setbeamertemplate{block begin}
{%
refstepcounter{block}%
parvskipmedskipamount%
begin{beamerboxesrounded}[upper=block title,lower=block body,shadow=true]%
{raggedrightusebeamerfont*{block title}insertblocktitle}%
raggedright%
usebeamerfont{block body}%
}

begin{document}

section{}
begin{frame}{Example ref{block1}}
begin{block}{}label{block1}
lipsum[2]
end{block}
end{frame}

begin{frame}
content...
end{frame}

begin{frame}{Example ref{block2}}
begin{block}{}label{block2}
lipsum[2]
end{block}
end{frame}

end{document}





share|improve this answer














The problem is actually more tricky than you make it look. The main problem is that blocks are not numbered in beamer and if you label them, you will get the framenumber and not the number of the block.



You can modify the definition of the block environment to include a counter. Once blocks are numbered you can use @marmots great suggestion and use numberwithin{block}{section} to include the section number.



Additional comment: never ever use section inside a frame, this can have serve side-effects.



documentclass[12pt,xcolor=dvipsnames]{beamer}
usefonttheme{serif}
usetheme{Madrid}
usepackage{lipsum}

newcounter{block}
setcounter{block}{0}
numberwithin{block}{section}

setbeamertemplate{block begin}
{%
refstepcounter{block}%
parvskipmedskipamount%
begin{beamerboxesrounded}[upper=block title,lower=block body,shadow=true]%
{raggedrightusebeamerfont*{block title}insertblocktitle}%
raggedright%
usebeamerfont{block body}%
}

begin{document}

section{}
begin{frame}{Example ref{block1}}
begin{block}{}label{block1}
lipsum[2]
end{block}
end{frame}

begin{frame}
content...
end{frame}

begin{frame}{Example ref{block2}}
begin{block}{}label{block2}
lipsum[2]
end{block}
end{frame}

end{document}






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 20 at 20:15

























answered Nov 20 at 20:12









samcarter

82.5k793264




82.5k793264












  • Wow, many thanks @samcarter! This is exactly what I had in mind! That's amazing!
    – Alex
    Nov 20 at 20:14










  • @Alex You're welcome!
    – samcarter
    Nov 20 at 20:19


















  • Wow, many thanks @samcarter! This is exactly what I had in mind! That's amazing!
    – Alex
    Nov 20 at 20:14










  • @Alex You're welcome!
    – samcarter
    Nov 20 at 20:19
















Wow, many thanks @samcarter! This is exactly what I had in mind! That's amazing!
– Alex
Nov 20 at 20:14




Wow, many thanks @samcarter! This is exactly what I had in mind! That's amazing!
– Alex
Nov 20 at 20:14












@Alex You're welcome!
– samcarter
Nov 20 at 20:19




@Alex You're welcome!
– samcarter
Nov 20 at 20:19










Alex is a new contributor. Be nice, and check out our Code of Conduct.










 

draft saved


draft discarded


















Alex is a new contributor. Be nice, and check out our Code of Conduct.













Alex is a new contributor. Be nice, and check out our Code of Conduct.












Alex is a new contributor. Be nice, and check out our Code of Conduct.















 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f461013%2flabel-blocks-inlcuding-section-number%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

How to change which sound is reproduced for terminal bell?

Can I use Tabulator js library in my java Spring + Thymeleaf project?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents