GeneralMain file not compiling anymore

LaTeX specific issues not fitting into one of the other forums of this category.
poeli
Posts: 19
Joined: Tue Mar 11, 2014 10:59 am

Main file not compiling anymore

Post by poeli »

Hi all,

I have a main thesis document in which i put the various chapters. Now I finished another chapter. When I Want to compile the main file, I get following error:

! LaTeX Error: Can be used only in preamble.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.1 \documentclass
[11,a4paper,twoside, openodd, final]{report}
Your command was ignored.
Type I <command> <return> to replace it with another command,
or <return> to continue without it.

The red errors all go to my titlepage. So I tried removing the input titlepage, without a result, the same errors come up but now my abstract giving the error. This is a copy of my original file, as my original file gave the following error:

! Text line contains an invalid character.
l.3

All red errors in this file refer to line 3, which is \usepackage [section]{placeins}.

Posting a minimal working example probably doesn't make any sense as all the files in it are missing for you guys...I hope someone can help me out! Please note, i haven't changed a thing in my main file, only added some text (no formula's or even images) to one of the chapters.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10330
Joined: Mon Mar 10, 2008 9:44 pm

Main file not compiling anymore

Post by Stefan Kottwitz »

Possibly you include a document, which itself starts like a document with \documentclass.

Perhaps post the .log file as an attachment to a forum post. This information could be useful.

Stefan
LaTeX.org admin
poeli
Posts: 19
Joined: Tue Mar 11, 2014 10:59 am

Main file not compiling anymore

Post by poeli »

Code: Select all

\documentclass[11]{book}
\usepackage{amssymb,amsmath,nccmath,graphicx}
\usepackage[section]{placeins}
\usepackage{fixltx2e}
\usepackage{titlesec}
\usepackage{hyperref}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{caption}
\usepackage{nomencl}

\begin{document}
\nocite{*}
\input{titlepage}

\chapter*{Abstract}
\input{abstract}

\chapter*{Dedication}
The price of success is hard work, dedication to the job at hand, and the determination that whether we win or lose, we have applied the best of ourselves to the task at hand.

\chapter*{Declaration}


\chapter*{Acknowledgements}
I want to thank my promotor, XXXXXXXX for guiding me through this thesis and the 3 years at the VUB in general. I also want to thank my co-promotorsXXXXX and XXXXXXXXXX, for the practical advices and change of thoughts. I'd also like to thank XXXXXXXXXX to book the semi-anechoic room at the XXX campus. Last but not least, I'd like to thank my family and close friends for their support on this long journey.
\tableofcontents

\listoffigures
\listoftables

\begin{figure}

\centerline{\includegraphics{nomencl}}

\end{figure}


\chapter{Introduction}
\input{hoofdstuk1}

\chapter{Theoretical background}
\input{hoofdstuk2}

\chapter{Test setup}
\input{hoofdstuk3}

\chapter{Results}
\input{hoofdstuk4}


\chapter{Conclusion}
\input{conclusion}


\chapter{Recommendations}
\input{recommendations}

\chapter{Acknowledgments}
\input{acknowledgements}

\bibliographystyle{plain}
\bibliography{referenties}

\chapter{Appendices}
\input{appendices}

\end{document}
Stupid question maybe, in Texmaker, how can I get the .log file? I see the .log file but how do I export it to a file. I googled it but don't find much useful information there.
Last edited by Stefan Kottwitz on Sun Apr 27, 2014 2:50 pm, edited 1 time in total.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10330
Joined: Mon Mar 10, 2008 9:44 pm

Main file not compiling anymore

Post by Stefan Kottwitz »

Your document uses the book class, as we can see in the first line. However, the error shows report in \documentclass[11,a4paper,twoside, openodd, final]{report}. So you are loading report in one of your files.

It's obviously not another package, since that error message and your document show the same wrong class option 11, there is no such option, you probably mean 11pt.

The .log file is stored in the same folder as the main document.

Stefan
LaTeX.org admin
poeli
Posts: 19
Joined: Tue Mar 11, 2014 10:59 am

Main file not compiling anymore

Post by poeli »

I changed all the files to book and included 11pt instead of 11. But this still gives me the same errors. I suppose the .log file is this one:
https://www.dropbox.com/s/9dgpobjma9yqo ... elling.log

I'm not a hero in reading the .log file. Is it common that Texmaker just can't compile anymore without changing anything to the main file? I originally had an error with chapter 4, which gives me "A funny symbol that I can't read has just been input.
Continue, and I'll forget that it ever happened."
The log file of this chapter is this one:
https://www.dropbox.com/s/qaqdm4tbnjs04 ... dstuk4.log
User avatar
Stefan Kottwitz
Site Admin
Posts: 10330
Joined: Mon Mar 10, 2008 9:44 pm

Main file not compiling anymore

Post by Stefan Kottwitz »

Please always attach files directly to a forum post, don't post external links to files. We don't want users to be forced to visit dropbox or other file hosters.

Your chapter 4 loads the report document class. However, it should not call a document class, it simply uses the class of the main document. A chapter file should not have a preamble, it should not have a \documentclass or \usepackage command, except a rare case that it will be independently compiled. In that case it cannot be loaded via \include or \input. You cannot mix document classes.

Stefan
LaTeX.org admin
poeli
Posts: 19
Joined: Tue Mar 11, 2014 10:59 am

Re: Main file not compiling anymore

Post by poeli »

Sorry for the attachments, will remember in the future. Removing all the usepackages and document classes doesn't make a change it seems. Error still continues. It really amazes me, as I only have added some text and it used to work before. It's the first time I see this error appear. Thanks for clearing some things for me.
Attachments
Samenstelling.log
(39.46 KiB) Downloaded 401 times
User avatar
Stefan Kottwitz
Site Admin
Posts: 10330
Joined: Mon Mar 10, 2008 9:44 pm

Main file not compiling anymore

Post by Stefan Kottwitz »

It seems to start here:

Code: Select all

C:\Users\Poelaertp\Dropbox\Masterproef\Hoofdstukken\Samenstelling.aux
! Text line contains an invalid character.
So there's a problem reading the .aux file. Delete Samenstelling.aux and compile again. That .aux file will be generated each time you compile.

Stefan
LaTeX.org admin
poeli
Posts: 19
Joined: Tue Mar 11, 2014 10:59 am

Main file not compiling anymore

Post by poeli »

I deleted the .aux file and indeed that specific error is gone. There is still an error stating:
(C:\Users\Poelaertp\Dropbox\Masterproef\Hoofdstukken\titlepage.tex

! LaTeX Error: Can be used only in preamble.

See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...

l.3 \begin{document}

Your command was ignored.
Type I <command> <return> to replace it with another command,
or <return> to continue without it.
Attachments
Samenstelling.log
(17.09 KiB) Downloaded 371 times
User avatar
Stefan Kottwitz
Site Admin
Posts: 10330
Joined: Mon Mar 10, 2008 9:44 pm

Main file not compiling anymore

Post by Stefan Kottwitz »

Edit titlepage.tex and remove that line

\begin{document}

Stefan
LaTeX.org admin
Post Reply