无标题+多列+自定义目录:1:第一列水平对齐。2:多行输入时调整行高。3:右边距文本对齐

无标题+多列+自定义目录:1:第一列水平对齐。2:多行输入时调整行高。3:右边距文本对齐

我的目录中有三个问题,如下图所示: 在此处输入图片描述

我在最后发布了一个最简单的例子。

1:第一个 ToC 条目的对齐。我有一个没有标题的目录,但即使没有标题内容,标题所占用的空间仍然存在。从最小示例中可以看出,我尝试通过使用以下行在标题中插入 vspace 来缓解此问题:\renewcommand{\printtoctitle}[1]{\vspace{-3cm}}。我可以让它对齐,但如果可能的话,我真的真的真的想要一个不那么黑客的解决方案。

2:子条目内容的行距。我找到了几个命令来控制章节标题和内容之间以及目录中条目之间的行距:\setlength\cftparskip{-5pt}\renewcommand{\cftbeforesectionskip}{3pt},但我找不到正确的命令来调整内容的行距。

3:右边距对齐不良。目录中的右边距对齐存在一个奇怪的问题。内容的文本宽度似乎小于列,除了最后一个条目(如下所示的第 5 节)。我希望内容与列的边距对齐,以便所有条目的文本宽度都与最后一个条目相对应。

\documentclass[11pt,a4paper,onecolumn,oneside]{memoir}
\usepackage{titlesec}
\usepackage[danish]{babel}
\usepackage[danish]{isodate}
\usepackage[utf8x]{inputenc}
\usepackage{mfirstuc}
\usepackage{multicol}
\usepackage{etoolbox}
\usepackage{lastpage}
\usepackage{graphicx}
\usepackage{ragged2e}
\usepackage{newtxtext}
\usepackage{totcount}
\usepackage{lipsum}

\cftpagenumbersoff{section}
\cftpagenumbersoff{subsection}

\setsecnumdepth{chapter}

\renewcommand{\printtoctitle}[1]{\vspace{-3cm}}
\makeatletter
\newcommand*{\setupparasubsubsecs}{%
  \let\oldnumberline\numberline%
  \renewcommand*{\cftsubsubsectionfont}{\itshape\scriptsize}
  \renewcommand*{\cftsubsubsectionpagefont}{\itshape\scriptsize}
  \renewcommand{\l@subsubsection}[2]{%
    \def\numberline####1{\textit{####1}}%
    \leftskip=0.0cm%
    \rightskip=\@tocrmarg%
    \parfillskip=\fill%
    \ifhmode\ \else\noindent\fi%
    \ignorespaces{\cftsubsubsectionfont ##1.}%
    \let\numberline\oldnumberline\ignorespaces}
}
\makeatother

\newcommand*{\setupmaintoc}{%
  \let\changetocdepth\oldchangetocdepth%
  \let\precistoctext\oldprecistoctext%
  \let\cftchapterfillnum\oldcftchapterfillnum\addtodef{\cftchapterbreak}{\par}{}%
\renewcommand*{\cftchapterfont}{\normalfont\sffamily}%
\renewcommand*{\cftchapterleader}{%
\sffamily\cftdotfill{\cftchapterdotsep}}%
\renewcommand*{\cftchapterafterpnum}{}%
\renewcommand{\cftchapterbreak}{\par\addpenalty{-\@highpenalty}}%
\setrmarg{2em}%
\cftsetindents{section}{0em}{0em}%
\renewcommand{\cftsectionfont}{\bfseries\scriptsize}%
\renewcommand{\cftbeforesectionskip}{3pt}%
}%

\let\cftpartformatpnum\oldcftpartformatpnum%
\addtodef{\cftpartbreak}{\par}{}%
\let\cftbookformatpnum\oldcftbookformatpnum\addtodef{\cftbookbreak}{\par}{}%
\setlength\cftparskip{-5pt}%

\newcommand{\Sum}[1]{%
{{\itshape#1}\addcontentsline{toc}{subsubsection}{\makefirstuc{#1}}}%
}

\newcommand{\TOCcols}{%
\begin{multicols}{3}%
\setupmaintoc%
\tableofcontents*%
\end{multicols}%
}%

\newtotcounter{SECTION}
\setcounter{SECTION}{0}

\begin{document}

\setupparasubsubsecs%
\clearpage%
\mainmatter

\chapter*{Chapter}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmodtempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

\TOCcols

\addtocounter{SECTION}{1}%
\addcontentsline{toc}{section}{SECTION~\theSECTION}%
\section*{Section~\theSECTION}%
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut \Sum{labore} et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in \Sum{reprehenderit} in voluptate velit esse cillum dolore eu \Sum{fugiat} nulla pariatur. \Sum{Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.}

\addtocounter{SECTION}{1}%
\addcontentsline{toc}{section}{SECTION~\theSECTION}%
\section*{Section~\theSECTION}%
Lorem ipsum \Sum{dolor} sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation \Sum{ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor} in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur \Sum{sint} occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

\addtocounter{SECTION}{1}%
\addcontentsline{toc}{section}{SECTION~\theSECTION}%
\section*{Section~\theSECTION}%
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut \Sum{labore} et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in \Sum{reprehenderit} in voluptate velit esse cillum dolore eu \Sum{fugiat} nulla pariatur. \Sum{Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.}

\addtocounter{SECTION}{1}%
\addcontentsline{toc}{section}{SECTION~\theSECTION}%
\section*{Section~\theSECTION}%
Lorem ipsum \Sum{dolor} sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation \Sum{ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor} in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur \Sum{sint} occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

\addtocounter{SECTION}{1}%
\addcontentsline{toc}{section}{SECTION~\theSECTION}%
\section*{Section~\theSECTION}%
Lorem ipsum \Sum{dolor} sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation \Sum{ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor} in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur \Sum{sint} occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
\end{document}

答案1

对您的第一个问题的答案。

代替:

 \renewcommand{\printtoctitle}[1]{\vspace{-3cm}

   \renewcommand{\printtottitle}[1]{}   
   \renewcommand{\tocheadstart}{\vspace{-3cm}}

对于其他问题,请查看 TOC 文件的内容,看看您可以使用\Sum宏来调整它们。(大胆猜测,试试\addtocontents而不是\addcontentsline

相关内容