サブセクションのタイトルと参照の異なるラベル

サブセクションのタイトルと参照の異なるラベル

私は論文を作成中で、レポート クラスのバリアントを使用しています。章、セクション、サブセクション、サブサブセクションが所々にあります。テキストを読むときに、サブセクションとサブサブセクションのタイトルに長い数字、文字、ローマ数字の文字列があると見栄えが悪くなります。これらのタイトルには、関連するサブセクションまたはサブサブセクションのタイトルのみを含め、次のようにします。

\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}

結果:

結果

関連情報