# \includeonly not including parts correctly because of _ in the file name and breqn

I am trying to use

\include{...}


and

\includeonly{...}


to structure my thesis and faster compile the document. As long as I only use \include{...} everything works fine. But once I try to use \includeonly{...} in the preamble I only get the table of contents, the list of figures and tables and the Bibliography but no actual content. I don't know what I am doing wrong. I tried to remove some packages I am using but so far I couldn't find one that causes the problem. In case it matters every "part" consists of \chapter{...} parts, \section{...}and \subsection{...} parts including text, tables and figures. Here is what I have in my main document (I left the whole preamble in case one of the packages I use causes the problem):

\documentclass [a4paper,12pt,DIV=10,BCOR=0.5cm]{scrreprt}
\usepackage[german, english]{babel}
\usepackage{cite}
\usepackage[pdftex]{graphicx}
\graphicspath{{Pictures/}}
\usepackage{hyperref}
\usepackage{textgreek}
\usepackage[toc,page]{appendix}
\usepackage{sidecap}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{breqn}
\usepackage{tabularx}
\usepackage{tabu}
\usepackage[font=small,format=plain,labelfont=bf,up,textfont=it,up]{caption}
\usepackage{fixltx2e}

\includeonly{part_1}

\begin{document}

\pagenumbering{Roman}

\include{titlepage}

\setcounter{page}{0}

\tableofcontents
\listoffigures
\listoftables

\include{abstract}

\pagenumbering{arabic}

\include{part_1}

\include{part_2}

\include{part_3}

\bibliography{thesis.bib}{}
\bibliographystyle{unsrt}

\end{document}


After some try and error I found an answer:

There seems to be an issue with using _ in file names when using \includeonly. By using only file names without _, like part1 or part-1 everything seems to work fine. Strangely there are documentations about \include and \includeonly that use _ in their file names like this one here: http://en.wikibooks.org/wiki/LaTeX/Modular_Documents

• You have to use \includeonly in conjunction with \include - they are not exclusive. So use \includeonly in the preamble and \include in the document body. The file(s) mentioned in \includeonly should also be contained in some \include command. – Werner Jun 25 '13 at 21:05
• @David Carlisle: I don't get any error just a lot of warnings like this:"pdfTeX warning (dest): name{table.caption.8} has been referenced but does not e xist, replaced by a fixed one" regarding your second comment: I don't have any nested include parts if you mean that. The only thing I include in the separate parts are graphics. – Marty Jun 25 '13 at 21:18
• @Werner: I think did that as you can see in the example text. – Marty Jun 25 '13 at 21:19
• @David Carlisle: To generate the example I changed the names of my files from PhD_thesis_partx to partx but I haven't actually tried that code until now. Now that I tried it I figured out that once I use names without _ it works fine. Strangely \include accepts names containing _ but \includeonly does not. Can that actually be the case? It is correct that when I use \includeonly that only that part is displayed and the rest not right. Do you know if there is also a way to display the other parts but not compile them? – Marty Jun 25 '13 at 22:00
• @David Carlisle: It seems the breqn package in combination with \includeonly and _ seems to cause that bug. Damn that was hard to find. I thought I tried that out before but now it seems reproducible, at least for me. Could you try that as well? – Marty Jun 25 '13 at 23:01

It's breqn.

Making your example a bit more minimal

\documentclass [a4paper,12pt,DIV=10,BCOR=0.5cm]{scrreprt}

\usepackage{cite}
\usepackage[pdftex]{graphicx}

\usepackage{breqn}

\includeonly{part\string_1}

\begin{document}

\pagenumbering{Roman}

If you comment out breqn it works without the \string with breqn you need to make a safe _.