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.

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

  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.