作者ChenMeng0518 (Ch'enMeng)
标题Re: [问题] titletoc 之标题对齐
时间Tue Jan 7 19:06:50
这里只讲一下 chapter 的问题﹐section 和 subsection 当然也需要调整一下﹐
但是依样画葫芦并不困难。
\documentclass{book}
% 加上必要的 CJK 支持
\usepackage{titletoc}
\newlength{\ChapterLabelWidth}
\titlecontents{chapter}
[0em]
{}
{\let\OLDthecontentslabel\thecontentslabel%
\renewcommand{\thecontentslabel}{第\CJKnumber{\OLDthecontentslabel}章}%
\settowidth{\ChapterLabelWidth}{\thecontentslabel\hspace*{1em}}%
\contentslabel{\ChapterLabelWidth}}
{\hspace*{0em}}{\titlerule*{.}\contentspage}
\begin{document}
\tableofcontents
\chapter{title title title title title title title title title title title title title title title title title title title title title title title title title }
\end{document}
※ 引述《birdhackor (夜残狼)》之铭言:
: 各位好
: 由於我希望可以将目录的 lable
: 从
: 1 chapter name ........ page
: 1.1 section name .. page
: 变成
: 第一章 chapter name ........ page
: 1.1 section name .. page
: 这样的格式
: 所以我用 titletoc 进行处理
: 语法如下
: \titlecontents{chapter}
: [0em]
: {}
: {第\CJKnumber{\thecontentslabel}章~~}
: {}{\titlerule*{.}\contentspage}
: %
: \titlecontents{section}
: [28pt]
: {}
: {\thecontentslabel\quad}
: {}{\titlerule*{.} \contentspage}
: %
: \titlecontents{subsection}
: [56pt]
: {}
: {\thecontentslabel\quad}
: {}{\titlerule*{.} \contentspage}
: 但我发现
: 这样会产生一个问题
: 原本如果标题过长
: 再换行之後应该会对齐标题
: 像这样
: 1.1 xxxxxxxxxxxxx
: xxxxx ....... 3
: 1.2 sssss ....... 4
: 用了上面的方式之後变成
: 1.1 xxxxxxxxxxxxx
: xxxxx ............ 3
: 1.2 sssss ....... 4
: 请问如何让它恢复对齐呢?
--
来自萌气四溢的 M 君~
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 183.217.25.49
※ 编辑: ChenMeng0518 来自: 183.217.25.49 (01/07 19:44)
※ 编辑: ChenMeng0518 来自: 183.217.25.49 (01/07 19:49)
1F:推 birdhackor:感谢您 01/07 22:39