1

I am using the Legrand Orange book template (which seems to be quite popular so I am not posting its details here). A few of my chapter titles are too long and they are being truncated as shown in the attached image 1. Any idea how I can make it wrap the title. enter image description here

I found one person was able to do something similar using KOMA script (see img 2) but I am not using that I am using the regular latex with TexWorks. enter image description here

Please help.

thank you!

  • 1
    Where did you find that solution with KOMA? That you're using TeXworks is actually totally irrelevant, you should be able to use the KOMA version, though you may need to either install or upgrade the KOMA package first (depending on what exactly you currently have installed). – Torbjørn T. Jun 30 '18 at 13:16
  • And if you try the first code block in the accepted answer, how does that fail? – Torbjørn T. Jun 30 '18 at 13:24
  • To be honest, I was too lost in both of those links. He is not really using legrand orange but only trying to reproduce that look. So I am not sure what can I try from that. Legrand's main.tex contains this: '\chapterimage{chapter_head_2.pdf} % Chapter heading image \chapter{Chapter dsaf 1234 asd fad fa 1234 dfa df adf 1234 f adsfasdfa d}' Is there something that I have to do here? I am so sorry, I have no idea what to do. – Priyshrm Jun 30 '18 at 13:42
  • Sorry, my previous comments were probably not that helpful. \chapterimage is only for selecting the image used as the background. One has to make some changes in structure.tex (assuming the version you're using has the same setup as latextemplates.com/template/the-legrand-orange-book). I'll see if I can do it, but no promises. – Torbjørn T. Jun 30 '18 at 14:53
2

Looking at https://www.latextemplates.com/template/the-legrand-orange-book. In structure.tex, find lines 434 to 455. Those lines look like this:

434 \def\@makechapterhead#1{%
...
455 \fi\fi\par\vspace*{270\p@}}}

Replace that entire block of 22 lines with the following:

\newlength\chaptertitleheight
\newsavebox\chaptertitlebox
\def\@makechapterhead#1{%
{\parindent \z@ \raggedright \normalfont
\ifnum \c@secnumdepth >\m@ne
\setbox\chaptertitlebox=\hbox{%
\parbox{15cm}{\huge\sffamily\bfseries\color{black}\thechapter\autodot~#1\strut}}
\setlength\chaptertitleheight{\dimexpr\ht\chaptertitlebox+\dp\chaptertitlebox}
\if@mainmatter
\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};
\draw[anchor=west] (\Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,fill opacity=0.5,inner sep=15pt,minimum height=1.2\chaptertitleheight]{\strut\makebox[22cm]{}};
\draw[anchor=west] (\Gm@lmargin+.3cm,-9cm) node [text width=15cm] {\huge\sffamily\bfseries\color{black}\thechapter\autodot~#1\strut};
\end{tikzpicture}};
\end{tikzpicture}
\else
\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};
\draw[anchor=west] (\Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,fill opacity=0.5,inner sep=15pt,minimum height=1.2\chaptertitleheight]{\strut\makebox[22cm]{}};
\draw[anchor=west] (\Gm@lmargin+.3cm,-9cm) node [text width=15cm] {\huge\sffamily\bfseries\color{black}#1\strut};
\end{tikzpicture}};
\end{tikzpicture}
\fi\fi\par\vspace*{270\p@}}}

Four example pages with short and long, unnumbered and numbered, chapter titles:

enter image description here

  • YES!!! This works. Amazing. Thank you very much for your help. – Priyshrm Jul 1 '18 at 2:59
  • If I may ask one more question, how do I move the title a little upwards to get more space for the page text below? I tried modifying several parameters in the above code and was able to change the width and height of the rounded box. But I couldn't move the whole thing up. – Priyshrm Jul 1 '18 at 3:44
  • @Priyshrm Vertical position is determined by the -9cm you see at four different places. In \draw[anchor=west] (\Gm@lmargin,-9cm), \Gm@lmargin is the x-coordinate and -9cm the y-coordinate, relative to the top left corner of the page. Change -9cm to for example -7cm, or some other length that you find suitable. – Torbjørn T. Jul 1 '18 at 6:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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