0

In {article} environment, I have the following code:

\begin{enumerate}[\textit{Stage} $(1)$]
\item \label{st0} Something
    \item \label{st1} Something1
    \item \label{st2} Something2
\end{enumerate}

Through the paper, when I call

\ref{st1}

it immediately writes "Stage 2" with a hyperlink. However, I cannot reproduce it in beamer. In particular, it only prints "1".

Do you have any clue on how to fix this?

Thanks in advance!!

Edit. Compilable Example.

\documentclass[english]{beamer}
\usepackage{lmodern}
\renewcommand{\sfdefault}{lmss}
\renewcommand{\ttdefault}{lmtt}
\usepackage[T1]{fontenc}
\usepackage{amstext}
\hypersetup{
    colorlinks,
    citecolor=blue,
    linkcolor=blue
}
\usepackage{amsmath, amsthm, amssymb}
\newtheorem{prop}{Proposition}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage[authoryear]{natbib}
\makeatletter
\newcommand\makebeamertitle{\frame{\maketitle}}
\AtBeginDocument{
  \let\origtableofcontents=\tableofcontents
  \def\tableofcontents{\@ifnextchar[{\origtableofcontents}{\gobbletableofcontents}}
  \def\gobbletableofcontents#1{\origtableofcontents}}
  \makeatletter
\renewcommand{\itemize}[1][]{%
    \beamer@ifempty{#1}{}{\def\beamer@defaultospec{#1}}%
    \ifnum \@itemdepth >2\relax\@toodeep\else
    \advance\@itemdepth\@ne
    \beamer@computepref\@itemdepth% sets \beameritemnestingprefix
    \usebeamerfont{itemize/enumerate \beameritemnestingprefix body}%
    \usebeamercolor[fg]{itemize/enumerate \beameritemnestingprefix body}%
    \usebeamertemplate{itemize/enumerate \beameritemnestingprefix body begin}%
    \list
    {\usebeamertemplate{itemize \beameritemnestingprefix item}}
    {\def\makelabel##1{%
            {%
                \hss\llap{{%
                        \usebeamerfont*{itemize \beameritemnestingprefix item}%
                        \usebeamercolor[fg]{itemize \beameritemnestingprefix item}##1}}%
            }%
        }%
    }
    \fi%
    \setlength\itemsep{\fill}
    \ifnum \@itemdepth >1
     
    \fi%  
    \beamer@cramped%
    \raggedright%
    \beamer@firstlineitemizeunskip%
}
\def\enditemize{\ifhmode\unskip\fi\endlist%
    \usebeamertemplate{itemize/enumerate \beameritemnestingprefix body end}
    \ifnum \@itemdepth >1
    \vfil
    \fi%  
}
\makeatother
\setbeamercovered{transparent}
\makeatother
\usepackage[english]{babel}
\setbeamercolor{math text}{fg=black!15!blue}
\setbeamertemplate{footline}[frame number]
\begin{document}
\title{Example
\today }
\begin{frame}{Stages}
\begin{center}
\begin{enumerate}[\textit{Stage} $(1)$]
\item \label{st0} Something happens.
\vspace{5mm}
    \item \label{st1} Something happens.
    \vspace{5mm}
    \item \label{st2} Something happens.
    \vspace{5mm}
    \item \label{st3} Something happens.
    \end{enumerate}\end{center}
\end{frame}
\begin{frame}{Call the Stage}
    \begin{itemize}
        \item \ref{st1}
    \end{itemize}
\end{frame}
\end{document}

Edit 2

See the attached article example.

 \documentclass[english,12pt]{article}
\usepackage[T1]{fontenc}
\usepackage{newpxtext,newpxmath}
\usepackage{palatino}
\usepackage{longtable}
\usepackage{rotating}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{geometry}
 \geometry{
 a4paper,
 left=3.175cm,
 right=3.175cm,
 top=3.175cm,
 bottom=3.175cm,
 }
\usepackage{amssymb}
\usepackage{float}
\usepackage[shortlabels]{enumitem}
\usepackage{graphicx}
\usepackage{appendix}
\usepackage{pgfplots}
\usetikzlibrary{patterns,decorations.pathreplacing}
\pgfplotsset{compat=1.10}
\usepackage{setspace}
\usepackage[round]{natbib}
 \linespread{1.25}
\usepackage{xcolor}
\setcitestyle{square}
\usepackage{hyperref}
\usepackage{tgpagella}
\hypersetup{
  colorlinks,
  citecolor=blue,
  linkcolor=blue,
  urlcolor=blue}
\makeatletter
\numberwithin{equation}{section}
\numberwithin{figure}{section}
\numberwithin{table}{section}
\interfootnotelinepenalty=10000
\usepackage{mdframed}
\mdfdefinestyle{myenvs}{%
  hidealllines=true,%
  nobreak=true, % comment this to allow breaking
  leftmargin=0pt,
  rightmargin=0pt,
  innerleftmargin=0pt,
  innerrightmargin=0pt,
}
\newmdtheoremenv[style=myenvs]{prop}{Proposition}
\newtheorem{corollary}{Corollary}
\newmdtheoremenv[style=myenvs]{Lemma}{Lemma}
\usepackage{blindtext}
\usepackage{thmtools}
\usepackage{authblk}
\makeatother
\providecommand{\Propositionname}{Proposition}
\providecommand{\theoremname}{Theorem}

\begin{document}
\title{Example}
}
\author{me}
\date{\today}
\maketitle
\thispagestyle{empty}
\textbf{Keywords}
\newpage{}
\maketitle
\clearpage
\setcounter{page}{1}
\newpage
\section{Example}
\begin{enumerate}[\textit{Stage} $(1)$]
\item \label{st0} Something happens.
    \item \label{st1} Example.
\end{enumerate}
In \ref{st0}, something happens.
\end{document}
10
  • 1
    Can you make a compilable example? Are you using the enumitem package? That might not be the best idea in beamer... Feb 3, 2023 at 16:57
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Feb 3, 2023 at 17:02
  • @samcarter_is_at_topanswers.xyz I have provided an example. I hope it is clear now. Thanks for your comment
    – MaB21
    Feb 3, 2023 at 17:04
  • 1
    I can not reproduce your claim that it works in article. By default enumerate has no optional argument, and with the enumerate package the \ref simply gives 2. Feb 3, 2023 at 17:11
  • 1
    your example errors, but apart from this it uses enumitem (which is not really compatible with beamer as it breaks the overlay functions). Feb 3, 2023 at 17:33

1 Answer 1

-1

You may use enumitem package:

\documentclass{beamer}
\usepackage{enumitem}
\begin{document}
\begin{frame}
\begin{enumerate}[label=\textit{Stage (\arabic*)}]
    \item \label{st0} Something
    \item \label{st1} Something1
    \item \label{st2} Something2
\end{enumerate}
\end{frame}
\begin{frame}
This is a reference to \ref{st1}.
\end{frame}
\end{document}
3
  • Maybe my comment was ambiguous, I did not want to imply that one could use the enumitem package with beamer. That's not a good idea. It will make itemize bullets disappear and some other "funny" side effects. I was just wondering where the non-standard syntax of the first code fragment came from. Feb 3, 2023 at 19:46
  • @samcarter_is_at_topanswers.xyz Thanks a lot for your answer! Your code works if I open a new project, but unfortunately does not work if I use it in my example. What is the non-standard syntax in my code?
    – MaB21
    Feb 3, 2023 at 21:00
  • @Andrey L. Thanks a lot for your answer! Your code works if I open a new project, but unfortunately does not work if I use it in my example... Do you have any idea on why that happens?
    – MaB21
    Feb 3, 2023 at 21:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .