# Beamer: label ref wrong display format

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 ?

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

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}


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


You could add the following instructions to the preamble:

\usepackage{chngcntr}
\counterwithin{subsection}{section}