请问有没有知道afterskip和beforeskip无效该如何解决? \titlespacing 只能改标题后的间距.改前间距的无效 ```tex \documentclass[UTF8, zihao=-4, linespread=1.25]{ctexart} \usepackage{ctexheading} \usepackage{setspace} \usepackage{titlesec} % \titlespacing{\section}{0cm}{55pt}{55pt} \usepackage{titletoc} \titlecontents{section}%.................................目录一级标题 [21pt]%..........................章节标题内容与左边的距离42pt为3cm {\songti \zihao{-3}}% {\contentslabel{1.5em}}%章节序号与章节标题的距离(序号头到标题头距离) {\hspace*{-1.5em}}%.......................无序号章节标题的移动距离 {\titlerule*[0.5pc]{.}\contentspage}%..........章节与页码间的连线 \titlecontents{subsection} [49pt] {\songti \zihao{4}}% {\contentslabel{27pt}}% {}% {\titlerule*[0.5pc]{.}\contentspage}% \titlecontents{subsubsection} [72pt] {\songti \zihao{4}}% {\contentslabel{35pt}}% {}% {\titlerule*[0.5pc]{.}\contentspage}% \renewcommand{\contentsname}{{\zihao{3} {目\quad 录} }} \usepackage{fontspec} % \setmainfont{MicrosoftYaHei} \usepackage{graphicx} \usepackage{geometry} \geometry{a4paper,left=3cm,right=1.5cm,top=3cm,bottom=2.5cm} % \geometry{a4paper} \usepackage{fancyhdr} \pagestyle{fancy} \headheight=3cm \lhead{\quad \newline \hspace{-5pt} % {\renewcommand{\arraystretch}{1.5}\selectfont % 要改變行距的部分} % \linespread{3} 毕业设计(论文)专用纸 \\[-10pt] } \chead{} \rhead{} \lfoot{} \cfoot{\setmainfont{Times New Roman}\thepage} \rfoot{} % \small\sffamily Page \thepage} % \fancyhead{\parbox{16.5cm}{ % \vspace{10pt} \includegraphics[scale=1]{logo.png} \vspace{5.5pt} 毕业论文(论文)专用纸 \hrule height 0.4pt % } % } % \fancyfoot{\parbox{16.5cm}{\hrule \vspace{-21pt} \thepage}} % \fancyhead{\parbox{20em}{\hrule\vspace{2pt}\leftline\thepage}} \renewcommand{\headrulewidth}{0.4pt} \renewcommand{\footrulewidth}{0.4pt} %................................章节样式设计............................... \ctexset{ section = { number = \chinese{section}, format+ = \zihao{-3}\heiti, aftername = \ , afterskip = {20pt}, beforeskip = {29pt}, }, subsection = { format+ = \zihao{4}\setmainfont{SimHei}\heiti, numberformat+ = \setmainfont{SimHei}, fixskip = true, }, subsubsection = { format+ = \zihao{4}\setmainfont{SimHei}\heiti, } } %.................................文章基本信息............................ \title{a} \author{gx} \date{\today} % ....................................................................... % % 以下为正文部分 % % ........................................................................ \begin{document} \newgeometry{right=1.5cm,bottom=2.5cm} \setmainfont{SimSun} %英文字体设为宋体 % \fancyfoot[c]{\setmainfont{Times New Roman}\thepage} \bibliographystyle{plain} \maketitle \thispagestyle{empty} \pagestyle{fancy} %..................................摘要.................................. \newpage \section*{摘\hspace{15pt} 要} \addcontentsline{toc}{section}{摘~ 要} 百年大计,教育为本;教育大计,教师为本。 \bibliography{test} \end{document} ```

1 回答1

59
章节标题出现在页首时,`beforeskip` 自动忽略。设计如此。 ```tex \documentclass[zihao=-4, linespread=1.25]{ctexart} \usepackage{geometry} \geometry{a4paper,left=3cm,right=1.5cm,top=3cm,bottom=2.5cm,showframe} \ctexset{ section = { number = \chinese{section}, format+ = \zihao{-3}\heiti, aftername = \ , afterskip = {20pt}, beforeskip = {29pt}, } } \begin{document} \section*{title} 百年大计,教育为本;教育大计,教师为本。 \section*{摘\hspace{15pt} 要} \addcontentsline{toc}{section}{摘~ 要} 百年大计,教育为本;教育大计,教师为本。 \end{document} ``` ![](https://pics.latexstudio.net/data/images/202003/b27704a51081afe.jpg)

回答: 2020-03-16 16:46

(接上一个回答)可以通过下面的方式修改默认行为,让 `beforeskip` 在位于页面顶部的章节标题中也生效 ```tex \documentclass{ctexart} \usepackage[pass, showframe]{geometry} \usepackage{xpatch} \makeatletter \xpatchcmd\@startsection {\addvspace} {\vspace*} {}{\fail} \makeatother \begin{document} \section{title} abc \section{title} abc ``` ![](https://pics.latexstudio.net/data/images/202003/fdfeeb686de9232.png)

你的回答

请登录后回答

你的回答将会帮助更多人,请务必认真回答问题。