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.

A short time ago, I asked this question to resize the width of a chapter section.

But there is another problem with the footer. If the chapter name is too long, the chapter name in the footer ends in the middle. Is there any possibility to make the height optimal for two lines?

Chapter name

Footer

I tried to make a working sample, but it's not optimal...

\documentclass{scrbook}
\usepackage{xcolor}
\usepackage{titlesec}
\usepackage{lmodern}% just for the example
\usepackage{lipsum}% just for the example
\usepackage{hyperref}
\usepackage{fancyhdr} 
\usepackage{tgheros}

\colorlet{ctcolorchapterline}{cyan}
\colorlet{ctcolorchapternum}{cyan}

\newcommand\mychapformat[1]{%
  \parbox[b]{\dimexpr\textwidth-3em\relax}{\raggedright#1}}
\titleformat{\chapter}[display]%
  {\usekomafont{chapter}}%
  {\vspace{-8em}\raggedleft{%
    {\color{ctcolorchapterline}%
        \rule[-5pt]{2pt}{5cm}}\quad%
    {\color{ctcolorchapternum}
        \fontsize{60}{60}\selectfont\thechapter}%
    }%
  }%
  {-2.1em}%
  {\mychapformat}%
  [\phantomsection]

% **************************************************
% Header and Footer
% **************************************************
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{%
    \markboth{%
        \footnotesize%
        {\color{ctcolorchapterline}\textbf{\chaptername\ \thechapter}}%
        \quad%
        {\color{ctcolorchapterline}#1}%
    }{}%
}
\renewcommand{\sectionmark}[1]{%
    \markright{%
        \footnotesize%
        {\color{ctcolorchapterline}\textbf{\thesection}}%
        \quad%
        {\color{ctcolorchapterline}#1}%
    }%
}
%
\fancypagestyle{plain}{%
    \fancyhf{}
    \fancyfootoffset[OR]{1.85cm}
    \fancyfoot[OR]{%
        {\ }\usekomafont{chapter}%
        {\color{ctcolorchapterline}\rule[-90pt]{1.25pt}{100pt}}%
        \hspace*{10pt}\begin{minipage}[b]{1.5cm}%
            \color{ctcolorchapterline}\normalsize\textbf{\thepage}%
        \end{minipage}%
    }
    \fancyfootoffset[EL]{1.85cm}
    \fancyfoot[EL]{%
        \usekomafont{chapter}%
        \begin{minipage}[b]{1.5cm}%
            \raggedleft\color{ctcolorchapterline}\normalsize\textbf{\thepage}%
        \end{minipage}%
        \hspace*{10pt}{\color{ctcolorchapterline}\rule[-90pt]{1.25pt}{100pt}}%
    }
    \renewcommand{\headrulewidth}{0pt}
    \renewcommand{\footrulewidth}{0pt}
}
%
\fancypagestyle{maincontentstyle}{%
    \pagestyle{plain}
    \fancyhf{}
    \fancyfootoffset[OR]{1.85cm}
    \fancyfoot[OR]{%
        {\ }\usekomafont{chapter}\footnotesize%
        \rightmark%
        \hspace*{0.75cm}{\color{ctcolorchapterline}\rule[-90pt]{1.25pt}{100pt}}%
        \hspace*{10pt}\begin{minipage}[b]{1.5cm}%
            \color{ctcolorfooterpage}\normalsize\textbf{\thepage}%
        \end{minipage}%
    }
    \fancyfootoffset[EL]{1.85cm}
    \fancyfoot[EL]{%
        \usekomafont{chapter}\footnotesize%
        \begin{minipage}[b]{1.5cm}%
            \raggedleft\color{ctcolorchapterline}\normalsize\textbf{\thepage}%
        \end{minipage}%
        \footnotesize%
        \hspace*{10pt}{\color{ctcolorchapterline}\rule[-90pt]{1.25pt}{100pt}}%
        \hspace*{0.75cm}\leftmark%
    }
}

\begin{document}

\chapter{A test chapter with a long title that will span two lines}
\lipsum[1-6]

\end{document}
share|improve this question
    
That example produces rather odd results for me. I get no title at all in the footer and the chapter title itself goes over the blue line, while the chapter number is displayed as 'size60601'. Please make sure that your code really demonstrates the issue you are concerned with. –  cfr Mar 30 at 22:07
    
I noticed a warning not to combine Koma font with fancyhdr. –  John Kormylo Mar 30 at 22:27
    
@JohnKormylo Yes, I didn't change that stuff but this is almost certainly not the best way to do this given the facilities offered by the Koma classes. –  cfr Mar 30 at 23:53
add comment

1 Answer 1

Do you want something like this?

Footer - multiline

\documentclass{scrbook}
\usepackage{xcolor}
\usepackage{titlesec}
\usepackage{lmodern}% just for the example
\usepackage{lipsum}% just for the example
\usepackage{hyperref}
\usepackage{fancyhdr}
\usepackage{tgheros}
\usepackage{layout}

\colorlet{ctcolorchapterline}{cyan}
\colorlet{ctcolorchapternum}{cyan}

\newcommand\mychapformat[1]{%
  \parbox[b]{\dimexpr\textwidth-3em\relax}{\raggedright#1}}
\titleformat{\chapter}[display]%
  {\usekomafont{chapter}}%
  {\vspace{-8em}\raggedleft{%
    {\color{ctcolorchapterline}%
        \rule[-5pt]{2pt}{5cm}}\quad%
    {\color{ctcolorchapternum}
        \fontsize{60}{60}\selectfont\thechapter}%
    }%
  }%
  {-2.1em}%
  {\mychapformat}%
  [\phantomsection]

% **************************************************
% Header and Footer
% **************************************************
\renewcommand{\chaptermark}[1]{%
    \markboth{%
        \footnotesize%
        {\color{ctcolorchapterline}\textbf{\chaptername\ \thechapter}}%
        \quad%
        {\color{ctcolorchapterline}#1}%
    }{}%
}
\renewcommand{\sectionmark}[1]{%
    \markright{%
        \footnotesize%
        {\color{ctcolorchapterline}\textbf{\thesection}}%
        \quad%
        {\color{ctcolorchapterline}#1}%
    }%
}
%
\fancypagestyle{plain}{%
    \fancyhf{}
    \fancyfootoffset[OR]{1.85cm}
    \fancyfoot[OR]{%
        {\ }\usekomafont{chapter}%
        {\color{ctcolorchapterline}\rule[-90pt]{1.25pt}{100pt}}%
        \hspace*{10pt}\begin{minipage}[b]{1.5cm}%
            \color{ctcolorchapterline}\normalsize\textbf{\thepage}%
        \end{minipage}%
    }
    \fancyfootoffset[EL]{1.85cm}
    \fancyfoot[EL]{%
        \usekomafont{chapter}%
        \begin{minipage}[b]{1.5cm}%
            \raggedleft\color{ctcolorchapterline}\normalsize\textbf{\thepage}%
        \end{minipage}%
        \hspace*{10pt}{\color{ctcolorchapterline}\rule[-90pt]{1.25pt}{100pt}}%
    }
    \renewcommand{\headrulewidth}{0pt}
    \renewcommand{\footrulewidth}{0pt}
}
%
\newlength{\mychapbox}
\setlength{\mychapbox}{\textwidth}
\addtolength{\mychapbox}{-1.5em}
\addtolength{\mychapbox}{-0.75cm}
\addtolength{\mychapbox}{-10pt}
\fancypagestyle{maincontentstyle}{%
    \pagestyle{plain}
    \fancyhf{}
    \fancyfootoffset[OR]{1.85cm}
    \fancyfoot[OR]{%
        {\ }\usekomafont{chapter}\footnotesize%
        \rightmark%
        \hspace*{0.75cm}{\color{ctcolorchapterline}\rule[-90pt]{1.25pt}{100pt}}%
        \hspace*{10pt}\begin{minipage}[b]{1.5cm}%
            \color{ctcolorfooterpage}\normalsize\textbf{\thepage}%
        \end{minipage}%
    }
    \fancyfootoffset[EL]{1.85cm}
    \fancyfoot[EL]{%
        \usekomafont{chapter}\footnotesize%
        \begin{minipage}[b]{1.5cm}%
            \raggedleft\color{ctcolorchapterline}\normalsize\textbf{\thepage}%
        \end{minipage}%
        \footnotesize%
        \hspace*{10pt}{\color{ctcolorchapterline}\rule[-90pt]{1.25pt}{100pt}}%
        \hspace*{0.75cm}%
        \begin{minipage}[t]{\mychapbox}%
            \raggedleft\usekomafont{chapter}\color{ctcolorchapterline}\footnotesize\leftmark%
        \end{minipage}%
    }
}
\pagestyle{maincontentstyle}

\begin{document}

\chapter{A test chapter with a long title that will span two lines}
\lipsum[1-6]

\end{document}
share|improve this answer
add comment

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.