This is a follow-up to the question Cross-referencing in multiple chapters. Following the answer to this question, I am using the following macros:
\newcommand*\maybechapter[1]{%
% Tests if current chapter is equal to the chapter number of label)
\ifnum\value{chapter}=0#1\relax
% Print nothing if so
\else
% Set 'chapter' locally (=> no \setcounter) to the label chapter and
% print it in the usual format followed by a dot
{\value{chapter}=#1\relax\thechapter.}%
\fi
}
\renewcommand*\thesection{%
\protect\maybechapter{\arabic{chapter}}\arabic{section}%
}
This works as expected for references but in the Table of contents, section numbers are now all preceded by their chapter numbers:
I The first chapter
I.1 The first section of the first chapter
but I would like to get something like
I The first chapter
1 The first section of the first chapter
How should I modify \maybechapter to get this result?
