3

I'm (still) moving from regular LaTeX classes (report, article) to Koma-Script. Lots of things are just okay, but not everything.

My current problem lies with PDF inclusion and header/footer change for the included PDF pages.

In a lot of documents, I have to include PDF docs here and there. To make reading easier, I want to modify the footer or headers to add some data about the included PDF doc.

With report and article classes, fancyheaders and pagecommand, it is really easy :

\includepdf[addtotoc={1, section, 1, For the ToC, reference},
fitpaper=false,pages=-,frame,scale=0.7,
pagecommand={\thispagestyle{fancy}
             \fancyfoot[RE,LO]{\footnotesize\textbf{Some Footer}}}]{ThePDF}

No such luck when using scrheadings. I utterly fails to change the footer (or headers) for the included PDF pages.

Here is a minimal (not) working example :

\documentclass[headheight=1.2cm,headsepline]{scrartcl}
\usepackage[bottom=2.8cm,footskip=18mm]{geometry}

\usepackage[headsepline]{scrpage2}
\usepackage{lipsum}
\usepackage{pdfpages}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[frenchb]{babel}

\pagestyle{scrheadings}

\chead[]{Center header}
\ihead[]{Inside header}
\ohead[]{Outside header}

\cfoot[]{Center footer -- \thepage{} --}
\ifoot[]{Inside footer}
\ofoot[]{Outside footer}

\begin{document}

\title{That is some title}
\author{Author name}
\date{Someday}

\maketitle
\tableofcontents

\section{Blah}
\lipsum[3-5]

\includepdf[addtotoc={1, subsection, 1, Included PDF,tag},
    turn=false,frame,scale=0.8,pages=1,
    pagecommand={\thispagestyle{scrheadings}
                 \ofoot{Another outside footer}
                 \ifoot{Another inside footer}
                 \chead{And a center header}}]{SomePDF}

\lipsum[3-5]
\end{document}

Any idea about what I'm doing wrong, or how to reach this goal ?

2 Answers2

6

To reach your goal change the call of macro \includepdf in your MWE to:

{% Start group to have changes locally
\ofoot{Another outside footer}
\ifoot{Another inside footer}
\chead{And a center header}
\includepdf[%
  addtotoc={1, subsection, 1, Included PDF,tag},
  turn=false,frame,scale=0.8,pages=1-3,
  pagecommand={\thispagestyle{scrheadings}}
]{SomeFile.pdf}
}% Ends group, old footer and header are active ...

Now you get your new header and footer ...

Mensch
  • 65,388
2

You can define a new pagestyle, which gives greater flexibility.

\documentclass[headheight=1.2cm,headsepline,twoside]{scrartcl}
\usepackage[bottom=2.8cm,footskip=18mm]{geometry}

\usepackage[headsepline]{scrpage2}
\usepackage{lipsum}
\usepackage{pdfpages}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[frenchb]{babel}

\pagestyle{scrheadings}
\chead[]{Center header}
\ihead[]{Inside header}
\ohead[]{Outside header}
\cfoot[]{Center footer -- \thepage{} --}
\ifoot[]{Inside footer}
\ofoot[]{Outside footer}

% Easy interface
%\deftripstyle{pdfincl}
%  {}
%  {And a center header}
%  {}
%  {Another inside footer}
%  {}
%  {Another outside footer}

% Expert interface
\newpagestyle{pdfincl}
 {% HEADER
  (0pt,0pt)% no above rule
  {% header, even pages
   \hfil And a center header\hfil
  }
  {% header, odd pages
   \hfil And a center header\hfil
  }
  {% header, single side
   \hfil And a center header\hfil
  }
  (\textwidth,0.4pt)% rule below header
 }
 {% FOOTER
  (0pt,0pt)% no separation rule
  {% footer, even pages
   Another outside footer\hfil Another inside footer
  }
  {% footer, odd pages
   Another inside footer\hfil Another outside footer
  }
  {% footer, single side
   Another inside footer\hfil Another outside footer
  }
  (0pt,0pt)% no rule below footer
 }

\begin{document}

\title{That is some title}
\author{Author name}
\date{Someday}

\maketitle
\tableofcontents

\section{Blah}
\lipsum[3-5]

\includepdf[addtotoc={1, subsection, 1, Included PDF,tag},
    turn=false,frame,scale=0.8,pages=-,
    pagecommand={\thispagestyle{pdfincl}}]{chineheadincl}

\lipsum[3-5]
\end{document}

The easy interface does not allow for rules. Of course you're not required to fill all the fields, if you know that your document is one sided.

egreg
  • 1,121,712