0

I want to set up chapter headers to look like this:

||
|| Chapter 1
|| The City Begins
|| to Decay

The two vertical bars represent a series of vertical bars drawn in xfig. I've tried this:

\titleformat{\chapter}
[display]
{\normalfont\Large\bfseries}{
\includegraphics{chapter-graphic}
\chaptertitlename\ \thechapter
}
{-10pt}
{\titlefont}

Instead I get this:

Malformed chapter header 1

After applying Bernard's suggestion below and adjusting the first parameter, I get this:

Malformed chapter header 2

Note how this causes "Chapter X" to be indented, but not the chapter name. Putting \indent into any parameter of \titleformat won't help. Now look how the bottom of the image is not anchored to the bottom of the text:

Malformed chapter header 3

EDIT: Adding code for graphic

#FIG 3.2  Produced by xfig version 3.2.6a
Landscape
Center
Metric
A4
100.00
Single
-2
1200 2
2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
         0 0 45 0 45 1125 0 1125 0 0
2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
         90 1125 135 1125 135 -90 90 -90 90 1125
2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
         180 1125 225 1125 225 -180 180 -180 180 1125
2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
         270 1125 315 1125 315 -270 270 -270 270 1125
2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
         360 1125 405 1125 405 -360 360 -360 360 1125
2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
         450 1125 495 1125 495 -450 450 -450 450 1125
2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
         540 1125 585 1125 585 -540 540 -540 540 1125
  • For the graphic inclusion, try something like \raisebox{-\height}[0pt][0pt]{\includegraphics{chapter-graphic}}. – Bernard Sep 30 '18 at 11:02
  • @Bernard I adjusted the first parameter in your suggestion to get the actual height right. However, the height is not aligned to anything. It needs to align to the bottom of the chapter name. Also, "Chapter X" is indented, but not the chapter name. No amount of \indent seems to help. See above for the malformed chapter headers. – Frotz Oct 1 '18 at 21:27
  • @JohnKormylo, can I get an example of how to use tikzpicture, tikspagenodes for doing this? I find no such examples. – Frotz Oct 1 '18 at 21:28
  • And with the block style? – Bernard Oct 1 '18 at 21:52
  • @Bernard What do you mean by block style? The text should all be left-justified, appear just to the right of the graphic, and the graphic should be anchored about 30pt or so below the text. – Frotz Oct 1 '18 at 21:58
2

This solution puts a normal chapter into a \parbox and inserts the graphic in front (with a gap of \columnsep).

It uses a fixed width for the graphic, but adjusts the height to match the heading. It uses the definition for \chapter from book class (50pt above, 40pt below).

\documentclass{book}
%\usepackage{titlesec}
\usepackage{graphicx}
\usepackage{showframe}% debugging tool
\usepackage{lipsum}% MWE only

\makeatletter
\def\@makechapterhead#1{%
  \vspace*{50\p@}%
  {\parindent \z@ \parskip \z@
    \sbox0{\parbox[b]{\dimexpr\textwidth-2cm-\columnsep}{% width is preset
      \raggedright \normalfont
      \ifnum \c@secnumdepth >\m@ne
        \if@mainmatter
          \huge\bfseries \@chapapp\space \thechapter
          \par\nobreak
          \vskip 20\p@
        \fi
      \fi
      \interlinepenalty\@M
      \Huge \bfseries #1}}%
    \raisebox{-\dp0}[\ht0][\dp0]{% [\ht0][\dp0] redundant in this case
      \includegraphics[height={\dimexpr\ht0+\dp0},width=2cm]{example-image-duck}}%
    \hspace{\columnsep}\usebox0
    \par\nobreak}%
  \vskip 40\p@
}
\makeatother

\begin{document}
\frontmatter
\tableofcontents
\mainmatter
  \chapter[pipes]{Someone finds the old pipes leading downward}

  \lipsum[1-6]
\end{document}

demo


This solution is for memoir class.

\documentclass{memoir}
%\usepackage{titlesec}
\usepackage{graphicx}
\usepackage{showframe}% debugging tool
\usepackage{lipsum}% MWE only

\makeatletter
\def\@makechapterhead#1{%
  \chapterheadstart%
  {\parskip \z@
   \parindent \z@ 
   \sbox0{\parbox[b]{\dimexpr\textwidth-2cm-\columnsep}{% graphic width 2cm
     \memRTLraggedright \normalfont
     \ifm@m@And
       \printchaptername \chapternamenum \printchapternum
       \afterchapternum % \par\nobreak \vskip 20\p@
     \else
       \printchapternonum
     \fi
     \interlinepenalty\@M
     \printchaptertitle{#1}}}% \Huge \bfseries #1
   \raisebox{-\dp0}[\ht0][\dp0]{% [\ht0][\dp0] redundant in this case
     \includegraphics[height={\dimexpr\ht0+\dp0},width=2cm]{example-image-duck}}%
   \hspace{\columnsep}\usebox0%
   \afterchaptertitle%
  }}
\makeatother

\begin{document}
\frontmatter
\tableofcontents
\mainmatter
  \chapter[pipes]{Someone finds the old pipes leading downward}

  \lipsum[1-6]
\end{document}
|improve this answer|||||
  • If I adjust the line {\vskip-\topskip\vskip-50pt to {\vskip-\topskip\vskip-25pt, I seem to get the projection above the top of the text I need. However, this doesn't work on the memoir class. – Frotz Oct 2 '18 at 10:07
  • Memoir uses \beforechapskip and \afterchapskip, which default to 50pt and 40pt again. Anyway, I simplified the solution by only modifying \@makechapterhead. – John Kormylo Oct 2 '18 at 13:27
  • Note to myself and others: to get this to work for \chapter*{Foobar}, redefine \@makeschapterhead as well as \@makechapterhead. – Frotz Oct 6 '18 at 1:00

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.