`tocstyle` 和 `mwbk` 不兼容

`tocstyle` 和 `mwbk` 不兼容

我知道tocstyle可能存在兼容性问题,但它通过几个命令提供了我可能需要的所有预定义样式。另一方面,我可能会使用titletoc,但它似乎不太方便(使用 只需 2 行代码就可以完成很多代码tocstyle)。但是,tocstyle似乎与mwcls类存在一些不兼容性——文档可以编译(即 pdf 看起来不错),但有警告:

Missing number, treated as zero. \begin{document}
Undefined control sequence. \begin{document}

梅威瑟:

\documentclass{mwbk} 
\usepackage{blindtext}

\usepackage[tocgraduated]{tocstyle}

\usetocstyle{nopagecolumn}

\begin{document}



\tableofcontents

\frontmatter

\chapter{title}

\chapter{title}

\mainmatter

\chapter{This is a huge chapter name just for testing. This is a huge chapter name just for testing. This is a huge chapter name just for testing. }

\chapter{This is a huge chapter name just for testing. This is a huge chapter name just for testing. This is a huge chapter name just for testing with Lualatex}

\chapter{title}

\blinddocument

\end{document}

答案1

请注意,该软件包目前只有 alpha 版本tocstyle,据我所知,该软件包已不再开发。您可以改用以下软件包tocbasic

\documentclass{mwbk} 
\usepackage{blindtext}
\usepackage{expl3}
\usepackage{tocbasic}

\ExplSyntaxOn
\clist_map_inline:nn 
  {chapter,section,subsection,subsubsection,paragraph,subparagraph,figure,table}
  {
    \DeclareTOCStyleEntry[
      linefill=\quad,
      raggedpagenumber,
      pagenumberbox=\hbox
    ]{tocline}{#1}
  }
\ExplSyntaxOff
\DeclareTOCStyleEntry[
  entryformat=\sffamily\textbf,
  pagenumberformat=\normalfont
]{tocline}{chapter}
\makeatletter
\renewcommand\@tocrmarg{0pt}
\makeatother

\begin{document}
\tableofcontents
\frontmatter
\chapter{title}
\chapter{title}
\mainmatter
\chapter{This is a huge chapter name just for testing. This is a huge chapter name just for testing. This is a huge chapter name just for testing. }
\chapter{This is a huge chapter name just for testing. This is a huge chapter name just for testing. This is a huge chapter name just for testing with Lualatex}
\chapter{title}
\blinddocument
\end{document}

结果:

在此处输入图片描述

相关内容