我很高兴使用几天前要求的这个解决方案: 两个独立的 TOC
现在出现了一个后续问题:我的第二个目录仅包含\subsubsection
和更深的嵌套元素,直到\subparagraph
因为我想在目录和 PDF 书签中实现某种结构。我修改了这些元素的外观以匹配我想要的布局\renewcommand\thesubsection{\Alph{subsection}}
。
所以我的问题是如何调整我的第二个目录的布局。它看起来像节和小节,但在第二个目录中却不是这样。我想去掉那些缩进,第二个目录应该从左侧开始(下面的 MWE):
第一个 TOC 不应受到这些设置的影响。
\renewcommand*\l@subsubsection{\bprot@dottedtocline{1}{1.5em}{2.3em}}
我最后一次尝试是在之后使用来使用\printcontents[sections]{ }{2}{}
该节的值来设置子节,但这根本没有效果。
这是我的工作示例(不是那么简单),演示了该行为。我在其中留下了一些评论,以展示我尝试过但没有成功的不同方法。
非常感谢。
\documentclass[paper=A4,%
pagesize=auto,%
fontsize=11pt,%
DIV=19,%
tocleft,%
bibliography=totocnumbered,%
listof=numbered,
titlepage]{scrartcl}
\usepackage[ngerman]{babel}
\usepackage[latin1]{inputenc}
\usepackage[babel,german=quotes]{csquotes} %% deutsche Anfuehrungsstriche
\usepackage[T1]{fontenc}
\usepackage[titles]{tocloft} %% Einrückungen beim Appendix im Titel
\usepackage{titletoc} %% zwei Inhaltsverzeichnisse
\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}
\usepackage{titlesec}
%%\titleformat{\paragraph}[hang]{\normalfont\bfseries}{}{0pt}{}
\titlespacing{\paragraph}{0mm}{15pt}{3pt} %% 30pt
%%\titlecontents{paragraph}[1.5em]{\addvspace{1pc}\bfseries}{\contentslabel{5em}}{}
%% {\titlerule*[0.3pc]{.}\contentspage}
%% http://www.latex-community.org/forum/viewtopic.php?f=5&t=1383
\makeatletter
\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
{-3.25ex\@plus -1ex \@minus -.2ex}%
{1.5ex \@plus .2ex}%
{\normalfont\normalsize\bfseries}}
\makeatother
\renewcommand{\figurename}{\textbf{Abb.}} %% ersetzt Abbildung durch Abb.
%%%%%%%%%%%% hyperref und pdf-Einstellungen Start %%%%%%%%%%%%
\usepackage{hyperref}
\hypersetup{
pdfauthor={xxx},%
pdftitle={Exxx},%
pdfsubject={xxx},%
pdfcreator={xxx},%
%%pdfproducer=meinproducer,% %% ersetzt pdfTeX-Versions-Info
pdfkeywords={xxx},%
bookmarksnumbered=true,%
plainpages=false,%
linktoc=all,
%%pdfpagelabels=true,%
hypertexnames=false,%
%%%pdfborder={0 0 0},%
pdfborderstyle={/S/U/W 1},% %% setzt Unterstrich mit Dicke 1pt
colorlinks=true,% %% false
}
%% farbige Links im PDF mit Unterstreichung
%% von https://tex.stackexchange.com/questions/26071/how-can-i-have-colored-and-underlined-links-with-hyperref
\makeatletter
\Hy@AtBeginDocument{%
\def\@pdfborder{0 0 1}% Overrides border definition set with colorlinks=true
\def\@pdfborderstyle{/S/U/W 1}% Overrides border style set with colorlinks=true
% Hyperlink border style will be underline of width 1pt
}
\makeatother
\usepackage[all]{hypcap} %% fixt Link zum Start einer Grafik, nicht zur darunterliegenden Caption
%%%%%%%%%%%% hyperref und pdf-Einstellungen Ende %%%%%%%%%%%%
%% more space for roman numbers in TOC
%% http://www.komascript.de/node/608
\makeatletter%
\renewcommand*{\@pnumwidth}{3.0em}
\makeatother%
%% for appendix
%%\makeatletter%
%%\g@addto@macro\appendix{%
%% \pagenumbering{Roman}%
%% \addtocontents{toc}{\protect\renewcommand*{\protect\@pnumwidth}{2em}}%
%%}
%%\makeatother%
\begin{document}
My document.
\pdfbookmark[1]{~~~~My TOC}{toc}
\startcontents
\printcontents{ }{1}{}
\setcounter{page}{1}
\section{first section}
foo bar
\subsection{first subsection}
foo bar
\section{last section before appendix}
foo bar
\subsection{some subsection}
foo bar
\subsection{some subsection}
voo bar
\newpage
%% START APPENDIX
\appendix
\pagenumbering{Roman}
\renewcommand\thesubsection{\Alph{subsection}}
\phantomsection
\addcontentsline{toc}{section}{Anhang}
\section*{Anhang}
\markboth{Anhang}{Anhang}
\subsection{and just another subsection}
\subsection{and another subsection}
\subsection{Sources}
\stopcontents
%% START SECOND TOC
\startcontents[sections]
Here is all the sourcecode.
\printcontents[sections]{ }{2}{}
%% see https://tex.stackexchange.com/questions/33841/how-to-modify-the-indentation-before-sectioning-titles-in-the-table-of-contents
\makeatletter
\renewcommand*\l@subsubsection{\bprot@dottedtocline{1}{1.5em}{2.3em}} %% values of section
\renewcommand*\l@paragraph{\bprot@dottedtocline{2}{1.5em}{2.3em}} %% old values: 3.8em 3.2em %% values of subsection
\renewcommand*\l@subparagraph{\bprot@dottedtocline{3}{7.0em}{4.1em}} %% values of subsubsection
\makeatother
%% needs tocloft, there is no difference with these lines
%%\setlength{\cftsecindent}{2.4cm}
%%\setlength{\cftparaindent}{1.3em} %% 2.4 cm versetzt den gesamten TOC-Eintrag (Kapitelnummer und Titel) nach links oder rechts
%%\setlength{\cftparanumwidth}{0.5cm} %% Breite der Zahl vor dem Titel
%%\setlength{\cftbeforeparaskip}{-2cm} %% zieht das TOC insgesamt nach oben
\setcounter{subsection}{3}
\subsubsection{SQL}
\paragraph{create some tables}
bla
\subparagraph{deepest}
a lot of code
\subsubsection{PHP}
\subsubsection{JavaScript}
\stopcontents[sections]
\resumecontents
\subsection{some more}
\begingroup
\renewcommand*\section{\subsection} %% changing for the dynamic created
\listoffigures
\listoftables
\endgroup
\subsection{last subsection}
Finally.
\stopcontents
\end{document}
答案1
将重新定义移至之前\printcontents[sections]{ }{2}{}
对我来说是有效的。