## LaTeX forum ⇒ General ⇒ Issue when cross-referencing with short chapter names

LaTeX specific issues not fitting into one of the other forums of this category.
Loupiote3
Posts: 2
Joined: Tue Jul 31, 2018 2:47 pm

### Issue when cross-referencing with short chapter names

Hi all,

Sorry if this already has an answer somewhere, I have been pulling my hair out trying to solve this for a while now (beginner alert).

I am writing a thesis in the book format, and some of my chapters have very long titles. Accordingly, I have given them short titles so that the headers do not overflow, like such:

\chapter[short title]{Awfully long title that won't fit in a header}

So far, so good.
Now, I am wanting to reference some of my chapters in the text, like this:

This is adressed at length in Chapter 2.

I tried labelling the chapter in question, and calling the reference in the text using \ref{label}.
Now here is my problem: even though I introduced the label straight after the \chapter command, like this:

\chapter[short title]{Awfully long title that won't fit in a header}
\label{ch:chaptername}

The reference in the text appears as "This is adressed at length in Chapter 2.5".
There are 5 sections in chapter 2, but I want to reference the whole chapter, not section 2.5.

I have noticed that this does not happen if I remove the short title for the chapter, so that this code allows me to reference Chapter 2 just fine:

\chapter{Awfully long title that won't fit in a header}
\label{ch:chaptername}

\ref{ch:chaptername}

When I add the short title, the backslash in front of "chapter" does not appear in bold anymore, and it seems like the counter gets upset.

Has anyone had that problem and did you manage to solve it?

Tags:

Johannes_B
Site Moderator
Posts: 3933
Joined: Thu Nov 01, 2012 4:08 pm
Welcome to the forum.

The behaviour you describe isn't normal. Something in your document, most likely in the preamble causes this problem. We don't know your preamble, though. Can you post a minimal working example, meaning your complete preamble and a test chapter? Please copy the code first to a new directory and see if it is compiling and showing the behaviour.

Regarding the bold thing: This is just syntax highlighting done by the editor software.

\documentclass{book}\usepackage{scrlayer-scrpage}\usepackage{mwe}\begin{document}\chapter[MR]{Manta Ray}\label{ch:mantarey}\blindtext see \ref{ch:mantarey}\section{Taxonomy}\blindtext[10]\chapter{Mobula}\blindtext\section{Life style}\blindtext[10]\end{document}

The above is a minimal working example showing that the behaivour does not occur by default. You can click on Open in Overleaf just above the code block to see the output.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

Loupiote3
Posts: 2
Joined: Tue Jul 31, 2018 2:47 pm
Hi Johannes,

Many thanks for your reply and sorry for not posting a minimal working example straight away, I wasn't sure how to go about it. I tried running your code on my laptop and - no surprises there - it worked perfectly fine. Then I ran your example with my preamble and it worked too...
Then I compiled my document again and, there's the surprise, it worked as well. I didn't change anything in the preamble, and I don't remember having changed anything that could have affected this behaviour anywhere else either, so I will just be grateful it works and keep my surprise in check for today. I am wondering if this could be a matter of recompiling the references again and again - I did do a few cycles of F11 + compile before I posted the question, but...

Many thanks again for your help and all the best,

Lou

Johannes_B
Site Moderator
Posts: 3933
Joined: Thu Nov 01, 2012 4:08 pm
Problem solved for now? Great.

Feel free to post more questions.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.