-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
关于多行标题居中悬挂对齐在目录中的换行问题 #111
Labels
CJK/CTeX-collection
Related to the CTeX macro collection.
Layout/headings
related to \part \chapter \section ...
Comments
\documentclass{ctexbook}
% Fandol 缺字
% \setCJKmainfont{Source Han Serif TC}[ItalicFont=*]
\ctexset{
chapter/name = {第, 回},
chapter/titleformat = \chaptertitleformat
}
\newcommand\chaptertitleformat[1]{%
\parbox[t]{8\ccwd}{#1}}
\begin{document}
\tableofcontents
\chapter{甄士隱夢幻識通靈\hspace{.5em}賈雨村風塵懷閨秀}
\chapter{賈夫人仙逝揚州城\hspace{.5em}冷子興演說榮國府}
\chapter{金陵城起複賈雨村\hspace{.5em}榮國府收養林黛玉}
\chapter{薄命女偏逢薄命郎\hspace{.5em}葫蘆僧亂判葫蘆案}
\chapter{開生面夢演紅樓夢\hspace{.5em}立新場情傳幻境情}
\chapter{賈寶玉初試雨雲情\hspace{.5em}劉姥姥一進榮國府}
\end{document} 目录: 章标题: 页眉: 手写 |
lingr7
referenced
this issue
in lingr7/HongLouMeng-ZhiPingBen
Jan 6, 2020
用 \documentclass{ctexbook}
\usepackage{geometry}
\geometry{showframe}
\ctexset{
chapter = {
format += \centering,
name = {第,回},
nameformat += \chapternameformat,
titleformat = \chaptertitleformat
}
}
\newcommand{\chapternameformat}[1]{\kaishu #1}
\newcommand{\chaptertitleformat}[1]{%
\parbox[t]{8\ccwd}{\CTEXifname{\relax}{\centering}#1}}
\begin{document}
\tableofcontents
\chapter{甄士隱夢幻識通靈\hspace{.5em}賈雨村風塵懷閨秀}
\chapter{賈夫人仙逝揚州城\hspace{.5em}冷子興演說榮國府}
\chapter{金陵城起複賈雨村\hspace{.5em}榮國府收養林黛玉}
\chapter{薄命女偏逢薄命郎\hspace{.5em}葫蘆僧亂判葫蘆案}
\chapter{開生面夢演紅樓夢\hspace{.5em}立新場情傳幻境情}
\chapter{賈寶玉初試雨雲情\hspace{.5em}劉姥姥一進榮國府}
\end{document} |
Liam0205
added
CJK/CTeX-collection
Related to the CTeX macro collection.
Layout/headings
related to \part \chapter \section ...
labels
Apr 23, 2020
另外,用 |
\usepackage[titles]{tocloft}
\setlength{\cftchapnumwidth}{5\ccwd} 完整例子 \documentclass{ctexbook}
\usepackage[showframe]{geometry}
\usepackage[titles]{tocloft}
\setlength{\cftchapnumwidth}{5\ccwd}
\ctexset{
chapter = {
format += \centering,
name = {第,回},
nameformat += \kaishu,
titleformat = \chaptertitleformat
}
}
\newcommand{\chaptertitleformat}[1]{%
\CTEXifname{\parbox[t]{8\ccwd}{#1}}{#1}}
\begin{document}
\tableofcontents
\chapter{甄士隱夢幻識通靈\hspace{.5em}賈雨村風塵懷閨秀}
\chapter{賈夫人仙逝揚州城\hspace{.5em}冷子興演說榮國府}
\chapter{金陵城起複賈雨村\hspace{.5em}榮國府收養林黛玉}
\addtocounter{chapter}{10}
\chapter{薄命女偏逢薄命郎\hspace{.5em}葫蘆僧亂判葫蘆案}
\chapter{開生面夢演紅樓夢\hspace{.5em}立新場情傳幻境情}
\chapter{賈寶玉初試雨雲情\hspace{.5em}劉姥姥一進榮國府}
\end{document} |
提供一种用正则把
从 \chapter ::=
<some staff>
if next char == "*" % \chapter*{title}
\@schapter{title}
else if next char == "[" % \chapter[short title]{title}
\@chapter[short title]{title}
else % \chapter{title}
\@chapter[title]{title}
end if 完整例子 \documentclass{ctexbook}
\usepackage[showframe]{geometry}
\usepackage{varwidth}
%% 设置 \chapter 的样式
\ctexset{
chapter = {
format += \centering,
name = {第,回},
nameformat += \kaishu,
titleformat = \chaptertitleformat
}
}
% 因为对 \@chapter 的修改,此处可恢复使用 varwidth 环境
\newcommand{\chaptertitleformat}[1]{%
\CTEXifname{\begin{varwidth}[t]{.7\linewidth}#1\end{varwidth}}{#1}}
%% 增加 \chapter 对应目录项的 numwidth
\usepackage[titles]{tocloft}
\setlength{\cftchapnumwidth}{5\ccwd}
\ExplSyntaxOn
\makeatletter
%% 在 \chapter 的可选和必选参数的值相同时,把可选参数中的 "\\<任意个空白字符>"
%% 替换为 "\hspace{0.5\ccwd}",间接影响在目录和页眉显示的章标题
\cs_set_eq:NN \@chapter:wn \@chapter
\cs_set_nopar:Npn \@chapter [#1]#2
{
\tl_set:Nn \l_tmpa_tl {#1}
\tl_set:Nn \l_tmpb_tl {#2}
\tl_if_eq:NNT \l_tmpa_tl \l_tmpb_tl
{
\regex_replace_once:nnN { \s*\c{\x5C}\s* } { \c{hspace} \cB\{ 0\.5 \c{ccwd} \cE\} } \l_tmpa_tl
}
\@chapter:wn [\l_tmpa_tl] {\l_tmpb_tl}
}
\makeatother
\ExplSyntaxOff
\begin{document}
\tableofcontents
\chapter{甄士隱夢幻識通靈\\ 賈雨村風塵懷閨秀}
\chapter{賈夫人仙逝揚州城\\ 冷子興演說榮國府}
\chapter{金陵城起複賈雨村\\ 榮國府收養林黛玉}
\addtocounter{chapter}{10}
\chapter{薄命女偏逢薄命郎\\ 葫蘆僧亂判葫蘆案}
\chapter{開生面夢演紅樓夢\\ 立新場情傳幻境情}
\chapter{賈寶玉初試雨雲情\\ 劉姥姥一進榮國府}
\end{document} |
@lingr7 赞。项目地址在哪里? |
红楼梦排版的github仓库地址 https://github.com/lingr7/HongLouMeng-ZhiPingBen |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
CJK/CTeX-collection
Related to the CTeX macro collection.
Layout/headings
related to \part \chapter \section ...
为了实现多行标题的居中悬挂对齐:
以上代码来自cetx.pdf(Texlive2019携带的文档)
正文效果挺好,回目我用
chapter/name = {\kaishu 第,回},
。\@writefile{toc}{\contentsline {chapter}{\numberline {第一回\hspace {.3em}}甄士隐梦幻识通灵\\贾雨村风尘怀闺秀}{3}{chapter.1}\protected@file@percent }
在chapter01.aux文件中的
\\
换行符造成在正式目录中,也出现了一个换行效果。红楼梦排版的github仓库地址
想问一下是否有办法解决目录中也换行了这个问题。
The text was updated successfully, but these errors were encountered: