在自訂章節標題中手動換行

在自訂章節標題中手動換行
\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適當長度的 a :

\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}

在此輸入影像描述

相關內容