3

I am trying to typeset the chapter header for a book. It will need to include a custom image to the right of the text Chapter #. I have currently tried to achieve this using multi cols, e.g.

\begin{multicols}{2}
{\let\clearpage\relax
\chapter[Introduction]{Intro this is a long chapter title}}
\vfill
\columnbreak

{\let\clearpage\relax
\vspace{3.5cm}
\hspace{2cm}
\includegraphics[width=6.4cm, right]{periodicTable.jpg}
}
\end{multicols}
... Here comes section and more text

Which produces the following output: enter image description here

I am trying to have the graphics aligned vertically with the 'Chapter 1' string (on the same baseline) and the title textnot being wrapped.

I expect one has to redefine the chapter code somehow but have no idea how to do that. Any pointers appreciated.

2
  • What \documentclass are you using?
    – Werner
    Aug 12, 2014 at 22:29
  • I am using \documentclass[14pt]{extbook} I am sure I saw an example using titlesec, but I can't locate it. Been looking for it for two days :( Aug 13, 2014 at 0:10

1 Answer 1

2

extbook.cls uses a similar chapter construction to book.cls. Below I've modified it to insert an image as specified via the newly-created \chapterimage[<opt>]{<image>} user interface:

enter image description here

\documentclass[14pt,openany]{extbook}
\usepackage{graphicx}

\makeatletter
\newcommand{\@chapterimage}{}
\newcommand{\chapterimage}[2][]{\renewcommand{\@chapterimage}{\includegraphics[#1]{#2}}}
\def\@makechapterhead#1{%
  \vspace*{50\p@}%
  {\parindent \z@ \raggedright \normalfont
    \ifnum \c@secnumdepth >\m@ne
      \if@mainmatter
        \huge\bfseries \@chapapp\space \thechapter
        \hfill\smash{\@chapterimage}% Insert image
        \gdef\@chapterimage{}% Remove image definition
        \par\nobreak
        \vskip 20\p@
      \fi
    \fi
    \interlinepenalty\@M
    \Huge \bfseries #1\par\nobreak
    \vskip 40\p@
  }}
\makeatother
\begin{document}

\chapterimage[width=150pt]{example-image}
\chapter[Introduction]{Intro this is a long chapter title that spans multiple lines}

... Here comes section and more text

\chapter[Another chapter]{Another long chapter title that spans multiple lines}

... Here comes section and more text

\end{document}
1
  • Hello, I just tried this and it worked nicely. Exactly what I asked for. Very very helpful. Thanks a bunch! Aug 13, 2014 at 4:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .