# ConTeXt inserting images into header

I need to insert three images into header in ConTeXt and specific info in the footer.

The equivalent snippet in LaTeX is:

\usepackage{fancyhdr}
\renewcommand{\title}[1]{\gdef\@title{#1}\gdef\mytitle{#1}}
\title{Page}
\pagestyle{fancy}
\rfoot{Page \thepage\ of \pageref{LastPage}}
\cfoot{\currfilename}
\lfoot{\mytitle}


I would also have a line after header and before footer (LaTeX snippet doesn't do that).

NOTE: I'm a complete ConTeXt newbie and I'm struggling to catch up.

• Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. – BambOo Aug 7 '18 at 15:57

This will probably get you on track. You can use the setup commands to define your header and footer commands and then apply them using the appropriate command for header of footer respectively.

I have left the page layout to you (margins etc.), but it's not that hard to figure it out, because the ConTeXt wiki pages are very descriptive.

\setuppagenumbering[alternative=singlesided]

\def\title{Test}

\setupfootertexts[\setups{simplefoot}]

\externalfigure[example-image.pdf][height=1.5cm]
\hfill
\externalfigure[example-image.pdf][height=1.5cm]
\stopsetups
\startsetups[simplefoot]
\rlap{\title}
\hfill
\jobname
\hfill
\llap{Page \pagenumber\ of \lastpagenumber}
\stopsetups

\starttext
Test
\page
Quack
\stoptext

• For the lines have a look at the \setupbackgrounds command. – TeXnician Aug 7 '18 at 16:17

Here is a slightly different solution than TeXnician's:

\setuppagenumbering[location=]
\useMPlibrary[dum]

\definemeasure[ruledistance][5pt]

\setuplayout
footerdistance=2\measure{ruledistance},
footer=\lineheight,
height=middle,
]

\setupfootertexts[\jobname]
\setupfootertexts[title][Page \pagenumber\ of \lastpagenumber]

\setupbackgrounds[footer][text][topframe=on,    frameoffset=\measure{ruledistance}]

\starttext
\starttitle[title=My sample document]
Test
\page
Quack
\stoptitle
\stoptext


• I define measures for lengths that are used multiple times in the document.
• I use defineexternalfigure to specify figure settings that are shared by multiple figures.
• I use the two argument version of \setupheadertexts[][] rather than manual alignment. This is similar in spirit to the fancyhdr package.
• The marking for the current title is automatically stored as title. So you don't need to define a new macro to store its value. It can also be retrieved using \getmarking[title].