Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.
\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}

Hello,

my problem is that chapter dosen't fit the text on a page. I have tried many things such as:

\protect

How to make (force) line-break in Chapter Title (in ToC, Chapter, Header) - if possible?

chapter title long and necessity to cut it

How to make title of chapter to fit the page size?

share|improve this question

1 Answer 1

up vote 5 down vote accepted

In the definition of \@makechapterhead and \@makeschapterhead replace the \hbox in which the title will be typeset with a \parbox of the appropriate length:

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

enter image description here

share|improve this answer
    
Great! Sometimes I wonder, how is it, that You always anwser my questions, and always You do it first. Whatever, I'm greateful. –  Daniel Miliński Aug 25 '12 at 23:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.