# Renew only the reference on section part for \ref

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


class: scrbook

hyperref is used

# Tried things

I tried to use

\usepackage[nokeyprefix]{refstyle}
\chapref


but this refs on the section.

• Possible dup of tex.stackexchange.com/a/13703/18414 – Hugh Dec 4 '17 at 8: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 4 '17 at 8:26

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}


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