我对 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}
在 Beamer 文章输出中,它如下所示:
\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}
我必须做什么才能让引用在 Beamer 模式下显示为 $sectionnumber.$subsectionnumber ?
答案1
简单地重新定义一下\thesubsection
就可以达到目的:
\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}
如果章节编号只应出现在参考文献中,但\thesubsection
不应更改,则为\p@subsection
参考文献定义一个前缀:
\makeatletter
\@namedef{p@subsection}{\thesection.}
\@namedef{p@subsubsection}{\thesection.\arabic{subsection}.}
\makeatother
答案2
您可以在序言中添加以下说明:
\usepackage{chngcntr}
\counterwithin{subsection}{section}