2

I need some text to run into the margin in my header and footer using the exam class. All the solutions I have found use the fancyhdr package, but it conflicts with \lhead and \rhead defined in exam class.

Essentially I'm trying to replicate \fancyhfoffset[R]{0.4in} but using the exam class. I tried looking at the .sty for fancyhdr, but it was way above my head...

EDIT: My apologies, I thought that my question would be clear enough without a MWE.

I'd like to move this footer (and header) to the right by 0.4 inches (as shown by the right arrow). MWE as follows:

\documentclass[12pt]{exam}
\usepackage{amsmath}
\usepackage[a4paper]{geometry}
\geometry{verbose,tmargin=1in,bmargin=1in,lmargin=0.8in,rmargin=1.2in}
\setlength{\parskip}{\smallskipamount}
\setlength{\parindent}{0pt}
\usepackage{mathtools}
\usepackage{graphicx}
\usepackage{lipsum}

\geometry{showframe}   
\addpoints
  
\runningfooter%
    {}
    {}
    {\iflastpage{}{
        \textbf{Question \thequestion }%
        \ifcontinuation{ -- continued}{}\\%
        \oddeven{\textbf{TURN OVER}}{}
        }
    }
%MOVE THIS FOOTER TO THE RIGHT BY 0.4in, same for the header, but I've left it out as the header is even longer which lots of if conditions.

\pagestyle{headandfoot}

\begin{document}
    \begin{questions}
    \question \lipsum[1]
        \begin{parts}
        \part[1] \lipsum[2]
        \newpage
        \part[1] \lipsum[3]
        \newpage
        \part[1] \lipsum[4]
        \newpage
        \part[1] \lipsum[5]
        \end{parts}
    \end{questions}
\end{document}
2
  • 1
    Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
    – user31729
    Jul 6, 2015 at 8:36
  • @ChristianHupfer I've added a MWE, not that I think it adds much in my opinion. However the screenshot of what I'm trying to achieve hopefully clarifies my question more
    – Alwin
    Jul 6, 2015 at 10:49

2 Answers 2

3

A solution is to patch footer and header's commands. You can try

\usepackage{xpatch}

\makeatletter
\patchcmd{\run@fullfoot}{\hbox to \textwidth}{\hbox to \dimexpr\textwidth+0.4in\relax}%
{}{\errmessage{Patching of \noexpand\run@fullfoot failed}}
\makeatother

and for header it's \run@fullhead

1
  • this is a very nice solution thank you! I've marked your answer as correct because it changes all the header and footers at once!
    – Alwin
    Jul 8, 2015 at 10:07
3

Not sure if it is ‘TURN OVER’ only that has to be pushed into the margin, but here is a solution:

\documentclass[12pt]{exam}
\usepackage{amsmath}
\usepackage[a4paper]{geometry}
\geometry{verbose,tmargin=1in,bmargin=1in,lmargin=0.8in,rmargin=1.2in}
\setlength{\parskip}{\smallskipamount}
\setlength{\parindent}{0pt}
\usepackage{mathtools}
\usepackage{graphicx}
\usepackage{lipsum}

\geometry{showframe}
\addpoints

\runningfooter%
    {}
    {}
    {\iflastpage{}{
        \textbf{Question \thequestion }%
        \ifcontinuation{ -- continued}{}\\%
        \oddeven{\mbox{\rlap{\makebox[0.46in][r]{\textbf{TURN OVER}}}}}{}
        }
    }
%MOVE THIS FOOTER TO THE RIGHT BY 0.4in, same for the header, but I've left it out as the header is even longer which lots of if conditions.

\pagestyle{headandfoot}

\begin{document}

    \begin{questions}
    \question \lipsum[1]
        \begin{parts}
        \part[1] \lipsum[2]
        \newpage
        \part[1] \lipsum[3]
        \newpage
        \part[1] \lipsum[4]
        \newpage
        \part[1] \lipsum[5]
        \end{parts}
    \end{questions}

\end{document} 

enter image description here

1
  • wow thanks it worked like a charm! I've turned it into a macro \newcommand{\longhdft}[1]{\mbox{\rlap{\makebox[0.46in][r]{#1}}}} and it's working very well for my headers and footers!
    – Alwin
    Jul 8, 2015 at 9:59

You must log in to answer this question.

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