2

I'm using class report and hyperref, and it seems that I'm having a problem with sections and especially when introducing subsections. In the .pdf file, the unnumbered chapter GH in my MWE listed below becomes part of the previous unnumbered chapter, when I add subsection within the previous chapter.

Please help.

My full MWE follows (sorry for making it long):

\documentclass[10pt,a4]{report}

\usepackage[english]{babel}
\usepackage{setspace}
\usepackage{rotating}
\usepackage{multirow}
\usepackage{enumerate}
\usepackage{array,graphicx}
\usepackage[table]{xcolor}
\usepackage{fullpage}
\usepackage{fmtcount}
\usepackage{float}
\usepackage{pifont}
\usepackage{slashbox}
\usepackage{enumitem}
\usepackage{txfonts}
\usepackage{pxfonts}
\usepackage{longtable}
\setlength\LTleft{0pt}
\setlength\LTright{0pt}


\usepackage[T1]{fontenc}
\usepackage[left= 7.5em, right= 7.5em, bottom=13em]{geometry}
\usepackage[colorlinks,linktocpage]{hyperref}
\hypersetup{
   colorlinks   = true, %Colours links instead of ugly boxes
   urlcolor     = blue, %Colour for external hyperlinks
   linkcolor    = blue, %Colour of internal links
   citecolor    = red   %Colour of citations
}



\usepackage{tocstyle}
\usepackage{tocloft}
\renewcommand\cftpartdotsep{1}
\renewcommand\cftchapdotsep{1}
\renewcommand\cftsecdotsep{1}
\usetocstyle{standard}
\settocfeature{raggedhook}{\raggedright}

\makeatletter
\newcommand{\thickhline}{%
    \noalign {\ifnum 0=`}\fi \hrule height 2pt
    \futurelet \reserved@a \@xhline
}
\newcolumntype{"}{@{\hskip\tabcolsep\vrule width 2pt\hskip\tabcolsep}}
\makeatother

\providecommand{\keywords}[1]{\textbf{\textit{Keywords ---}} #1}

\newcommand*\rot{\rotatebox{90}}

%\definecolor{Gray}{gray}{0.9}

%------------------------------------------------------------------------------------------
\usepackage[strict]{changepage}
\usepackage{framed}
\definecolor{formalshade}{rgb}{0.93,0.93,1}
\newenvironment{formal}{%
  \def\FrameCommand{%
    \hspace{50pt}%
    {\color{blue}\vrule width 2pt}%
    {\color{formalshade}\vrule width 1pt}%
    \colorbox{formalshade}%
  }%
  \MakeFramed{\advance\hsize-\width\FrameRestore}%
  \noindent\hspace{-4.55pt}% disable indenting first paragraph
  \begin{adjustwidth}{}{7pt}%
  \vspace{2pt}\vspace{2pt}%
}
{%
  \vspace{2pt}\end{adjustwidth}\endMakeFramed%
}

\renewcommand{\thesection}{\Alph{section}}

\newcommand{\spheading}[2][4.5em]{
    \rotatebox{90}{\parbox{#1}{\raggedright #2}}}

\renewcommand{\labelenumii}{\theenumii}

\renewcommand{\theenumii}{\theenumi.\arabic{enumii}.}

\usepackage{titlesec}
\titleformat{\chapter}[display]
  {\normalfont\rmfamily\LARGE\bfseries\color{black}}
  {\chaptertitlename\ \thechapter}{18pt}{\Large}


\usepackage{graphicx}
\usepackage{lscape}


\begin{document}
\doublespacing
\author{\textbf{}}
\title{Report}
\maketitle
\singlespacing

\tableofcontents

\chapter*{AB}
\addcontentsline{toc}{chapter}{AB}

\section{ab1}
\section{ab2}
\subsection{ab21}
\subsection{ab22}
\subsubsection{ab221}
\subsubsection{ab222}

\chapter*{CD}
\addcontentsline{toc}{chapter}{CD}
\setcounter{section}{0}
\renewcommand*{\theHsection}{chX.\the\value{section}}

\section{cd1}
\section{cd2} 
\subsection{cd21}

\renewcommand*{\theHsection}{\theHchapter.\the\value{section}}

\chapter*{EF}
\addcontentsline{toc}{chapter}{EF}
\setcounter{section}{0}
\renewcommand*{\theHsection}{chX.\the\value{section}}

\section{ef1}
\section{ef2}
\section{ef3}

\chapter*{GH}
\addcontentsline{toc}{chapter}{GH}
\setcounter{section}{0}
\renewcommand*{\theHsection}{chX.\the\value{section}}


\chapter*{IJ}
\addcontentsline{toc}{chapter}{IJ}
\setcounter{section}{0}
\renewcommand*{\theHsection}{chX.\the\value{section}}

\chapter*{KL}
\addcontentsline{toc}{chapter}{KL}
\setcounter{section}{0}
\renewcommand*{\theHsection}{chX.\the\value{section}}

\chapter*{MN}
\addcontentsline{toc}{chapter}{MN}
\setcounter{section}{0}
\renewcommand*{\theHsection}{chX.\the\value{section}}

\chapter*{OP}
\addcontentsline{toc}{chapter}{OP}
\setcounter{section}{0}
\renewcommand*{\theHsection}{chX.\the\value{section}}

\chapter*{RS}
\addcontentsline{toc}{chapter}{RS}
\setcounter{section}{0}
\renewcommand*{\theHsection}{chX.\the\value{section}}

\chapter*{TU}
\addcontentsline{toc}{chapter}{TU}
\setcounter{section}{0}
\renewcommand*{\theHsection}{chX.\the\value{section}}\

\end{document}

chapter GH for some reason becomes part of the previous chapter

  • 1
    Welcome to TeX.SE. I suspect you just need to re-run pdflatex. – Peter Grill Jun 16 '16 at 11:11
  • 2
    (1) Welcome, (2) Full minimal example please, preamble is missing. Full MWE makes it a lot easier for others to help. If you are using \chapter* all over the palce, why not simple use \setcounter{secnumdepth}{-1} and then use \chapter? That disables numbering, and thus turns \chapter into \chapter* with the added bonus that the title is automatically added to the toc. – daleif Jun 16 '16 at 11:12
  • @daleif Thanks for the advice. \setcounter{secnumdepth}{-1} does improve the script. I've included the preamble. – Timur Umarov Jun 16 '16 at 11:40
  • @PeterGrill I'm using ps2pdf from the command line. What is exactly re-running pdflatex? – Timur Umarov Jun 16 '16 at 11:41
  • What don't you just use pdflatex to compile instead of latex+dvips+ps2pdf, pdflatex outputs directly into PDF. That is what most users are using nowadays, that is what Peter means – daleif Jun 16 '16 at 11:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.