我从 karlkoeller 发现了以下 MWE:scrreprt 中的附录 - 单独的附录表格,但在原始目录中提及
对于我来说,这几乎是完美的,只需要改变一件事。而不是
A。章节名称
我需要:
安行1:章节名称
使用
\renewcommand{\thechapter}{Anhang~\arabic{chapter}}
不起作用,因为它会弄乱附录目录中的间距。另外,仅供参考,我只需要章节,不需要部分等。我还想使用点从 Anhang 1:章节名称.....页码开始,这样它就可以与我的图表列表、公式列表和表格列表相匹配。
我还使用了应该显示自定义标题
安航1
如果可能的话,不要使用完整的章节名称。
以下是 MWE:
\documentclass[12pt, numbers=noenddot,parskip, headsepline, footsepline,headings=small,]{scrreprt}
\usepackage{lipsum}
\usepackage[a4paper, includeheadfoot, left=3.5cm, right=1.7cm, top=2.5cm, bottom=2.0cm]{geometry}
\renewcommand{\floatpagefraction}{.75}%
\newcommand\appendicesname{Anlagen}
\newcommand\listofloaname{Verzeichnis der \appendicesname}
\newcommand*{\listofappendices}{\listoftoc{loa}}
\setuptoc{loa}{totoc}
\makeatletter
\g@addto@macro\appendix{%
\let\oldaddcontentsline\addcontentsline
\newcommand\hackedaddcontentsline[3]{\oldaddcontentsline{loa}{#2}{#3}}
\let\oldpart\part
\renewcommand*\part[1]{%
\let\addcontentsline\hackedaddcontentsline%
\oldpart{#1}%
\let\addcontentsline\oldaddcontentsline%
}
\let\oldchapter\chapter
\renewcommand*\chapter[1]{%
\let\addcontentsline\hackedaddcontentsline%
\oldchapter{#1}%
\let\addcontentsline\oldaddcontentsline%
}
\let\oldsection\section
\renewcommand*\section[1]{%
\let\addcontentsline\hackedaddcontentsline%
\oldsection{#1}%
\let\addcontentsline\oldaddcontentsline%
}
\let\oldsubsection\subsection
\renewcommand*\subsection[1]{%
\let\addcontentsline\hackedaddcontentsline%
\oldsubsection{#1}%
\let\addcontentsline\oldaddcontentsline%
}
\let\oldsubsubsection\subsubsection
\renewcommand*\subsubsection[1]{%
\let\addcontentsline\hackedaddcontentsline%
\oldsubsubsection{#1}%
\let\addcontentsline\oldaddcontentsline%
}
}
\makeatother
\usepackage{chngcntr}
\counterwithout{figure}{chapter}
\counterwithout{equation}{chapter}
\counterwithout{table}{chapter}
\usepackage{etoolbox,refcount}
\usepackage{multicol}
\usepackage[onehalfspacing]{setspace}
\usepackage[ngerman]{babel}
\usepackage{xpatch}
%\newcommand{\HRule}{\rule{\linewidth}{0.5mm}}
%\usepackage{mathpazo}
\usepackage[automark]{scrlayer-scrpage}
\automark{chapter}
\clearpairofpagestyles
\ihead{\headmark}
\ohead{\pagemark}
\renewcommand*{\chapterpagestyle}{headings}
\renewcommand*{\chapterheadstartvskip}{\vspace*{-\topskip}}
\renewcommand{\theequation}{\arabic{equation}}
\renewcommand{\thefigure}{\arabic{figure}}
\renewcommand{\thetable}{\arabic{figure}}
\renewcommand{\topfraction}{.75}
\usepackage{enumitem}
\SetLabelAlign{LeftAlignFullWidth}{\makebox[\dimexpr\linewidth+\labelwidth\relax][l]{#1}}
\usepackage[colorlinks=true, linktocpage=true,citecolor=blue]{hyperref}
\usepackage{xcolor}
\usepackage{microtype}
\usepackage{dirtytalk}
\usepackage{graphicx}
%\usepackage{ltxtable}
%\usepackage{mathpazo}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[nottoc]{tocbibind}
\usepackage[titles]{tocloft}
\newcommand\NoIndent[1]{%
\par\vbox{\parbox[t]{\linewidth}{#1}}%
}
\begin{document}
\renewcommand{\cftdot}{.}
\newcounter{savepage}
\pagenumbering{Roman}
%\cleardoublepage
\onehalfspacing
\tableofcontents
\KOMAoptions{listof=totoc,index=totoc}
\setcounter{savepage}{\value{page}}
\pagenumbering{arabic}
\chapter{Chapter 1}
\lipsum[1-5]
\section{A section}
\lipsum[1-5]
\listofappendices
\appendix
\renewcommand{\thechapter}{Anhang~\arabic{chapter}}
\chapter{This is the first Anhang}
\end{document}
更新:新 MWE 采用的答案:
\documentclass[12pt, numbers=noenddot,parskip, headsepline, footsepline,headings=small,
listof=totoc,
index=totoc
]{scrreprt}
\usepackage[a4paper, includeheadfoot, left=3.5cm, right=1.7cm, top=2.5cm, bottom=2.0cm]{geometry}
\renewcommand{\floatpagefraction}{.75}%
\newcommand*{\listappendicesname}{Verzeichnis der Anlagen}
%%% see: https://komascript.de/comment/5578#comment-5578 (Markus Kohm)
\DeclareNewTOC[%
owner=\jobname,
listname=\listappendicesname,% Titel des Verzeichnisses
]{atoc}% Dateierweiterung (a=appendix, toc=table of contents)
\makeatletter
\newcommand*{\useappendixtoc}{%
\renewcommand*{\ext@toc}{atoc}%
\scr@ifundefinedorrelax{hypersetup}{}{% damit es auch ohne hyperref funktioniert
\hypersetup{bookmarkstype=atoc}%
}%
}
\ifundefinedorrelax{ext@toc}{%
\newcommand*{\ext@toc}{toc}
\renewcommand{\addtocentrydefault}[3]{%
\expandafter\tocbasic@addxcontentsline\expandafter{\ext@toc}{#1}{#2}{#3}%
}
}{}
\AfterTOCHead[atoc]{%
% add the appendix TOC to the main TOC:
{\def\ext@toc{toc}\addchaptertocentry{}{\listappendicesname}}
\KOMAoptions{toc=nonumberline}
}
\makeatother
\usepackage{xpatch}% loads also etoolbox
\xapptocmd{\appendix}
{
\useappendixtoc
\listofatocs
\renewcommand\chapterformat{\appendixname\ \thechapter:\enskip}%
\renewcommand\thechapter{\arabic{chapter}}%
\xpatchcmd{\addchaptertocentry}
{\addtocentrydefault{chapter}{#1}{#2}}
{\addtocentrydefault{chapter}{}{\appendixname\ #1:\ #2}}
{}{\PatchFailed}
\renewcommand\chaptermark[1]{\markboth{\chaptermarkformat}{\chaptermarkformat}}
\renewcommand\chaptermarkformat{\appendixname\ \thechapter\autodot}
}
{}{\PatchFailed}
\usepackage{chngcntr}
\counterwithout{figure}{chapter}
\counterwithout{equation}{chapter}
\counterwithout{table}{chapter}
\usepackage{refcount}
\usepackage{multicol}
\usepackage[onehalfspacing]{setspace}
\usepackage[ngerman]{babel}
\usepackage{blindtext}% only for dummy text
\usepackage{scrlayer-scrpage}% sets pagestyle scrheadings; headings is only a synonym
\automark[chapter]{chapter}
\clearpairofpagestyles
\ihead{\headmark}
\ohead{\pagemark}
\RedeclareSectionCommand[beforeskip=-1sp minus -1sp]{chapter}% no skip before the chapter title
\renewcommand{\topfraction}{.75}
\usepackage{enumitem}
\SetLabelAlign{LeftAlignFullWidth}{\makebox[\dimexpr\linewidth+\labelwidth\relax][l]{#1}}
\usepackage{xcolor}
\usepackage{microtype}
\usepackage{dirtytalk}% in TeXLive but not in MiKTeX
\usepackage{graphicx}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[colorlinks=true, linktocpage=true,citecolor=blue]{hyperref}% load as last package
\newcommand\NoIndent[1]{%
\par\vbox{\parbox[t]{\linewidth}{#1}}%
}
\newcounter{savepage}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Added To MWE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{amsmath}
\DeclareNewTOC[%
tocentryindent=0pt,% kein Einzug im Verzeichnis
tocentrynumwidth=2em,% Einzug für den Text im Verzeichnis
type=equation
]{loe}
\AtBeginDocument{\renewcaptionname{ngerman}{\contentsname}{Inhalt}
\newcaptionname{ngerman}\equationname{Formel}%
\newcaptionname{ngerman}\listequationname{Verzeichnis der Formeln}
\renewcaptionname{ngerman}{\listfigurename}{Verzeichnis der Abbildungen} %Figures
\renewcaptionname{ngerman}{\listtablename}{Verzeichnis der Tabellen} %Tables
\renewcaptionname{ngerman}{\figurename}{Abb.} %Figure
\renewcaptionname{ngerman}{\tablename}{Tab.} %Table
\renewcaptionname{ngerman}{\bibname}{Verzeichnis der Literatur} %Bibliography
\newcaptionname{ngerman}{\lstlistlistingname}{Quelltexte} %Table of listings
\newcaptionname{ngerman}{\lstlistingname}{Quelltext} }%
\makeatletter
\newcommand*{\@currententry}{}
% Zwei amsmath-Anweisungen ändern:
\g@addto@macro\make@display@tag{\set@currententry}%
\def\tagform@#1{\maketag@@@{(\ignorespaces#1\unskip\@@italiccorr)}%
\set@currententry}
\newcommand*{\set@currententry}{%
\typeout{set current entry}%
\ifx\@currententry\@empty\else
\addcontentsline{loe}{equation}{\protect\numberline{\@currentlabel}%
\@currententry}%
\global\let\@currententry\@empty
\fi
}
% Neue Benutzeranweisung
\newcommand*{\equationentry}[1]{%
\gdef\@currententry{#1}%
}
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Added To MWE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\pagenumbering{Roman}
\tableofcontents
\listofequations
\listoffigures
\listoftables
\setcounter{savepage}{\value{page}}
\cleardoublepage
\pagenumbering{arabic}
% \blinddocument
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Added To MWE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapter{Kapitel 1}
\begin{equation}\label{eq:Eq1}\equationentry{P-Anteil}
a=b
\end{equation}
\newpage
\centering% center the table
\captionaboveof{table}{My caption}
\label{my-label}
\begin{tabular}{lllll}
& \multicolumn{2}{l}{XYZ} & \multicolumn{2}{l}{ABC} \\
& Sex & P & Sex & P \\
AGE1 & 0.5 & 1 & 0.6 & 1 \\
& & & &
\end{tabular}
\begin{figure}
Test Figure
\caption{No Intend Here} \label{fig:LableTest}
\end{figure}
\begin{figure}
Test Figure
\caption{No Intend Here} \label{fig:LableTest2}
\end{figure}
% \blinddocument
\begin{equation}\label{eq:Eq2}\equationentry{P-Anteil}
a=b
\end{equation}
\begin{equation}\label{eq:3}\equationentry{P-Anteil}
a=b
\end{equation}
\chapter{Kapitel 2}
\begin{equation}\label{eq:Eq4}\equationentry{P-Anteil}
a=b
\end{equation}
\begin{equation}\label{eq:5}\equationentry{P-Anteil}
a=b
\end{equation}
\centering% center the table
\captionaboveof{table}{My caption}
\label{my-label2}
\begin{tabular}{lllll}
& \multicolumn{2}{l}{XYZ} & \multicolumn{2}{l}{ABC} \\
& Sex & P & Sex & P \\
AGE1 & 0.5 & 1 & 0.6 & 1 \\
& & & &
\end{tabular}
\begin{figure}
Test Figure
\caption{No Intend Here} \label{fig:LableTest3}
\end{figure}
\blinddocument
\appendix
\end{document}
答案1
不要将包tocloft
与 KOMA-Script 类一起使用。也无需加载包tocbibind
。
建议:
\documentclass[12pt, numbers=noenddot,parskip, headsepline, footsepline,headings=small,
listof=totoc,
index=totoc
]{scrreprt}
\usepackage[a4paper, includeheadfoot, left=3.5cm, right=1.7cm, top=2.5cm, bottom=2.0cm]{geometry}
\renewcommand{\floatpagefraction}{.75}%
\newcommand*{\listappendicesname}{Verzeichnis der Anlagen}
%%% see: https://komascript.de/comment/5578#comment-5578 (Markus Kohm)
\DeclareNewTOC[%
owner=\jobname,
listname=\listappendicesname,% Titel des Verzeichnisses
]{atoc}% Dateierweiterung (a=appendix, toc=table of contents)
\makeatletter
\newcommand*{\useappendixtoc}{%
\renewcommand*{\ext@toc}{atoc}%
\scr@ifundefinedorrelax{hypersetup}{}{% damit es auch ohne hyperref funktioniert
\hypersetup{bookmarkstype=atoc}%
}%
}
\ifundefinedorrelax{ext@toc}{%
\newcommand*{\ext@toc}{toc}
\renewcommand{\addtocentrydefault}[3]{%
\expandafter\tocbasic@addxcontentsline\expandafter{\ext@toc}{#1}{#2}{#3}%
}
}{}
\AfterTOCHead[atoc]{%
% add the appendix TOC to the main TOC:
{\def\ext@toc{toc}\addchaptertocentry{}{\listappendicesname}}
\KOMAoptions{toc=nonumberline}
}
\makeatother
\usepackage{xpatch}% loads also etoolbox
\xapptocmd{\appendix}
{
\useappendixtoc
\listofatocs
\renewcommand\chapterformat{\appendixname\ \thechapter:\enskip}%
\renewcommand\thechapter{\arabic{chapter}}%
\xpatchcmd{\addchaptertocentry}
{\addtocentrydefault{chapter}{#1}{#2}}
{\addtocentrydefault{chapter}{}{\appendixname\ #1:\ #2}}
{}{\PatchFailed}
\renewcommand\chaptermark[1]{\markboth{\chaptermarkformat}{\chaptermarkformat}}
\renewcommand\chaptermarkformat{\appendixname\ \thechapter\autodot}
}
{}{\PatchFailed}
\usepackage{chngcntr}
\counterwithout{figure}{chapter}
\counterwithout{equation}{chapter}
\counterwithout{table}{chapter}
\usepackage{refcount}
\usepackage{multicol}
\usepackage[onehalfspacing]{setspace}
\usepackage[ngerman]{babel}
\usepackage{blindtext}% only for dummy text
\usepackage{scrlayer-scrpage}% sets pagestyle scrheadings; headings is only a synonym
\automark[chapter]{chapter}
\clearpairofpagestyles
\ihead{\headmark}
\ohead{\pagemark}
\RedeclareSectionCommand[beforeskip=-1sp minus -1sp]{chapter}% no skip before the chapter title
\renewcommand{\topfraction}{.75}
\usepackage{enumitem}
\SetLabelAlign{LeftAlignFullWidth}{\makebox[\dimexpr\linewidth+\labelwidth\relax][l]{#1}}
\usepackage{xcolor}
\usepackage{microtype}
\usepackage{dirtytalk}% in TeXLive but not in MiKTeX
\usepackage{graphicx}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[colorlinks=true, linktocpage=true,citecolor=blue]{hyperref}% load as last package
\newcommand\NoIndent[1]{%
\par\vbox{\parbox[t]{\linewidth}{#1}}%
}
\newcounter{savepage}
\begin{document}
\pagenumbering{Roman}
\tableofcontents
\listoffigures
\listoftables
\setcounter{savepage}{\value{page}}
\cleardoublepage
\pagenumbering{arabic}
\blinddocument
\appendix
\blinddocument
\end{document}