我的文档设置如下:
\documentclass[12pt,a4paper,twoside]{report}
\usepackage[top=25mm, bottom=25mm, outer=15mm, inner=35mm]{geometry}
\renewcommand{\baselinestretch}{1.15}
\usepackage[utf8]{inputenc}
\usepackage{textcomp}
\usepackage{polski}
\usepackage[polish]{babel}
\usepackage{titlesec}
\usepackage{titletoc}
\usepackage{fancyhdr}
\titleformat
{\part}
[display]
{\bfseries \huge \itshape\centering}
{Część \ \thepart}
{0.5ex}
{
\rule{\textwidth}{0pt}
\vspace{1ex}
\centering
}
[
\vspace{-0.5ex}
\rule{\textwidth}{0pt}
]
\titleformat{\chapter}[hang]
{\normalfont\huge\bfseries}
{\thechapter}{18pt}{\huge}
\titlespacing*{\chapter}{0pt}{50pt}{20pt}
\pagestyle{fancy}
\fancyhf{}
\fancypagestyle{plain}{}
\pagenumbering{arabic}
\rfoot{Strona ~\thepage~}
\renewcommand{\headrulewidth}{0pt}
\makeatletter
\renewcommand\@biblabel[1]{#1.}
\makeatother
\begin{document}
\part{The Part name}
...
\chapter{The First Chapter name}
...
\chapter{The Second Chapter name}
...
\chapter{The Third Chapter name}
...
\end{document}
我想实现章节从同一页开始,紧接着上一章的结尾?这篇文章的解决方案关联在我的例子中不起作用。
答案1
您必须\clearpage
从\chapter
宏中删除 s。答案与您发布的链接基本相同,除了一个细节。
您正在加载titlesec
,显然它希望您\chapter
以“垂直模式”输入宏,即在段落之后。\clearpage
默认情况下会这样做,但由于您想删除它,因此您必须\par
在 之前手动插入一个 agraph break \chapter
。
总结
把这个放在你的序言中就可以了:)
\usepackage{etoolbox}
\makeatletter
\patchcmd\chapter
{\if@openright\cleardoublepage\else\clearpage\fi}
{\par}% Inserting a \par here!
{}{}
\makeatother
完整 MWE:
\documentclass[12pt,a4paper,twoside]{report}
\usepackage[top=25mm, bottom=25mm, outer=15mm, inner=35mm]{geometry}
\renewcommand{\baselinestretch}{1.15}
\usepackage[utf8]{inputenc}
\usepackage{textcomp}
\usepackage{polski}
\usepackage[polish]{babel}
\usepackage{titlesec}
\usepackage{titletoc}
\usepackage{fancyhdr}
\titleformat
{\part}
[display]
{\bfseries \huge \itshape\centering}
{Część \ \thepart}
{0.5ex}
{
\rule{\textwidth}{0pt}
\vspace{1ex}
\centering
}
[
\vspace{-0.5ex}
\rule{\textwidth}{0pt}
]
\titleformat{\chapter}[hang]
{\normalfont\huge\bfseries}
{\thechapter}{18pt}{\huge}
\titlespacing*{\chapter}{0pt}{50pt}{20pt}
\pagestyle{fancy}
\fancyhf{}
\fancypagestyle{plain}{}
\pagenumbering{arabic}
\rfoot{Strona ~\thepage~}
\renewcommand{\headrulewidth}{0pt}
\makeatletter
\renewcommand\@biblabel[1]{#1.}
\makeatother
\usepackage{etoolbox}
\makeatletter
\patchcmd\chapter
{\if@openright\cleardoublepage\else\clearpage\fi}
{\par}% Inserting a \par here!
{}{}
\makeatother
\begin{document}
\part{The Part name}
...
\chapter{The First Chapter name}
...
\chapter{The Second Chapter name}
...
\chapter{The Third Chapter name}
...
\end{document}