0

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
esdd
  • 85,675
Joanna
  • 1
  • Welcome to TeX.SE! Your document runs at least two times through LaTeX? Without removing miscellaneous aux-, toc- and so on files in between? If so you should cook down your example to a minimal working example (eg there are lots of packages that have definitely nothing to do with your problem). – Jürgen May 29 '17 at 11:27
  • 2
    Please do not show us screenshots of a code snippet. Always show us a minimal but working example (MWE). Making such a MWE will help you to find the critical code and sometimes even to find a solution. Showing us such a MWE will help us to reproduce the problem, test our suggestions and find a solution. BTW: Remove option pdftex from loading packages. They don't need it. – Schweinebacke May 29 '17 at 11:41
  • 2
    Which titlesec version do you use? If it is 2.10.1 from 2016/03/15 then you have to update this package (see https://tex.stackexchange.com/a/300259/43317). But note that it is not recommended to use the packages titlesec and tocloft together with a KOMA-Script class. There should be a way to get the desired result with KOMA-Script commands and settings. Do not change \oddsidemargin and \evensidemargin manuelly. There is geometry loaded in your snippet, so you can use its options to change the page margins. – esdd May 29 '17 at 12:05
  • I tried to make MWE but I'm not quite sure if that's what you need... 9 @esdd honestly, I don't know which version do I use. How do I find out? But as I remember my sections had had numbers at the very beginning, then I think I modified something and they disappeared.. – Joanna May 30 '17 at 10:40
  • 1
    Please copy/paste the code so we can copy/paste and test your example. Just looking at a screenshot isn't helpful and nobody is going to type the text on a keyboard. – Johannes_B May 30 '17 at 10:50
  • 2
    Sorry, but there are really strange things in your preamble. Remove all the redefinitions of \chapter, \section, \subsection etc. from your code! They remove the numbers from your document and they are all wrong and result in a misusage of the \chapter command. There should be no formatting commands inside the argument of a sectioning commands. – esdd May 30 '17 at 11:00
  • 1
    If you want to use \chapter then use scrreprt or scrbook instead scrartcl. Article classes do not know chapters. – esdd May 30 '17 at 11:08

1 Answers1

4

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

esdd
  • 85,675
  • Thank you SOOO much! It seems like it works for everything but chapters... I still cannot number them and if I remove \def\chapter my whole document crashes... – Joanna May 30 '17 at 16:05
  • Did you replace scrartcl by scrreprt? Class scrartcl does not know chapters. – esdd May 30 '17 at 16:16
  • yes, I did it the same as in the code you posted – Joanna May 30 '17 at 16:21
  • If my example itself works for you, then ask a new question with a new short MWE which reproduces the issue and link to this question here. – esdd May 30 '17 at 16:35