我在书籍类中使用 minitoc。在每一章中,我都使用 minitoc 包打印一个 minitoc。
有没有办法打印时不显示每行的章节号?比如
第2章
minitoc:
第一部分 ......
第二部分......
代替 :
2.1. 第一节 .....
2.2. 第二部分.....
我找不到正确的命令来重新定义\numberline
mtc 文件上的哪个自定义部分!
梅威瑟:
\documentclass{book}
\usepackage{minitoc}
\begin{document}
\dominitoc
\tableofcontents
\chapter{Introduction}
\chapter{chapter two}
\minitoc
\section{section one}
\section{section two}
\section{section three}
\end{document}
编辑 :
我不确定,但这与这个宏有关。我不知道如何更改 #2 的值:
\def\MTC@contentsline#1#2#3#4{%
\gdef\themtc{\arabic{mtc}}%
\expandafter\ifx\csname #1\endcsname\chapter
\stepcounter{mtc}%
\if@mtc@longext@%
\mtcPackageInfo[I0033]{minitoc}%
{Writing\space\jobname.mtc\themtc\@gobble}%
\def\mtcname{\jobname.mtc\themtc}%
\else
\mtcPackageInfo[I0033]{minitoc}%
{Writing\space\jobname.M\themtc\@gobble}%
\def\mtcname{\jobname.M\themtc}%
\fi
\immediate\closeout\tf@mtc
\immediate\openout\tf@mtc=\mtcname
\fi
\expandafter\ifx\csname #1\endcsname\appendix
\stepcounter{mtc}%
\if@mtc@longext@%
\mtcPackageInfo[I0033]{minitoc}%
{Writing\space\jobname.mtc\themtc\@gobble}%
\def\mtcname{\jobname.mtc\themtc}%
\else
\mtcPackageInfo[I0033]{minitoc}%
{Writing\space\jobname.M\themtc\@gobble}%
\def\mtcname{\jobname.M\themtc}%
\fi
\immediate\closeout\tf@mtc
\immediate\openout\tf@mtc=\mtcname
\fi
\mtc@toks{\noexpand\leavevmode #2}%
\expandafter\ifx\csname #1\endcsname\section
\MTC@WriteContentsline{#1}{mtcS}{#3}{#4}%
\fi
\expandafter\ifx\csname #1\endcsname\subsection
\MTC@WriteContentsline{#1}{mtcSS}{#3}{#4}%
\fi
\expandafter\ifx\csname #1\endcsname\subsubsection
\MTC@WriteContentsline{#1}{mtcSSS}{#3}{#4}%
\fi
\expandafter\ifx\csname #1\endcsname\paragraph
\MTC@WriteContentsline{#1}{mtcP}{#3}{#4}%
\fi
\expandafter\ifx\csname #1\endcsname\subparagraph
\MTC@WriteContentsline{#1}{mtcSP}{#3}{#4}%
\fi
\expandafter\ifx\csname #1\endcsname\coffee
\MTC@WriteCoffeeline{#1}{#3}%
\fi
\expandafter\ifx\csname #1\endcsname\starchapter
\stepcounter{mtc}%
\if@mtc@longext@
\mtcPackageInfo[I0033]{minitoc}%
{Writing\space\jobname.mtc\themtc\@gobble}%
\def\mtcname{\jobname.mtc\themtc}%
\else
\mtcPackageInfo[I0033]{minitoc}%
{Writing\space\jobname.M\themtc\@gobble}%
\def\mtcname{\jobname.M\themtc}%
\fi
\immediate\closeout\tf@mtc
\immediate\openout\tf@mtc=\mtcname
\fi
\expandafter\ifx\csname #1\endcsname\starsection
\MTC@WriteContentsline{#1}{mtcS}{#3}{#4}%
\fi
\expandafter\ifx\csname #1\endcsname\starsubsection
\MTC@WriteContentsline{#1}{mtcSS}{#3}{#4}%
\fi
\expandafter\ifx\csname #1\endcsname\starsubsubsection
\MTC@WriteContentsline{#1}{mtcSSS}{#3}{#4}%
\fi
\expandafter\ifx\csname #1\endcsname\starparagraph
\MTC@WriteContentsline{#1}{mtcP}{#3}{#4}%
\fi
\expandafter\ifx\csname #1\endcsname\starsubparagraph
\MTC@WriteContentsline{#1}{mtcSP}{#3}{#4}%
\fi
}
例如,这会产生如下行:
{\reset@font\mtcSfont\mtc@string\contentsline{section}{\noexpand \leavevmode \numberline {2.1}section one .}{\reset@font\mtcSfont 5}}
答案1
仅在 minitoc 中删除章节编号的一种方法是在章节编号中添加一个命令,该命令的定义将在 minitoc 渲染期间被改变。
考虑将以下代码放入你的序言中:
\newcommand{\filterminitoc}[1]{#1}
\renewcommand{\thesection}{\csname filterminitoc \endcsname{\arabic{chapter}.}\arabic{section}}
\newcommand{\minitocsection}{\begingroup\renewcommand{\filterminitoc}[1]{}\minitoc\endgroup}
第一行定义了一个不执行任何操作的命令,以避免更改 minitoc 之外的结果。第二行重新定义了章节编号,以便将编号的章节部分传递给命令\filterminitoc
。最后一行定义了一个新命令,它将\minitoc
使用修改后的命令进行调用\filterminitoc
,从而防止呈现章节编号。
您现在可以调用\minitocsection
来呈现正确的 minitoc。
完整代码:
\documentclass{book}
\usepackage{minitoc}
\newcommand{\filterminitoc}[1]{#1}
\renewcommand{\thesection}{\csname filterminitoc \endcsname{\arabic{chapter}.}\arabic{section}}
\newcommand{\minitocsection}{\begingroup\renewcommand{\filterminitoc}[1]{}\minitoc\endgroup}
\begin{document}
\dominitoc
\tableofcontents
\chapter{Introduction}
\chapter{chapter two}
\minitocsection
\section{section one}
\section{section two}
\section{section three}
\end{document}
结果: