1

I want to change the chaptername to something like Test Chapter, and Section to Test Section. Problem is, in the Table of Contents, the section title My first section is printed out over the Test Section 1. The problem also occurs on minitoc. Following is the example:

\documentclass[bibliography=totoc,headings=big,captions=tableheading,chapterprefix=true,fontsize=13pt]{scrreprt}
\usepackage[left=1in,right=2cm,top=1in,bottom=1in]{geometry}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{minitoc}
\usepackage{lmodern}
\usepackage[pdftex,bookmarks=true]{hyperref}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
% ================================================================================
% Table of Contents with Chapter
% http://tex.stackexchange.com/questions/39153/table-of-contents-with-chapter
\usepackage{titletoc}% http://ctan.org/pkg/titletoc
\titlecontents*{chapter}% <section-type>
  [0pt]% <left>
  {}% <above-code>
  {\bfseries\chaptername\ \thecontentslabel\quad}% <numbered-entry-format>
  {}% <numberless-entry-format>
  {\bfseries\hfill\contentspage}% <filler-page-format>
% ================================================================================
\renewcommand{\chaptername}{Test Chapter}
\renewcommand\thesection{Test Section~\arabic{section}}

\setlength\parindent{0pt}

\begin{document}
\dominitoc
% ================================================================================
% For bigger heading
% Taken from http://tex.stackexchange.com/questions/159869/koma-script-scrreprt-chapter-heading-size-customisation
\addtokomafont{chapterprefix}{\raggedleft}
\addtokomafont{chapter}{\fontsize{30}{38}\selectfont}
\addtokomafont{section}{\huge}
\addtokomafont{subsection}{\Large}
\addtokomafont{subsubsection}{\large}
\renewcommand*{\chapterformat}{%
\mbox{\scalebox{1.5}{\chapappifchapterprefix{\nobreakspace}}%
\scalebox{4}{\color{gray}\thechapter\autodot}\enskip}}
% ================================================================================
\phantomsection
\pdfbookmark[0]{\contentsname}{pdf:toc}
\tableofcontents                % Inhaltsverzeichnis einfügen
\clearpage
% ================================================================================
\chapter{My first chapter}
\minitoc
\section{My first section}
\section{My very long long long long long long long long long long long long long long long long long long long long section title}
\end{document}

Output here:

enter image description here enter image description here

scmg
  • 246

1 Answers1

1

Ok, seems I found the answer, using the not-accepted answer of this question. The code is changed to:

\documentclass[bibliography=totoc,headings=big,captions=tableheading,chapterprefix=true,fontsize=13pt]{scrreprt}
\usepackage[left=1in,right=2cm,top=1in,bottom=1in]{geometry}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{minitoc}
\usepackage{lmodern}
\usepackage[pdftex,bookmarks=true]{hyperref}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}


%% ================================================================================
%% Table of Contents with Chapter
%% https://tex.stackexchange.com/questions/39153/table-of-contents-with-chapter
%\usepackage{titletoc}% http://ctan.org/pkg/titletoc
%\titlecontents*{chapter}% <section-type>
%  [0pt]% <left>
%  {}% <above-code>
%  {\bfseries\chaptername\ \thecontentslabel\quad}% <numbered-entry-format>
%  {}% <numberless-entry-format>
%  {\bfseries\hfill\contentspage}% <filler-page-format>
%% ================================================================================
\renewcommand{\chaptername}{Test Chapter}
\renewcommand\thesection{Test Section~\arabic{section}}

% ================================================================================
% THAT PART MAKE IT DONE
\usepackage{tocloft,calc}
\renewcommand{\cftchappresnum}{\chaptername~}
\AtBeginDocument{\addtolength\cftchapnumwidth{\widthof{\chaptername}}}
\AtBeginDocument{\addtolength\cftsecnumwidth{\widthof{Test Section}}}
% ================================================================================

\setlength\parindent{0pt}

\begin{document}
\dominitoc
% ================================================================================
% For bigger heading
% Taken from https://tex.stackexchange.com/questions/159869/koma-script-scrreprt-chapter-heading-size-customisation
\addtokomafont{chapterprefix}{\raggedleft}
\addtokomafont{chapter}{\fontsize{30}{38}\selectfont}
\addtokomafont{section}{\huge}
\addtokomafont{subsection}{\Large}
\addtokomafont{subsubsection}{\large}
\renewcommand*{\chapterformat}{%
\mbox{\scalebox{1.5}{\chapappifchapterprefix{\nobreakspace}}%
\scalebox{4}{\color{gray}\thechapter\autodot}\enskip}}
% ================================================================================
\phantomsection
\pdfbookmark[0]{\contentsname}{pdf:toc}
\tableofcontents                % Inhaltsverzeichnis einfügen
\clearpage
% ================================================================================
\chapter{My first chapter}
\minitoc
\section{My first section}
\section{My very long long long long long long long long long long long long long long long long long long long long section title}
\end{document}

Output:

enter image description here

enter image description here

scmg
  • 246