# Wrong label of chapter (using subfile) with glossary

I trying to have the good number when I refer the Chapter 2 of my Ph.D Thesis but without success.

I have four files, the main with a lot of packages and :

% Manuscrit.tex ----> Main files
\documentclass[a4paper,11pt,final,twoside]{book}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{subfiles}
\usepackage{xr-hyper}
\usepackage[dvipsnames]{xcolor}
\usepackage[pdftex,pagebackref=true]{hyperref}
\hypersetup{
citecolor=OliveGreen,
urlcolor=mymauve}
%Drawing
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,positioning,decorations,automata,backgrounds,calc,er,patterns}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{decorations.pathreplacing}

\externaldocument[Int-]{./Introduction/Introduction}
\externaldocument[I-]{./Chapitre_1/Chapitre_1}
\externaldocument[III-]{./Chapitre_3/Chapitre_3}

\usepackage{glossaries} % Ensures that all acronyms are defined once
\let\oldnewacronym\newacronym
\newcommand*{\provideacronym}[3]{%
\ifglsentryexists{#1}{%
}{%
\oldnewacronym{#1}{#2}{#3}%
}%
}
\makeglossaries

\newacronym{qgp}{QGP}{Quark Gluon Plasma}
\newacronym{epos}{EPOS}{Energy conserving multiple scattering Partons, parton ladders, and strings Off-shell remnants Saturation}
\newacronym{sm}{SM}{Standard Model}
\newacronym{qcd}{QCD}{Quantum ChromoDynamics}
% and other acronym

\begin{document}

\mainmatter
\subfile{./Introduction/Introduction.tex}
\subfile{./Chapitre_1/Chapitre_1.tex}
%\subfile{./Chapitre_2/Chapitre_2.tex}
\subfile{./Chapitre_3/Chapitre_3.tex}

\printglossaries

\end{document}


In Introduction.tex file :

\documentclass[./../Manuscrit.tex]{subfiles}

\begin{document}

\chapter{Introduction}
\label{chap:intro}
\end{document}


In Chapitre_1.tex :

\documentclass[./../Manuscrit.tex]{subfiles}

\begin{document}

Blabla ....
Finally, we will see few programs that we created to study the \acrlong{qgp} with particles colliders and the connection with my Ph.D work.

\chapter{High energy Physics - Matter - Quark-Gluon-Plasma}
\label{chap:context}

\section{Standard Model describes the known matter}

\begin{table}[h]
\begin{center}
\begin{tabular}{|c|c|c|}
\hline
Symbol & Description & Value \\
\hline
\hline
$m_e$ & Electron Mass & 511 KeV \\
\hline
$m_\mu$ & Muon Mass & 105.7 MeV \\
\hline
$m_\tau$ & Tau Mass & 1.78 GeV \\
\hline
$m_u$ & Up Quark Mass & 1.9 MeV \\
\hline
$m_d$ & Down Quark Mass & 4.4 MeV \\
\hline
$m_s$ & Strange Quark Mass & 87 MeV \\
\hline
$m_c$ & Charm Quark Mass & 1.32 GeV \\
\hline
$m_b$ & Beauty or Bottom Quark Mass & 4.24 GeV \\
\hline
$m_t$ & Truth or Top Quark Mass & 172.7 GeV \\
\hline
$\omega_{12}$ & \gls{ckm} 12-mixing angle & 13.1  \\
\hline
$\omega_{23}$ & \gls{ckm} 23-mixing angle & 2.4  \\
\hline
$\omega_{13}$ & \gls{ckm} 13-mixing angle & 0.2  \\
\hline
$\delta$ & \gls{ckm} CP-violating Phase & 0.995 \\
\hline
g' & U(1) gauge coupling & 0.357  \\
\hline
g & SU(2) gauge coupling & 0.652 \\
\hline
$g_s$ & SU(3) gauge coupling & 1.221  \\
\hline
$\theta_{QCD}$ & \gls{qcd} vacuum angle & $\approx$ 0  \\
\hline
v & Higgs vacuum expectation value & 246 GeV \\
\hline
$m_H$ & Higgs Mass & $\approx$ 125.36 GeV \\
\hline
\end{tabular}
\end{center}0
\caption{\label{tab:param_SM} 19 parameters in \acrlong{sm}}
\end{table}

\subsection{Description of the Standard Model}
\subsubsection{Formal Aspect of Standard Model}
\subsubsection{Interactions and particles in Standard Model}
\label{subsub:partSM}
\subsubsection{The architecture of Standard Model}
\subsection{Limitations of Standard Model}
\begin{figure}[h]
\begin{center}
\begin{tikzpicture}
\draw[thick,->,>=latex] (0,0) -- (13,0);
\draw[thick,->,>=latex] (0,0) -- (0,4.1)node[above]{$\alpha_s$};
\node at (12.5,-0.3){$\mu$};
\node at (1,-0.3){\small 1 GeV};
\node at (5,-0.3){\small $\approx$ TeV};
\node at (10,-0.3){\small Before Planck};
\node at (1.5,3.3){\small Confinment};
\node at (11,3.3){\small Asymptotic safety};
\draw[blue] (1,3) to[out=280,in=170] (5,0.4) to[out=-10,in=200] (9,0.8) to[out=20,in=230] (11,2.7) to[out=30,in=170] (12.8,2.85) ;
\node[red] at (2.2,2.2) {\tiny Light quarks};
\node[red] at (5,1.2) {\tiny Higgs Mechanism};
\node[red] at (5,0.7) {\tiny Top};
\node[red] at (8,2) {\tiny New colored states};
\draw[red,->,>=latex] (8,1.8) -- (9,0.8);
\end{tikzpicture}
\caption{Asymptotically safe scenario of \acrlong{qcd} expressed in terms of the running of $\alpha_s$}
\label{fig:qcdsafe}
\end{center}
\end{figure}

\subsection{Beyond the Standard Model}
\subsubsection{Supersymmetry}
\subsubsection{String Theory}
\subsection{Summary}

\section{One of the first matter in the Universe}
\subsection{Asymptotic Freedom}
\subsection{The beginning of Quark-Gluon Plasma in physics}
\subsection{Phases of nuclear matter}
\label{subsec:phamat}
\subsection{Heavy Ions Collisions}
\subsection{Summary}

\section{Studies of the Quark Gluon Plasma}
\subsection{Soft Probes}
\subsubsection{Photon}
\label{subsub:photon}
\subsubsection{Baryon enhancement}
\subsubsection{Transverse energy}
\subsubsection{Flow}
\label{subsec:flow}

\end{document}


And in the Chapitre_3 where I want to reference the chapter 1 (not the introduction)

\documentclass[./../Manuscrit.tex]{subfiles}

\externaldocument[I-]{./../Chapitre_1/Chapitre_1}

\begin{document}

\chapter{Methods to study of anisotropic flow}
\label{Chap:flow}

We see in the previous chapter the tool what I have used all of this Ph.D Thesis. In this chapter, I will show the analysis that I have done all this Ph.D Thesis. Typically, I had put some part of this chapter in the event generator \gls{epos} presented in the previous chapter.

\setlength{\parskip}{0.5cm}

The main observable of this Ph.D is the anisotropic flow that I had briefly introduce in the section \ref{I-subsec:flow} of the Chapter \ref{I-chap:context}. Consquently, this chapter will be dedicated of the history and tacticals to calculs the anisotropic flow. To recall the section \ref{I-subsec:flow} of the Chapter \ref{I-chap:context}.
\end{document}


But the results gives me :

The main observable of this Ph.D is the anisotropic flow that I had briefly introduce in the section 1.3.1 of the Chapter 1. Consquently, this chapter will be dedicated of the history and tacticals to calculs the anisotropic flow. To recall the section 1.3.1 of the Chapter 1.

The reference of the section is good but not the Chapter, I want to ref the Chapter 2 and not the Chapter 1. Why I have the Chapter 1 and how we can fix it ?

I put the \usepackage{xr-hyper} before hyperref and I remove xr but now I cannot compile because I have also a glossary with \acrlong command and now Latex does not recognize the command \acrlong. I have this error from both \acrlong in caption, but no error from \acrlong outside caption

I run makeglossary for each subfiles

Thanks

• You're posting the same incomplete code as in the first question. \usepackage{xcolor} is missing for Manuscript.tex ... where is the acrlong macro used which causes the error you reported? – user31729 Oct 30 '17 at 18:07
• Also: Why do you wonder that your reference yields Chapter I if you call label names from I-chap:... only. There is no reference to II- at all. – user31729 Oct 30 '17 at 18:18
• thanks for the comment, I try on my computer and all codes compile now. Exactly compiles but gives an error with \acrlong. If I remove \usepackage{xr-hyper} by \usepackge{xr} the compilation works but I find the problem of wrong reference – G. Sophys Oct 31 '17 at 22:15
• The problem is that \acrlong appears in \caption which writes the content directly to .lof or .lot. Add \protect\acrlong{sm} etc. for those entries that appear in the captions. And use the siunitx package for your physical units ;-) – user31729 Oct 31 '17 at 22:32

