我正在构建我的论文,并使用报告类的变体。我在某些地方有章节、节、小节和小小节。阅读文本时,小节和小小节的标题中有一长串的数字、字母和罗马数字,看起来很不愉快。我希望这些标题只包含相关的小节或小小节标题,并使用:
\renewcommand\thesubsection{\Roman{subsection}}
(根据最终结果,我可能会包括章节计数器,但我肯定会删除章节计数器。)但是,当我引用子节或子子节时,我更希望使用整个数字串,否则引用定义不明确。有人可以评论如何做到这一点吗?
这是一个最小的例子。
\documentclass{report}
\begin{document}
\renewcommand\thesection{\arabic{chapter}.\arabic{section}}
\renewcommand\thesubsection{\Roman{subsection}}
\chapter{Chapter}
\section{Section}
\subsection{Subsection}\label{subsection}
\noindent I have the subsections labelled in Roman in the title, because 1.1.I would just be long.
\\
\noindent Here is a reference to the subsection: (\ref{subsection})
\\
\noindent I would like references to the subsection to be (1.1.I), however.
\end{document}
答案1
重新定义\p@subsection
(用于引用小节的前缀):
\documentclass{report}
\renewcommand\thesection{\arabic{chapter}.\arabic{section}}
\renewcommand\thesubsection{\Roman{subsection}}
\makeatletter
\renewcommand\p@subsection{\thesection.}
\makeatother
\begin{document}
\chapter{Chapter}
\section{Section}
\subsection{Subsection}\label{subsection}
\noindent I have the subsections labelled in Roman in the title, because 1.1.I would just be long.
\noindent Here is a reference to the subsection: (\ref{subsection})
\end{document}
顺便说一句,永远不要使用该组合\\ + blank line
;这将生成箱子未满的警告。
答案2
引用可以自动加上前缀\p@<counter>
,看例子:
\documentclass{report}
\usepackage{parskip}
\renewcommand\thesection{\arabic{chapter}.\arabic{section}}
\renewcommand\thesubsection{\Roman{subsection}}
\makeatletter
\renewcommand*{\p@subsection}{\thesection.}
\makeatother
\begin{document}
\chapter{Chapter}
Here is a reference to the subsection: \ref{subsection}
\section{Section}
\subsection{Subsection}\label{subsection}
\end{document}
结果: