3

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}
\setlength\headheight{48pt}
\lhead{\includegraphics[height=1.5cm]{Soft-in_logo}}
\rhead{\includegraphics[height=1.5cm]{SQS_ISO_logo\includegraphics[height=1.5cm]{IQNet_logo}}
\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
2

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}

\setupheadertexts[\setups{simplehead}]
\setupfootertexts[\setups{simplefoot}]

\startsetups[simplehead]
  \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
5

Here is a slightly different solution than TeXnician's:

\setuppagenumbering[location=]
\useMPlibrary[dum]

\definemeasure[headerheight][1.5cm]
\definemeasure[ruledistance][5pt]

\setuplayout
  [header=\measure{headerheight},
   headerdistance=2\measure{ruledistance},
   footerdistance=2\measure{ruledistance},
   footer=\lineheight,
   height=middle,
  ]

\defineexternalfigure[header][height=\measure{headerheight}]

\setupheadertexts[{\externalfigure[logo-1.pdf][header]}]
                 [{\externalfigure[logo-2.pdf][header]}]
\setupfootertexts[\jobname]
\setupfootertexts[title][Page \pagenumber\ of \lastpagenumber]

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

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

Some comments:

  • 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].

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.