Theses, Books, Title pagesmore space for chapter title

Classicthesis, Bachelor and Master thesis, PhD, Doctoral degree
Post Reply
templateuser
Posts: 679
Joined: Tue Mar 03, 2015 4:01 pm

more space for chapter title

Post by templateuser »

Hello all,

I thank the community for providing usefull support for this great template.

I have one problem:
Some of my chapter titles are rather long. As a consequence they are cut off after 5 to 7 words.
Now my question:
Is it possible to extend the chapter title over several rows and to adopt the size of the orange box accordingly?

Best regards

snoocad

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
Vel
Site Moderator
Posts: 463
Joined: Fri Jun 29, 2012 1:20 am

Re: more spcae for chapter title

Post by Vel »

Hey snoocad,

You can deal with this problem in a few different ways. The first is to decrease the font size of all chapter titles, but this is probably not the best since then you need to adjust the size of the rounded box they are in. The alternative is to use 2 titles for the longer chapters - one shorter one that appears in the chapter header at the beginning of the chapter and a longer one that appears in the table of contents and in the header of each page in that chapter.

An example of this is: \chapter[Text Chapter: A Careful Inspection]{Text Chapter}

The chapter header will now display "1 - Text Chapter" for this chapter but the table of contents and the headers on each page will display the longer version "Text Chapter: A Careful Inspection".

Cheers,
Vel
Founder and administrator of LaTeXTemplates.com and LaTeXTypesetting.com
MaverickVG
Posts: 4
Joined: Thu Sep 29, 2016 5:03 pm

Re: more space for chapter title

Post by MaverickVG »

Hey!

is it possible to have 2 lines for the chapter title at the beginning of each chapter? This would help me a lot!

Thanks,

Sebastian
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

more space for chapter title

Post by cgnieder »

The template has inefficient and restricting definitions of \@makechapterhead (numbered chapters) and \@makeschapterhead (unnumbered chapters). Here are improved versions which allow multiline chapter titles:

Code: Select all

\makeatletter
\tikzset{
  chaptertitle/.style={
    line width = 2pt ,
    rounded corners = 15pt ,
    draw = ocre ,
    fill = white ,
    fill opacity = 0.5 ,
    inner sep = 15pt ,
    text = black,
    node font = \huge\sffamily\bfseries ,
    text width = \paperwidth-\Gm@lmargin-20pt ,
    align = left
  }
}

\renewcommand\@makechapterhead[1]{%
  {%
    \parindent \z@ \raggedright \normalfont
    \ifnum \c@secnumdepth >\m@ne
      \begin{tikzpicture}[remember picture,overlay]
        \node at (current page.north west)
          {
            \begin{tikzpicture}[remember picture,overlay]
              \node[anchor=north west,inner sep=0pt] at (0,0)
                {\ifusechapterimage\includegraphics[width=\paperwidth]{\thechapterimage}\fi};
              \node[anchor=south west,chaptertitle] at (\Gm@lmargin,-9cm)
                {\if@mainmatter\thechapter. \fi#1\strut};
            \end{tikzpicture}
          };
      \end{tikzpicture}
    \fi
    \par\vspace*{270\p@}
  }%
}

\renewcommand\@makeschapterhead[1]{%
  \begin{tikzpicture}[remember picture,overlay]
    \node at (current page.north west)
      {
        \begin{tikzpicture}[remember picture,overlay]
          \node[anchor=north west,inner sep=0pt] at (0,0)
            {\ifusechapterimage\includegraphics[width=\paperwidth]{\thechapterimage}\fi};
          \node[anchor=south west,chaptertitle] at (\Gm@lmargin,-9cm)
            {#1\strut};
        \end{tikzpicture}
      };
  \end{tikzpicture}
  \par\vspace*{270\p@}
}
\makeatother
Adding this to the preamble and using

Code: Select all

\chapterimage{chapter_head_2.pdf}
\chapter{Text Chapter so long that it spans two lines. Indeed so long that it
  spans two lines.}
gives
lob1.png
lob1.png (187.44 KiB) Viewed 8437 times
More lines are also possible:
lob2.png
lob2.png (187.96 KiB) Viewed 8437 times
BTW: this code in the template

Code: Select all

\newpage
~\vfill
\thispagestyle{empty}

\noindent Copyright \copyright\ 2013 John Smith\\ % Copyright notice

\noindent \textsc{Published by Publisher}\\ % Publisher

\noindent \textsc{book-website.com}\\ % URL

\noindent Licensed under the Creative Commons Attribution-NonCommercial 3.0
Unported License (the ``License''). You may not use this file except in
compliance with the License. You may obtain a copy of the License at
\url{http://creativecommons.org/licenses/by-nc/3.0}. Unless required by
applicable law or agreed to in writing, software distributed under the License
is distributed on an \textsc{``as is'' basis, without warranties or conditions
  of any kind}, either express or implied. See the License for the specific
language governing permissions and limitations under the
License.\\

\noindent \textit{First printing, March 2013}
is against quite a few best practices in LaTeX: paragraph spacing by ending a paragraph with \\ – one should never do that. One of the consequences is a number of underfull hboxes; multiple \noindents is also not very nice; ~\vfill is just wrong. Better:

Code: Select all

\newpage
\thispagestyle{empty}
\vspace*{\fill}
\begingroup
  \setlength\parskip{\baselineskip}
  \setlength\parindent{0pt}
  Copyright \copyright\ 2013 John Smith

  \textsc{Published by Publisher}

  \textsc{book-website.com}

  Licensed under the Creative Commons Attribution-NonCommercial 3.0 Unported
  License (the ``License''). You may not use this file except in compliance
  with the License. You may obtain a copy of the License at
  \url{http://creativecommons.org/licenses/by-nc/3.0}. Unless required by
  applicable law or agreed to in writing, software distributed under the
  License is distributed on an \textsc{``as is'' basis, without warranties or
    conditions of any kind}, either express or implied. See the License for
  the specific language governing permissions and limitations under the
  License.

  \textit{First printing, March 2013}
\endgroup
There may be further places for improvement but I haven't checked :)

Regards
site moderator & package author
MaverickVG
Posts: 4
Joined: Thu Sep 29, 2016 5:03 pm

more space for chapter title

Post by MaverickVG »

Thank you very much! This helped a lot.

One more question: with the new code the text also has a opacity of 0.5. How to get the text back at 1.0? If I change the value than the white background is also set to 1.0 and is not transparent anymore.

Thanks!

Edit: I found it by myself, just add text opacity = 1.0 to the definition and it works!
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

more space for chapter title

Post by cgnieder »

Add text opacity = 1 to the style definition..
site moderator & package author
Post Reply