[Tex/LaTex] Sections numbers do not appear in document and ToC

chapterskoma-scriptsectioningtable of contents

Hej, I'm beginner with latex and I have a problem with chapters, sections and subsections numbers. They do not appear neither in my document nor in ToC. However, everything works fine for numbers of subsubsections…

3rd attempt:

\documentclass[paper=a4, fontsize=11pt,twoside]{scrartcl}   

\setcounter{secnumdepth}{5}

\setcounter{tocdepth}{5}

\usepackage[a4paper]{geometry}  
\setlength{\oddsidemargin}{5mm}     
\setlength{\evensidemargin}{5mm}
\usepackage[english]{babel}
\usepackage[protrusion=true,expansion=true]{microtype}  
\usepackage{amsmath,amsfonts,amsthm,amssymb}
\usepackage{newtxtext,newtxmath,amsmath}
\usepackage{graphicx}
\usepackage{subfiles}
\usepackage{blindtext}
\usepackage[utf8]{inputenc}
\usepackage{titlesec}
\usepackage{fancyhdr}
\usepackage{tocloft}
\usepackage{xstring}
\usepackage{adjustbox}

\makeatletter                           
\def\printtitle                     
\makeatother                                        
\def\chapter{\flushleft\LARGE\textbf}
\def\section{}
\def\subsection{\flushleft\textbf{}}
\def\justify{}
\def\linestretch{}

\begin{document}
\title{}    
\printtitle                 
\printauthor                

\include{chapter2}

\end{document}

\chapter{
\flushleft\textbf{\Huge Chapter 2}
\\[0.5cm]}
\linespread{1}
\normalsize

Best Answer

If you need chapters then use a report or book class like scrreprt or scrbook. Do not load scrartcl and define a \chapter command. And do not redefine \section and \subsection in that complettly wrong way. Your definitions remove the numbers for sections und subsections - amongst other strange things.

Maybe the following example could be a starting point. But I do not know which packages do you really need and how the sectioning titles should be formatted. Note that it is not recommended (and normally not necessary) to use titlesec, tocloft and fancyhdr together with a KOMA-Script class.

\documentclass[paper=a4,fontsize=11pt,twoside=semi,usegeometry]{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{microtype}

\usepackage{amsmath,amsfonts,amsthm,amssymb}
\usepackage{newtxtext,newtxmath}
\usepackage{graphicx}

%\usepackage{geometry}% needed?
%\usepackage{subfiles}% needed?
%\usepackage{xstring}% needed?
%\usepackage{adjustbox}% needed?

\usepackage{blindtext} %only for dummy text in the example

\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}

\addtokomafont{disposition}{\rmfamily}

\RedeclareSectionCommand[
  beforeskip=-1sp,
  afterskip=.5cm,
  font=\Huge
]{chapter}

\begin{document}
\title{Title}
\author{Author}
\maketitle
\tableofcontents
\chapter{Chapter 2}
\blindtext

\Blinddocument
\end{document}

enter image description here