我有一个关于的问题\minitoc
,我想更改我的硕士论文内部的布局\minitoc
。文档是使用单列编写的,但我想将内容放在\minitoc
两列中(我认为比一列更优雅)。
我将为您创建一个 ASCII 示例:
CHAPTER 1
INTRODUCTION
________________________________________
1.1 aims 1.3 bla bla
1.2 background 1.4 bla bla
________________________________________
我猜这是可能的,因为我以前见过,但我正疯狂地寻找如何做到这一点。
答案1
我不知道两列部分目录是否是个好主意(长标题可能看起来很奇怪)。无论如何,下面有一个可能的解决方案。一些注释:
- 我用了
titletoc
代替minitoc
。 - 为了在 nulticol 环境周围生成水平规则,我借用了 Werner 的一些代码他的回答到水平线接触多列分隔符规则。
- 我使用该
titletoc
包对部分目录条目进行了不同的格式化(字体大小设置为\small
并且页码为斜体)。 - 该
titlesec
包用于减少章节标题和部分目录之间的垂直空间。 - 我决定在部分目录中的列之间添加垂直线,以防止左列的页码干扰右列的节单元编号。在代码的第三个变体(如下)中,我隐藏了页码,因此垂直线也被删除了。
第一个变体:
\documentclass{book}
\usepackage{titletoc}
\usepackage{etoolbox}
\usepackage{multicol}
\usepackage{lipsum}
% start of Werner's code
% https://tex.stackexchange.com/a/37732/3954
\makeatletter
\patchcmd{\endmulticols}{\par}{\par\xdef\@@tpd{\the\prevdepth}}{}{}
\newenvironment{multicolumns}[1]
{% \begin{multicolumns}{<cols>}
\par\nobreak % don't break a page here
\kern\dimexpr\the\prevdepth+\multicolsep\relax % don't take into account the depth of the preceding line + #2
{\columnseprulecolor\hrule height \columnseprule} % the rule, same width as \columnseprule
\kern-\multicolsep % space after the rule
\nointerlineskip % no additional space after the rule
\begin{multicols}{#1}
}
{% \end{multicolumns}
\end{multicols}%
\par\nobreak % don't break a page here
\kern\dimexpr\@@tpd-\multicolsep\relax % don't take into account the depth of the preceding line + #2
{\columnseprulecolor\hrule height \columnseprule} % the rule, same width as \columnseprule
\kern\multicolsep % space after the rule
\nointerlineskip % no additional space after the rule
}
\makeatother
% end of Werner's code
\titlecontents{lsection}
[2.3em]{\small}{\contentslabel{2.3em}}
{\hspace*{-2.3em}}
{\hfill\itshape\contentspage}
\titlecontents{lsubsection}
[4.6em]{\small}{\contentslabel{2.3em}}
{\hspace*{-2.3em}}
{\hfill\itshape\contentspage}
\setlength\columnseprule{1pt}
\newcommand\buildptc{%
\startcontents[chapter]\vspace*{-2.5\baselineskip}
\begin{multicolumns}{2}
\printcontents[chapter]{l}{1}{}
\end{multicolumns}%
}
\begin{document}
\tableofcontents
\chapter{Test Chapter One}
\buildptc
\section{Test Section One One}
\lipsum[2-5]
\subsection{Test Subsection One One One}
\lipsum[2]
\subsection{Test Subsection One One Two}
\lipsum[2]
\subsection{Test Subsection One One Three}
\lipsum[2]
\section{Test Section One Two}
\lipsum[2]
\subsection{Test Subsection One Two One}
\lipsum[2]
\subsection{Test Subsection One Two Two}
\lipsum[2]
\subsection{Test Subsection One Two Three}
\lipsum[2]
\section{Test Section One Three}
\lipsum[2]
\subsection{Test Subsection One Three One}
\lipsum[2]
\subsection{Test Subsection One Three Two}
\lipsum[2]
\subsection{Test Subsection One Three Three}
\lipsum[2]
\end{document}
这里有一个变体,仅显示部分目录中的部分内容:
\documentclass{book}
\usepackage{titlesec}
\usepackage{titletoc}
\usepackage{etoolbox}
\usepackage{multicol}
\usepackage{lipsum}
% start of Werner's code
% https://tex.stackexchange.com/a/37732/3954
\makeatletter
\patchcmd{\endmulticols}{\par}{\par\xdef\@@tpd{\the\prevdepth}}{}{}
\newenvironment{multicolumns}[1]
{% \begin{multicolumns}{<cols>}
\par\nobreak % don't break a page here
\kern\dimexpr\the\prevdepth+\multicolsep\relax % don't take into account the depth of the preceding line + #2
{\columnseprulecolor\hrule height \columnseprule} % the rule, same width as \columnseprule
\kern-\multicolsep % space after the rule
\nointerlineskip % no additional space after the rule
\begin{multicols}{#1}
}
{% \end{multicolumns}
\end{multicols}%
\par\nobreak % don't break a page here
\kern\dimexpr\@@tpd-\multicolsep\relax % don't take into account the depth of the preceding line + #2
{\columnseprulecolor\hrule height \columnseprule} % the rule, same width as \columnseprule
\kern\multicolsep % space after the rule
\nointerlineskip % no additional space after the rule
}
\makeatother
% end of Werner's code
\titlecontents{lsection}
[2.3em]{\small}{\contentslabel{2.3em}}
{\hspace*{-2.3em}}
{\hfill\itshape\contentspage}
\titlecontents{lsubsection}
[4.6em]{\small}{\contentslabel{2.3em}}
{\hspace*{-2.3em}}
{\hfill\itshape\contentspage}
\setlength\columnseprule{1pt}
\newcommand\buildptc{%
\startcontents[chapter]
\begin{multicolumns}{2}
\printcontents[chapter]{l}{0}{\setcounter{tocdepth}{1}}
\end{multicolumns}%
}
\begin{document}
\tableofcontents
\titleformat{\chapter}[display]
{\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}
\titlespacing{\chapter}
{0pt}{40pt}{-10pt}
\chapter{Test Chapter One}
\buildptc
\section{Test Section One One}
\lipsum[2-5]
\subsection{Test Subsection One One One}
\lipsum[2]
\subsection{Test Subsection One One Two}
\lipsum[2]
\subsection{Test Subsection One One Three}
\lipsum[2]
\section{Test Section One Two}
\lipsum[2]
\subsection{Test Subsection One Two One}
\lipsum[2]
\subsection{Test Subsection One Two Two}
\lipsum[2]
\subsection{Test Subsection One Two Three}
\lipsum[2]
\section{Test Section One Three}
\lipsum[2]
\subsection{Test Subsection One Three One}
\lipsum[2]
\subsection{Test Subsection One Three Two}
\lipsum[2]
\subsection{Test Subsection One Three Three}
\lipsum[2]
\section{Test Section One Four}
\lipsum[2-5]
\subsection{Test Subsection One Four One}
\lipsum[2]
\subsection{Test Subsection One Four Two}
\lipsum[2]
\section{Test Section One Five}
\lipsum[2-5]
\subsection{Test Subsection One Five One}
\lipsum[2]
\subsection{Test Subsection One Five Two}
\lipsum[2]
\end{document}
如果部分目录中不显示页码,则上述示例中的垂直规则现在就变得多余,我们可以:
\documentclass{book}
\usepackage{titlesec}
\usepackage{titletoc}
\usepackage{etoolbox}
\usepackage{multicol}
\usepackage{lipsum}
% start of Werner's code
% https://tex.stackexchange.com/a/37732/3954
\makeatletter
\patchcmd{\endmulticols}{\par}{\par\xdef\@@tpd{\the\prevdepth}}{}{}
\newenvironment{multicolumns}[1]
{% \begin{multicolumns}{<cols>}
\par\nobreak % don't break a page here
\kern\dimexpr\the\prevdepth+\multicolsep\relax % don't take into account the depth of the preceding line + #2
{\columnseprulecolor\hrule height 0.4pt} % the rule, same width as \columnseprule
\kern-\multicolsep % space after the rule
\nointerlineskip % no additional space after the rule
\begin{multicols}{#1}
}
{% \end{multicolumns}
\end{multicols}%
\par\nobreak % don't break a page here
\kern\dimexpr\@@tpd-\multicolsep\relax % don't take into account the depth of the preceding line + #2
{\columnseprulecolor\hrule height 0.4pt} % the rule, same width as \columnseprule
\kern\multicolsep % space after the rule
\nointerlineskip % no additional space after the rule
}
\makeatother
% end of Werner's code
\titlecontents{lsection}
[2.3em]{\small}{\contentslabel{2.3em}}
{\hspace*{-2.3em}}
{}
\titlecontents{lsubsection}
[4.6em]{\small}{\contentslabel{2.3em}}
{\hspace*{-2.3em}}
{}
\newcommand\buildptc{%
\startcontents[chapter]
\begin{multicolumns}{2}
\printcontents[chapter]{l}{0}{\setcounter{tocdepth}{1}}
\end{multicolumns}%
}
\begin{document}
\tableofcontents
\titleformat{\chapter}[display]
{\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}
\titlespacing{\chapter}
{0pt}{40pt}{-10pt}
\chapter{Test Chapter One}
\buildptc
\section{Test Section One One}
\lipsum[2-5]
\subsection{Test Subsection One One One}
\lipsum[2]
\subsection{Test Subsection One One Two}
\lipsum[2]
\subsection{Test Subsection One One Three}
\lipsum[2]
\section{Test Section One Two}
\lipsum[2]
\subsection{Test Subsection One Two One}
\lipsum[2]
\subsection{Test Subsection One Two Two}
\lipsum[2]
\subsection{Test Subsection One Two Three}
\lipsum[2]
\section{Test Section One Three}
\lipsum[2]
\subsection{Test Subsection One Three One}
\lipsum[2]
\subsection{Test Subsection One Three Two}
\lipsum[2]
\subsection{Test Subsection One Three Three}
\lipsum[2]
\section{Test Section One Four}
\lipsum[2-5]
\subsection{Test Subsection One Four One}
\lipsum[2]
\subsection{Test Subsection One Four Two}
\lipsum[2]
\section{Test Section One Five}
\lipsum[2-5]
\subsection{Test Subsection One Five One}
\lipsum[2]
\subsection{Test Subsection One Five Two}
\lipsum[2]
\end{document}