
セクションなどを再定義すると、参照内の番号付けが正しくなくなります。
私のMWEは次のとおりです:
\documentclass[twoside]{book}
% possibility to have sections etc. be within the margins
\makeatletter
\newcommand{\doxysection}{\@ifstar{\doxysection@star}{\doxysection@nostar}}
\newcommand{\doxysection@star}[1]{\begingroup\sloppy\raggedright\section*{#1}\endgroup}
\newcommand{\doxysection@nostar}[1]{\begingroup\sloppy\raggedright\section{#1}\endgroup}
\makeatother
\usepackage[pdftex,pagebackref=true]{hyperref}
\hypersetup{ colorlinks=true, linkcolor=blue, citecolor=blue, unicode }
\begin{document}
\chapter{Special Commands}
\doxysection{Introduction}
\begin{list}{}
\item \contentsline{section}{\mbox{\hyperlink{commands_cmdaddtogroup}{addtogroup}}}{\ref{commands_cmdaddtogroup}}{}
\item \contentsline{section}{\mbox{\hyperlink{commands_cmdcallgraph}{callgraph}}}{\ref{commands_cmdcallgraph}}{}
\item \contentsline{section}{\mbox{\hyperlink{commands_cmdhidecallgraph}{hidecallgraph}}}{\ref{commands_cmdhidecallgraph}}{}
\end{list}
\hypertarget{commands_cmdaddtogroup}{}\doxysection{addtogroup}\label{commands_cmdaddtogroup}
\hypertarget{commands_cmdcallgraph}{}\section{callgraph}\label{commands_cmdcallgraph}
\hypertarget{commands_cmdhidecallgraph}{}\doxysection{hidecallgraph}\label{commands_cmdhidecallgraph}
\end{document}
出力は次のようになります:
この例では、セクション定義で、最初のセクションには再定義されたセクションを使用し、セクション セクションには元のセクションを使用し、3 番目のセクションには再び再定義されたセクションを使用しました。
ここで、最初の参照はセクション 1 を参照していますが、これは 1.2 であるべきです。2 番目の参照は正しいですが、3 番目の参照はやはり間違っています。これは 1.3 ではなく 1.4 であるべきです。
セクションを再定義すると、新しいコマンド内で「番号付け」がインポート/更新されないようです。
(tex コードは、doxygen から通常自動的に生成されるコードからの抜粋です。)
この問題をどうすれば解決できますか?
答え1
セクション タイトルの周囲にグループ化を使用していますが、ラベル名がローカルに保存されるため、\label システムが破壊されます。
次のようにして、独自のセクションコマンドを正しく定義することをお勧めします\@startsection
。
\documentclass[twoside]{book}
% possibility to have sections etc. be within the margins
\makeatletter
\newcommand\doxysection{\@startsection {section}{1}{\z@}%
{-3.5ex \@plus -1ex \@minus -.2ex}%
{2.3ex \@plus.2ex}%
{\raggedright\normalfont\Large\bfseries}}
\makeatother
\usepackage[pagebackref=true]{hyperref}
\hypersetup{ colorlinks=true, linkcolor=blue, citecolor=blue, unicode }
\usepackage{lipsum}
\begin{document}
\chapter{Special Commands}
\doxysection{Introduction}
\begin{list}{}
\item \contentsline{section}{\mbox{\hyperlink{commands_cmdaddtogroup}{addtogroup}}}{\ref{commands_cmdaddtogroup}}{}
\item \contentsline{section}{\mbox{\hyperlink{commands_cmdcallgraph}{callgraph}}}{\ref{commands_cmdcallgraph}}{}
\item \contentsline{section}{\mbox{\hyperlink{commands_cmdhidecallgraph}{hidecallgraph}}}{\ref{commands_cmdhidecallgraph}}{}
\end{list}
\hypertarget{commands_cmdaddtogroup}{}\doxysection{addtogroup}\label{commands_cmdaddtogroup}
\hypertarget{commands_cmdcallgraph}{}\section{section}\label{commands_cmdcallgraph}
\hypertarget{commands_cmdhidecallgraph}{}\doxysection{hidecallgraph}\label{commands_cmdhidecallgraph}
\end{document}