For my thesis, I want to compile various tex docs as chapters. Unfortunately, when trying to link the various chapters, I receive the following error:

File: chapter_1/tex/chapter1 "!Missing number, treated as zero.}\section{introduction}
File: chapter_1/tex/chapter1 "!Illegal unit of measure (pt inserted).}\section{introduction}

Below a snippet of my LaTex code:

The main document i.e. the compiler of the various chapters:

    paper=a4, % choose page size e.g. a4 or b5 (common booklet size)
    parskip, %indent at paragrafs?
    numbers=noendperiod, % 2.3.1 vs 2.3.1. (no dot after the last chapter number)
    twoside=true, %choose two sided for a booklet style, semi leaves the margings the same
    toc=bibliography, % Bibliography appears in Table of Contents (without a number)
    version=last % Use latest version of the KOMA-Script

% Add the configuration and packages

% ad hoc settings

%import packages that need to be imported separately

%toggle for footnotes to continue over the chapters


% ad hoc spacing for sections
\setlength\parskip{1em plus 0em minus 0.1em}

\titlespacing*{\section}{0pt}{1em plus 0em minus 0.1em}{1em plus 0em}
\titlespacing*{\subsection}{0pt}{1em plus 0em minus 0.1em}{.6em plus 0em}
\titlespacing*{\subsubsection}{0pt}{1em plus 0em minus 0.1em}{.6em plus 0em}



%% Startmain content
\chapter[Chapter 1]{Chapter 1 long title} \label{chapt 1}
%import actual chapter tex


An exemplary code of a chapter:

\usepackage{standalone} \standalonetrue %to allow it to be part of thesis


%sections setup



\unskip\thanks{Thanks to ...}
\author{John Doe}




%%%%%%% ABSTRACT %%%%%%%
Abstract text here.



%%%%%%% Introduction %%%%%%%

Introduction text here


I am using TeX Maker. I also made sure that all packages are up to date.

I read online in other posts that it might have something to do with the titlesec package but could not figure out a solution.

Many thanks for your support!

  • I'm not sure you should be using \import here, probably more like the features from the standalone package.
    – daleif
    Commented May 25, 2021 at 13:15

1 Answer 1


The \import command is based on the \input command, which basically pastes the file pointed to right at the spot of the \input/\import. That includes \documentclass and the rest of your preamble. Of course, that's not going to work!

Instead, you should use the subfiles package. See How to bring existing LaTeX files as chapters of thesis appendix?

I'm not entirely sure this is what's going on here, because I get the more descriptive error Can be used only in preamble. But then, I'm using a very clean minimal document, and with more configurations going on, things mix up easier.

  • Thanks for your prompt response. Unfortunatley, it still did not work. The "interesting" thing is when I do not use the "\section" command, the compilation into the master doc works. The error only appears when using "\section" (both with mine and your suggested approach)
    – Neicooo
    Commented May 25, 2021 at 13:24
  • @Neicooo Is it possible for you to comment out the titlesec stuff, see if things work then? Commented May 25, 2021 at 13:31
  • Not sure if I got you there, but do you mean the thread related to that topic that I found? tex.stackexchange.com/questions/302111/…
    – Neicooo
    Commented May 25, 2021 at 13:51
  • Commenting out is placing a percent sign (%) at the start of code lines. These will be seen as 'comments' by LaTeX, and hence be ignored. It's as if you deleted those lines from your code, except you can sort of keep them. Commented May 25, 2021 at 13:57
  • @Neicooo titlesec is mostly aesthetics. Hence, I would think you can just disable those lines in the configurations, and see if things work then. It tells us whether the problem lies at titlesec, as you were conjecturing, or whether it's something else Commented May 25, 2021 at 13:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .