Hej,
Recently I had a problem with numbering chapters, sections and subsections (can be found here). Now it seems like everything works but there is still a problem with chapters. They do not appear in ToC and I cannot numbered them. Also, when I tried to remove \def\chapter my whole document crashes... Help
\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}
\setlength{\oddsidemargin}{5mm}
\setlength{\evensidemargin}{5mm}
\usepackage{blindtext}
\usepackage{titlesec}
\usepackage{fancyhdr}
\usepackage{tocloft}
\usepackage{ragged2e}
\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}
\addtokomafont{disposition}{\rmfamily}
\RedeclareSectionCommand[
beforeskip=-1sp,
afterskip=.5cm,
font=\Huge
]{chapter}
\newcommand{\HRule}[1]{\rule{\linewidth}{#1}}
\makeatletter
\def\printtitle{}
\makeatother
\makeatletter
\def\printauthor{}
\makeatother
\def\afterpage{\null\newpage}
**\def\chapter**
\def\linestretch
\begin{document}
\printtitle
\printauthor
\include{Chapter}
\end{document}
\chapter. Simple use\chapter{Chapter 2}. The layout of the chapter title is defined using\RedeclareSectionCommand. – esdd May 30 '17 at 17:12**\def\chapter**and\def\linestretchie the start of two definitions without the actual definition, was that intended or has it been corrupted as you were adding to this site. also what is the intention of the very odd definition\def\afterpage{\null\newpage}? – David Carlisle May 30 '17 at 18:21\chapterso that it has to be followed by `**\def\linestretch
\begin
– David Carlisle May 30 '17 at 18:23and then would expand to the textdocumentso any other use of\chapter` will give the error that you state.\def\printtitle{}
\makeatother
\makeatletter
\def\printauthor{}
\makeatother
\def\afterpage{\null\newpage}
– David Carlisle May 30 '17 at 18:25\def\chapter
\def\linestretch` from your preamble.
\afterpagename comes from the package of that name (which I wrote) the definition here is just bizarre as it does not put anything after any page, the lines with\makeatletterto nothing at all. the line with\printauthor{}does not print anything anywhere it just defines\printauthorto do nothing. and the final two\defare syntax errors that will completely stop latex working at all, If you do not delete the\def\chapter**line then your document will not work and will not be fixable. – David Carlisle May 30 '17 at 20:19{}code section so line endings are preserved, all the lines from!to?also you still have not provided a copy of a (short)Chapter.texfile that makes this "crash" so no one except you can run your example. – David Carlisle May 30 '17 at 20:54