3

I'm trying to make the chapter header follow the style: - Chapter tittle is on its own page. - There is an image with full page width above the title, and different image for each chapter. - Optional: the image have caption, and can be link to list of figures.

I'm not new to tex, but my knowledge is quite like a beginner. And I have no idea about which packages/commands to use for this task. Thanks for your help.

Update Thanks @Bernard, with your help I could place the image at where I want. But there is a problem still not done: How can I change image per chapter?

Update 2: The final solution

I use a new command to define the image name, and renew it, which the name of image I want to use for new chapter. To make thing easier, I also create a new command to do all the work. Please see my code and the result below. Very much thanks to @Bernard for your time.

The result I want

\documentclass[11pt,a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lobstertwo}
\usepackage{lmodern}
\usepackage{graphicx} 
\usepackage{microtype}

\usepackage[svgnames, x11names]{xcolor}
\usepackage[explicit,newlinetospace]{titlesec}%

\newcommand{\chapterimage}{nothing}

\newcommand{\newchapter}[2]{
    \renewcommand{\chapterimage}{#2}
    \chapter{#1}
}

\titleformat{\chapter}[display]{\titleline[c]{\includegraphics[width=\pdfpagewidth]{\chapterimage}}\vskip4ex\bfseries}%
{\LARGE\chaptername \thechapter}{4ex}%
{\lsstyle \Huge\filcenter{\itshape\LobsterTwo#1}}[\thispagestyle{empty}\clearpage]%

\titlespacing{\chapter}{0pt}{-\dimexpr0.75\baselineskip + 1in + \voffset + \topmargin + \headheight + \headsep}{6\baselineskip}

\begin{document}%

    \newchapter{This is a very long\\ chapter title, which take\\ lot of space in header}{header}%    
    \newchapter{This is the second chapter header}{mouse}%
    \newchapter{This chapter use a cat image as its header}{cat}%

\end{document} 
  • 1
    Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – Symbol 1 Apr 26 '15 at 15:51
  • Welcome to TeX.SX! to make any sort of sensible answer, we need more information, in particular the document class you're using. my first guess would be that you would need to redefine the title block and \maketitle. – barbara beeton Apr 26 '15 at 15:54
  • @barbarabeeton Are you thinking of setting it up so \maketitle can be issued for each chapter? I would have expected redefining \chapter to be a more obvious move but maybe using something like titling and having each \chapter create a new title page makes more sense? – cfr Apr 26 '15 at 16:07
  • 1
    @cfr -- oops! i should have said to redefine \chapter. \maketitle is just plain wrong. sorry! – barbara beeton Apr 26 '15 at 16:50
  • It would be preferable to post your final solution as an answer so that people can more easily identify it. (There's no problem with answering your own question although the site enforces some sort of minimum waiting period, I think, and then rather annoyingly asks you if you are sure you really wouldn't rather edit your question.) – cfr Apr 26 '15 at 20:07
2

The titleline command, from the titlesecpackage allows to include horizontal material in headers.

Note I used the lobster2 font only to get something similar to your image. It has to be loaded before any other font loading, as it redefines the default roman family. Also I supposed this page should be unnumbered.

    \documentclass[11pt,a4paper]{report}
    \usepackage[utf8]{inputenc}
    \usepackage[T1]{fontenc}
    \usepackage{lobstertwo}
    \usepackage{lmodern}
    \usepackage{graphicx} 

    \usepackage{microtype}

    \usepackage[svgnames, x11names]{xcolor}
    \usepackage[explicit,newlinetospace]{titlesec}%

    \titleformat{\chapter}[display]{\titleline{\includegraphics[width=\linewidth]{titleimage.jpg}}\vskip4ex\bfseries}%
    {\LARGE\chaptername \thechapter}{4ex}%
    {\lsstyle \Huge\filcenter{\itshape\LobsterTwo#1}}[\thispagestyle{empty}\clearpage]%

    \titlespacing{\chapter}{0pt}{-\dimexpr0.75\baselineskip + 1in + \voffset + \topmargin + \headheight + \headsep}{6\baselineskip}

    \begin{document}%

    \chapter{This is a very long\\ chapter title, which take\\ lot of space in header}%

    Some text

    \end{document} 

enter image description here

  • Thanks @Bernard for suggesting the titleline, I try it, with a little modification from your code: \titleline[c]{\includegraphics[width=\pdfpagewidth]{header}}. It's seem work, except one thing that I can move the image on the top of page (with no margin). And, this solution may not allow to change the image for different chapter. I going to define a custom command for this task. – Tai Le Apr 26 '15 at 18:48
  • Do you mean you want the image at the top of the physical page? For the image perchapter problem, I had forgotten that requirement. I'll try to find a solution. – Bernard Apr 26 '15 at 18:54
  • Yes, I want the image on top of physical page. – Tai Le Apr 26 '15 at 18:55
  • Done. See my updated answer. – Bernard Apr 26 '15 at 19:10
  • Fine! I perhaps would prefer redefining the value of \chapterimage just before calling an ordinary \chapter command, but that's mainly a matter of personal taste. – Bernard Apr 26 '15 at 20:42

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.