The problem is \acrlong when it is used inside of \caption or \section , which generates nested hyperlinks.

There is a clear warning about this in glossaries-user manual (screen shot taken from section 6, page 124 of current manual)

xr-hyper must be loaded before hyperref, as stated already in the first question that lead to this one.

Possible solutions

• Use \protect\acrlong{foo} inside of \caption.
• Use \caption[Text for List Of Table]{Text for caption below the table}

I won't post the files from the O.P. again here.

• With your comment and answer I using \protect\acrlong{foo} and I can compile all files but I still keep the wrong reference of Chapter. Sorry I do not understand the files from the O.P.. Hum here xr-hyper is already loaded before hyperref. Isn'it ? – G. Sophys Oct 31 '17 at 23:00
• @G.Sophys: Again: You're using only \ref{I-...} like references, so this is grabs the references from the first chapter, since \externaldocument[I-]{../Chapitre_1/Chapitre_1} is used. I don't know why you expect references from Chapter 2 (which is most likely Chapitre_3 here) should appear. – user31729 Oct 31 '17 at 23:05
• @G.Sophys: Yes, xr-hyper is loaded correctly before here, I wanted to emphasize this. And I don't want to post a bunch of files here again where basically no change other than \protect is to be used. It is very tedious to track those multiple files. I am no fan of subfiles anyway – user31729 Oct 31 '17 at 23:07
• Aaaah Okay ! I apologize, I misspoke. for me The Chapter 1 is the introduction, the Chapter 2 is the chapter in the Chapitre_1 file. Because I ref the Chapitre_1 but Introduction poss also a number of chapter (the one) I refer on the Chapter 2 and not the one – G. Sophys Oct 31 '17 at 23:11
• @G.Sophys: Perhaps you should use \chapter*{Introduction} rather, i.e. an unnumbered chapter? – user31729 Oct 31 '17 at 23:12