I have a problem when I use a cross-reference from other files. I have a folder in which there is a main.tex
file and a subfolder (Chapter) containing Chapter1.tex
and Chapter2.tex
.
In the main file, I include only the chapter files like this:
\include{Chapters/Chapter1}
\include{Chapters/Chapter2}
My problem is that in the Chapter2.tex
file I need to reference a section from Chapter1.
Chapter1.tex
\documentclass{standalone}
\begin{document}
\chapter{chapter}
\label{ch:first_chapter}
\section{first section}\label{sc:first_section}
some Text..........
\end{document}
Chapter2.tex
\documentclass{standalone}
\usepackage{xr-hyper}
\usepackage{hyperref}
\externaldocument[C1-]{/Chapter1}
\begin{document}
\chapter{Second Chapter}
\label{ch:second_chapter}
\section{section}\label{sc:first_section_ch2}
Some text...text \ref{C1-sc:first_section}
\end{document}
When I compile the file, only ??
appears.
Best Answer
I don't think
\chapter
is defined for the standalone document class. Besides this, for me this sounds more like a job for thesubfiles
package then forstandalone
:main.tex:
and chapter1.tex
and chapter2.tex
(the above example assumes that all 3 files are in the same folder, for the usage of subfolders, you have to adjust the paths of the main file and the chapter files accordingly)