4

I am having trouble with the format of the referenced subsection in Beamer

\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage{default}
\begin{document}
\section{mysection}
\subsection{mysubsection}\label{subsec:mysubsection}
\begin{frame}
\ref{subsec:mysubsection} % displayed as 1 , but should be 1.1
\end{frame}
\end{document}

In Beamer article output it is as excepeted:

\documentclass{article}
\usepackage{beamerarticle}
\usepackage[utf8]{inputenc}
\usepackage{default}
\begin{document}
\section{mysection}
\subsection{mysubsection}\label{subsec:mysubsection}
\begin{frame}
\ref{subsec:mysubsection} % displayed ok as 1.1
\end{frame}
\end{document}

What do I have to do, that the reference is displayed in Beamer mode as $sectionnumber.$subsectionnumber ?

  • 1
    \renewcommand\thesubsection{\thesection.\arabic{subsection}} (this can affect other places where the number is used). – Ulrike Fischer Jun 24 '15 at 9:02
2

A simple redefinition of \thesubsection does the trick:

\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage{default}

\renewcommand*{\thesubsection}{\thesection.\arabic{subsection}}
\renewcommand*{\thesubsubsection}{\thesubsection.\arabic{subsubsection}}

\begin{document}
\section{mysection}
\subsection{mysubsection}\label{subsec:mysubsection}
\begin{frame}
\ref{subsec:mysubsection}
\end{frame}
\end{document}

Result

If the section number should only appear in references, but \thesubsection should not be changed, then \p@subsection defines a prefix for the references:

\makeatletter
\@namedef{p@subsection}{\thesection.}
\@namedef{p@subsubsection}{\thesection.\arabic{subsection}.}
\makeatother
| improve this answer | |
1

You could add the following instructions to the preamble:

\usepackage{chngcntr}
\counterwithin{subsection}{section}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.