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.

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

1 Answer 1

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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .