0

I had to declare \thesection without its fitting chapter. But the reference should always include the \thechapter. Does anyone has a workaround? I guess,

\let\origref\ref
\renewcommand\ref[1]{
    %ref to chapter.%
    \ref{#1}
}

Some more information

class: scrbook

hyperref is used

Tried things

I tried to use

\usepackage[nokeyprefix]{refstyle}
\chapref

but this refs on the section.

Heiko Oberdiek
  • 271,626
Shalec
  • 295
  • Possible dup of https://tex.stackexchange.com/a/13703/18414 – Hugh Dec 04 '17 at 08:21
  • Hm.. Probably I have to redefine ref and Label to use that. I need to apply This referencing to a huge document and the solution should be applied easyl – Shalec Dec 04 '17 at 08:26

1 Answers1

4

References can be prefixed by \p@<counter> that can be defined to contain \thechapter:

\documentclass{report}

% Section numbers without chapter number
\renewcommand*{\thesection}{\arabic{section}}

% Section references with chapter number
\makeatletter
\def\p@section{\thechapter.}
\makeatother

\begin{document}

\chapter{First chapter}
\section{First section}
\section{Second section}
\label{sec:second}
See section \ref{sec:second}.
\end{document}

Result

Heiko Oberdiek
  • 271,626
  • Thats the solution I was looking for. Thank you! I discovered, that we can easily enlarge this to subsection and subsubsection. – Shalec Dec 04 '17 at 08:37