\documentclass[openany, 10pt]{book}
\usepackage[utf8]{inputenc}
\usepackage[MeX]{polski}
\usepackage{titleps}
\usepackage{lipsum}
\usepackage{tocloft}
\renewcommand\cftchapaftersnum{.}% adds dot after chapter title in ToC
\renewcommand\cftchapdotsep{\cftdotsep}% adds leader dots from chapter titles to page numbers
\frenchspacing
\usepackage{pstcol}
\makeatletter
\def\LigneVerticale{\vrule height 5cm depth 2cm\hspace{0.1cm}\relax}
\def\LignesVerticales{
\let\LV\LigneVerticale\LV\LV\LV\LV\LV\LV\LV\LV\LV\LV}
\def\GrosCarreAvecUnChiffre#1{%
\rlap{\vrule height 0.8cm width 1cm depth 0.2cm}%
\rlap{\hbox to 1cm{\hss\mbox{\white #1}\hss}}%
\vrule height 0pt width 1cm depth 0pt}
\def\@makechapterhead#1{\hbox{%
\Huge
\LignesVerticales
\hspace{-0.5cm}%
\GrosCarreAvecUnChiffre{\thechapter.}% the final dot adds a dor after the chapter number in the document
\hspace{0.2cm}\hbox{#1}%
\renewcommand\numberline[1]{#1.\hskip0.7em}
}\par\vskip 2cm}
\def\@makeschapterhead#1{\hbox{%
\Huge
\LignesVerticales
%\hspace{0.5cm}%
\hbox{#1}%
}\par\vskip 2cm}
\begin{document}
\chapter{Much too long chapter title with linebreak}
\lipsum[1-10]
\end{document}
你好,
我的问题是章节不适合页面上的文本。我尝试了很多方法,例如:
\保护
如何在章节标题(在目录、章节、页眉中)进行(强制)换行 - 如果可能的话?
如何使章节标题适合页面大小?
答案1
在 的定义中\@makechapterhead
,将要排版标题的\@makeschapterhead
替换为适当长度的 :\hbox
\parbox
\documentclass[openany, 10pt]{book}
\usepackage[utf8]{inputenc}
\usepackage[MeX]{polski}
\usepackage{titleps}
\usepackage{lipsum}
\usepackage{tocloft}
\renewcommand\cftchapaftersnum{.}% adds dot after chapter title in ToC
\renewcommand\cftchapdotsep{\cftdotsep}% adds leader dots from chapter titles to page numbers
\frenchspacing
\usepackage{pstcol}
\makeatletter
\def\LigneVerticale{\vrule height 5cm depth 2cm\hspace{0.1cm}\relax}
\def\LignesVerticales{
\let\LV\LigneVerticale\LV\LV\LV\LV\LV\LV\LV\LV\LV\LV}
\def\GrosCarreAvecUnChiffre#1{%
\rlap{\vrule height 0.8cm width 1cm depth 0.2cm}%
\rlap{\hbox to 1cm{\hss\mbox{\white #1}\hss}}%
\vrule height 0pt width 1cm depth 0pt}
\def\@makechapterhead#1{\hbox{%
\Huge
\LignesVerticales
\hspace{-0.5cm}%
\GrosCarreAvecUnChiffre{\thechapter.}% the final dot adds a dor after the chapter number in the document
\hspace{0.2cm}\parbox[t]{\dimexpr\linewidth-2.2cm\relax}{\raggedright#1}%
\renewcommand\numberline[1]{#1.\hskip0.7em}
}\par\vskip 2cm}
\def\@makeschapterhead#1{\hbox{%
\Huge
\LignesVerticales
%\hspace{0.5cm}%
\parbox[t]{\dimexpr\linewidth-1.6cm\relax}{\raggedright#1}%
}\par\vskip 2cm}
\begin{document}
\chapter[A test chapter]{A Test Numbered Chapter with a Really Really Long Title}
\lipsum[1-10]
\end{document}