1

I'm compiling the main frame file that has several chapters takes as an \input from different files. In the Introduction file I'm referencing the single chapters but instead of getting as a result just the number of the chapter, I get as a result chapterNumber.randomSectionNumber. Any ideas on what it might be causing this problem?

Main file:

\documentclass[a4paper,12pt,twoside,openright]{report}

\begin{document}
\title{Something}\\
\normallinespacing
\maketitle

\chapter{Introduction}
\input{Introduction}

\part{Part1}
\chapter{Chapter 1}
\input{chapter1}
\label{chap:1}

\chapter{Chapter 2}
\input{chapter2}
\label{chap:2}

\part{Part 2}
\chapter{Chapter 3}
\input{chapter3}
\label{chap:3}

\bibliographystyle{splncs}
\bibliography{bibliography}

\end{document}

Introduction file:

in Chapter ~\ref{chap:2}, in Chapter ~\ref{chap:3}.

Chapter file

text
\section{1}
text
\section{n}
text
2
  • 1
    Your \label{chap:1} etc. is too late! You have to put it directly after \chapter{Chapter 1}, otherwise \label will use the next counter being fed to \refstepcounter in your \input files, e.g. a section or equation
    – user31729
    Dec 29, 2016 at 8:42
  • @ChristianHupfer I put it right after the \chapter{} and now it works. Thanks!
    – Barbara
    Dec 29, 2016 at 8:46

1 Answer 1

1

As @ChristianHupfer stated in his comment: you have to use the \label command directly after you issued any \chapter or \section-command.

The \label-command will store the last changed counter. If the last changed counter in your included files was, for example, an equation, than the label would reference that equation counter.

\part{Main Part}
\chapter{Chapter 3}\label{chap:3}

should give correct references.

2
  • The answering force is strong in you ;-)
    – user31729
    Dec 29, 2016 at 9:04
  • 1
    \LaTeX you must!
    – Jan
    Dec 29, 2016 at 9:26

You must log in to answer this question.

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