我该如何修复各部分右侧明显错误的编号?
这是本节的最小示例代码(我不想进一步缩短它,因为我不知道这是否会影响潜在的解决方案):
\documentclass[12pt,a4paper,bibliography=totocnumbered,listof=totocnumbered]{scrartcl}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{fancyhdr}
\usepackage{tabularx}
\usepackage{geometry}
\usepackage{setspace}
\usepackage[right]{eurosym}
\usepackage[printonlyused]{acronym}
\usepackage{subfig}
\usepackage{floatflt}
\usepackage[usenames,dvipsnames]{color}
\usepackage{colortbl}
\usepackage{paralist}
\usepackage{array}
\usepackage{titlesec}
\usepackage{parskip}
\usepackage[right]{eurosym}
\usepackage[subfigure,titles]{tocloft}
\usepackage[pdfpagelabels=true]{hyperref}
% Quotes
\usepackage[utf8]{inputenc}
\usepackage{epigraph}
\usepackage{listings}
\lstset{basicstyle=\footnotesize, captionpos=b, breaklines=true, showstringspaces=false, tabsize=2, frame=lines, numbers=left, numberstyle=\tiny, xleftmargin=2em, framexleftmargin=2em}
\makeatletter
\def\l@lstlisting#1#2{\@dottedtocline{1}{0em}{1em}{\hspace{1,5em} Lst. #1}{#2}}
\makeatother
\geometry{a4paper, top=27mm, left=30mm, right=20mm, bottom=35mm, headsep=10mm, footskip=12mm}
\hypersetup{unicode=false, pdftoolbar=true, pdfmenubar=true, pdffitwindow=false, pdfstartview={FitH},
pdftitle={ABC},
pdfauthor={ABC},
pdfsubject={ABC},
pdfcreator={\LaTeX\ with package \flqq hyperref\frqq},
pdfproducer={pdfTeX \the\pdftexversion.\pdftexrevision},
pdfkeywords={ABC},
pdfnewwindow=true,
colorlinks=true,linkcolor=black,citecolor=black,filecolor=magenta,urlcolor=black}
\pdfinfo{/CreationDate (D:20110620133321)}
% subsubsubsection via paragraph ---> Makes x.x.x.x for paras
\usepackage{titlesec}
\setcounter{secnumdepth}{4}
\titleformat{\paragraph}
{\normalfont\normalsize\bfseries}{\theparagraph}{1em}{}
\titlespacing*{\paragraph}
{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
% END
\begin{document}
\titlespacing{\section}{0pt}{12pt plus 4pt minus 2pt}{-6pt plus 2pt minus 2pt}
% Kopf- und Fusszeile
\renewcommand{\sectionmark}[1]{\markright{#1}}
\renewcommand{\leftmark}{\rightmark}
\pagestyle{fancy}
\lhead{}
\chead{}
\rhead{\thesection\space\contentsname}
\lfoot{abc}
\cfoot{}
\rfoot{\ \linebreak Seite \thepage}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
% Vorspann
\renewcommand{\thesection}{\Roman{section}}
\renewcommand{\theHsection}{\Roman{section}}
\pagenumbering{Roman}
% ----------------------------------------------------------------------------------------------------------
% Abstract
% ----------------------------------------------------------------------------------------------------------
\setcounter{page}{1}
\onehalfspacing
\titlespacing{\section}{0pt}{12pt plus 4pt minus 2pt}{2pt plus 2pt minus 2pt}
\rhead{Vorwort \& Kurzfassung}
\section{Vorwort}
lksajdlksajd
\section{Kurzfassung}
sajdalskdlsajd
\vspace{-1,2em}
\titlespacing{\section}{0pt}{12pt plus 4pt minus 2pt}{-6pt plus 2pt minus 2pt}
\section*{Abstract}
sldsaldlsdkl
\pagebreak
% ----------------------------------------------------------------------------------------------------------
% Verzeichnisse
% ----------------------------------------------------------------------------------------------------------
% TODO Typ vor Nummer
%\renewcommand{\cfttabpresnum}{Tab. }
\renewcommand{\cftfigpresnum}{Abb. }
\settowidth{\cfttabnumwidth}{Abb. 10\quad}
\settowidth{\cftfignumwidth}{Abb. 10\quad}
\titlespacing{\section}{0pt}{12pt plus 4pt minus 2pt}{2pt plus 2pt minus 2pt}
\singlespacing
\rhead{Inhaltsverzeichnis}
\renewcommand{\contentsname}{III Inhaltsverzeichnis}
\phantomsection
\addcontentsline{toc}{section}{\texorpdfstring{III Inhaltsverzeichnis}{Inhaltsverzeichnis}}
\addtocounter{section}{1}
\tableofcontents
\pagebreak
\rhead{Verzeichnisse}
\listoffigures
\pagebreak
%\listoftables
%\pagebreak
%\renewcommand{\lstlistlistingname}{Listing-Verzeichnis}
%{\labelsep2cm\lstlistoflistings}
\pagebreak
% ----------------------------------------------------------------------------------------------------------
% Abkürzungen
% ----------------------------------------------------------------------------------------------------------
\section{Abkürzungsverzeichnis}
\begin{acronym} % längste Abkürzung steht in eckigen Klammern
\setlength{\itemsep}{-\parsep} % geringerer Zeilenabstand
%\acro{API}{ - Application Programming Interface}
\end{acronym}
\newpage
% ----------------------------------------------------------------------------------------------------------
% Inhalt
% ----------------------------------------------------------------------------------------------------------
% Abstände Überschrift
\titlespacing{\section}{0pt}{12pt plus 4pt minus 2pt}{-6pt plus 2pt minus 2pt}
\titlespacing{\subsection}{0pt}{12pt plus 4pt minus 2pt}{-6pt plus 2pt minus 2pt}
\titlespacing{\subsubsection}{0pt}{12pt plus 4pt minus 2pt}{-6pt plus 2pt minus 2pt}
% Kopfzeile
\renewcommand{\sectionmark}[1]{\markright{#1}}
\renewcommand{\subsectionmark}[1]{}
\renewcommand{\subsubsectionmark}[1]{}
\lhead{Kapitel \thesection}
\rhead{\rightmark}
\onehalfspacing
\renewcommand{\thesection}{\arabic{section}}
\renewcommand{\theHsection}{\arabic{section}}
\setcounter{section}{0}
\pagenumbering{arabic}
\setcounter{page}{1}
% ----------------------------------------------------------------------------------------------------------
% Einleitung
% ----------------------------------------------------------------------------------------------------------
\section{Einleitung}
dfödjdöjfödkjf
\pagebreak
% ----------------------------------------------------------------------------------------------------------
% Literatur
% ----------------------------------------------------------------------------------------------------------
\renewcommand\refname{Quellenverzeichnis}
\bibliographystyle{myalpha}
\bibliography{bib1}
\pagebreak
% ----------------------------------------------------------------------------------------------------------
% Anhang
% ----------------------------------------------------------------------------------------------------------
\pagenumbering{Roman}
\setcounter{page}{1}
\lhead{Anhang \thesection}
\end{document}
我已经尝试注释掉几行,或者使用\addtocounter{section}{1}
(只操作左侧...)但没有任何帮助。感谢大家的支持 :)
答案1
您的代码破坏了几乎所有KOMA -Script 功能。不要将 KOMA-Script 类与包一起使用titlesec
,,,... 还有其他奇怪的事情。tocloft
parskip
fancyhdr
因此我建议使用标准类article
(或者可能更好report
)。然后,您可以使用包tocbibind
来获取编号的目录并列出目录中的条目。
使用包,tocloft
您可以使用\cftpagenumbersoff{section}
和\cftpagenumberson{section}
打开或关闭目录中的页码。
\documentclass[a4paper]{article}
\usepackage{geometry}
\geometry{top=27mm, left=30mm, right=20mm, bottom=35mm, headsep=10mm, footskip=12mm}
\usepackage{tocbibind}
\renewcommand{\listoffigures}{\begingroup
\tocsection
\tocfile{\listfigurename}{lof}%
\endgroup}
\renewcommand{\listoftables}{\begingroup
\tocsection
\tocfile{\listtablename}{lot}%
\endgroup}
\renewcommand{\tableofcontents}{\begingroup
\tocsection
\tocfile{\contentsname}{toc}%
\endgroup}
\usepackage{subfig}
\usepackage[subfigure,titles]{tocloft}
\addtolength\cftsecnumwidth{.5em}% enlarge the space for the section numbers
\usepackage{lipsum}% only for dummy text
\usepackage[naturalnames]{hyperref}
\begin{document}
\pagenumbering{Roman}
\renewcommand\thesection{\Roman{section}}
\addtocontents{toc}{\cftpagenumbersoff{section}}
\section{Vorwort}
\lipsum[1]
\section{Kurzfassung}
\lipsum[2]
\clearpage
\tableofcontents
\clearpage
\listoffigures
\cleardoublepage
\pagenumbering{arabic}
\renewcommand\thesection{\arabic{section}}
\setcounter{section}{0}
\addtocontents{toc}{\cftpagenumberson{section}}
\section{Einleitung}
\lipsum
\end{document}