Figures in Headings

From ConTeXt wiki

Jump to: navigation, search

This example shows how to completely replace the chapter text and number by an image:

\useexternalfigure[chapter-1][cow.pdf]
\useexternalfigure[chapter-2][hacker.jpg]

\setuphead
   [chapter]
   [command=\MyChapterCommand]

\def\MyChapterCommand#1#2%
   {\externalfigure[chapter-\currentheadnumber][height=5cm]}

\starttext

\chapter{One}
\section{First section of Chapter One}

\chapter{Two}

\stoptext

However, this "forgets" to put the chapter in the TOC. So you have to set the textcommand and numbercommand separately instead (thus retaining the command that puts the chapter in the TOC), rather than setting the overall command, if you need a complete TOC.

\setuphead
    [chapter]
    [textcommand=\MyChapterTextCommand,
     numbercommand=\MyChapterNumberCommand]

\def\MyChapterNumberCommand#1{} % hide chapter number

\def\MyChapterTextCommand#1%
    {\externalfigure[chapter-\currentheadnumber][height=5cm]}

[1]

Personal tools
Toolbox