0

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:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass
[
    paper=a4, % choose page size e.g. a4 or b5 (common booklet size)
    fontsize=12pt,
    headings=big,
    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
    headinclude,
    pagesize,
    appendixprefix=false,
    headsepline,
    toc=bibliography, % Bibliography appears in Table of Contents (without a number)
    version=last % Use latest version of the KOMA-Script
]{Thesis_Template}

% Add the configuration and packages
\input{definitions/configuration}
\input{definitions/packages_commands}
\input{definitions/hyphenation}

% ad hoc settings
\interfootnotelinepenalty=10000

%import packages that need to be imported separately
\usepackage[subpreambles=false]{standalone}
\usepackage{import}

%toggle for footnotes to continue over the chapters
\counterwithout{footnote}{chapter}

\flipbindingmargins

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

\usepackage{titlesec}
\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}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}
\frontmatter
\headerpage

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

\end{document}

An exemplary code of a chapter:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[a4paper,11pt]{article}
\usepackage{standalone} \standalonetrue %to allow it to be part of thesis
\usepackage{hyperref}
\usepackage[english]{babel}
\usepackage{fullpage}
\usepackage{fancyvrb}
\usepackage{amsmath}
\usepackage{amsbsy}
\usepackage{amssymb}
 \usepackage[flushleft]{threeparttable}
\usepackage{amsthm}
\usepackage{tikzscale}
\usepackage{graphicx}
\usepackage{eurosym}
\usepackage{bm}
\usepackage{bibentry}
\usepackage{natbib}
\usepackage{csquotes}
\usepackage{booktabs}
\usepackage[font=small]{caption}
\usepackage{nameref}
\usepackage{caption}
\usepackage[toc,page]{appendix}
\usepackage{tabularx}
\usepackage{subcaption}
\usepackage{subfiles}
\usepackage{mathrsfs}
\usepackage{standalone}
\usepackage{lscape}
\usepackage{textcomp}
\usepackage{setspace}
\usepackage{dcolumn}
\usepackage{cleveref}
\usepackage[nomessages]{fp}
\usepackage{ifthen}
\usepackage{tablefootnote}
%Settings
\tolerance=2000
\usepackage[usenames,dvipsnames]{color}
\hypersetup{
  colorlinks,
  citecolor=blue,
  linkcolor=blue,
  urlcolor=blue
  }

\usepackage{tikz}
\usepackage{pst-plot}
\usepackage{pst-func}
\usepackage{animate}
\usepackage{graphicx}
\usepackage[explicit]{titlesec}

%sections setup
\titleformat{\section}{\normalfont\bfseries}{\thesection.}{.5em}{\hyperlink{toc}{{\black{#1}}}}
\titleformat{\subsection}{\normalfont}{\thesubsection.}{.5em}{\hyperlink{toc}{\it{\black{#1}}}}
\titleformat{\subsubsection}{\normalfont}{\thesubsubsection.}{.5em}{\it{#1}}
\titlespacing*{\subsubsection}{0pt}{11pt}{0pt}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\ifstandalone

\title{\sc{Title}
\unskip\thanks{Thanks to ...}
}
\author{John Doe}
 }

\date{\today}

\maketitle

\vspace{-1.5em}

%%%%%%% ABSTRACT %%%%%%%
\begin{center}
\parbox[t]{.9\textwidth}{ 
\begin{small}
\singlespacing
Abstract text here.

\clearpage

\doublespacing
\fi

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

\section{Introduction}
Introduction text here

\end{document}

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!

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

1 Answer 1

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.

9
  • 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
    May 25, 2021 at 13:24
  • @Neicooo Is it possible for you to comment out the titlesec stuff, see if things work then? 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
    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. 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 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 .