0

I have a problem with references in beamer (metropolis theme) and the use of include commands. Indeed, my presentation consists of several files. Each file is included via the include command.

The problem is that when I make a reference from these files, I have a problem of an undefined reference whereas if I make a reference from a frame in the master file, there is no problem. Do you have an idea ?

Just below the master file (MWE):

\documentclass[10pt]{beamer}
\usetheme[subsectionpage=progressbar]{metropolis}
\usepackage{appendixnumberbeamer}
\usepackage{booktabs}
\usepackage[scale=2]{ccicons}
\usepackage{xspace}
\newcommand{\themename}{\textbf{\textsc{metropolis}}\xspace}

\begin{document}
%  myfile included via include commande
\include{./myfile}   

% reference here works fine
\begin{frame}  
   The reference here works fine \cite{ridge04}
\end{frame}

    \begin{frame}[allowframebreaks]{Références}
  \bibliography{./biblio/biblio}
  \bibliographystyle{abbrv}
\end{frame}
\end{document}

myFile.tec looks like this:

\section{Contribution}
\begin{frame}
The reference does not work here  \cite{ridge04} !
\end{frame}
  • 1
    Any specific reason to use \include? If not, use \input. – Phelype Oleinik Feb 5 '18 at 12:30
  • 1
    Try to rename your file to myfile.tex – user36296 Feb 5 '18 at 13:16
  • @samcarter it's just a typo in my question. – FiesAtoS Feb 5 '18 at 13:49
  • @FiesAtoS So your real file is names myfile.tex and not myFile.tex? – user36296 Feb 5 '18 at 13:52
  • 1
    @FiesAtoS Can you test (in another folder so no files will be overwritten) if pastebin.com/AWUeDyf2 works for you? – user36296 Feb 5 '18 at 13:54
2

The solution here is to replace the \include by \input.

The \input{file} command is equivalent to copy-pasting the contents of file to the place where the \input is called.

The \include{file} command, on the other hand, does a few other fancies. It does a \clearpage before and after including the contents of the file and creates a separate .aux for the included file. [reference]

Generally \include is used when writing something like a book, when you want the sections heads on separate pages. Otherwise \input can be used.

(My 2 cents: I always use \input and take care of the page breaking manually just to avoid the multiple .aux files).

There is something in your file that breaks the cross referencing for some reason I don't quite understand. It would be necessary more than a Minimal Working Example to see what's going on because the code from your MWE works perfectly.

TL;DR: The solution is to replace \include by \input to avoid the multiple .aux files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.