
我正在建立我的論文,並使用報告類別的變體。我在某些地方有章節、小節、小節和小節。閱讀文本時,小節和小節的標題中有一長串數字、字母和羅馬數字,看起來很不舒服。我希望這些標題只有相關的小節或小節標題,並使用以下方法來實現:
\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}
結果: