章节标题打印在章节编号上方(TOC 和 minitoc)

章节标题打印在章节编号上方(TOC 和 minitoc)

我想将 改为chapternameTest Chapter并将Section改为Test Section。问题是,在目录中,章节标题My first section打印在 上面Test Section 1。此问题也发生在 上minitoc。以下是示例:

\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}

这里输出:

在此处输入图片描述 在此处输入图片描述

答案1

好的,看来我找到了答案,使用不被接受的答案这个问题。代码改为:

\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}

输出:

在此处输入图片描述

在此处输入图片描述

相关内容