I have a headrule which overhangs the text, whereas I would like it to be the same length as the text and aligned with the text. The misalignment seems to come when including a PDF rather than having it as part of the same document. Below are left and right page examples.
The misalignment seems to occur regardless of what margins/paging I set in the included document. I have been looking at this as a fancyhdr problem, and tried to adjust the header with a combination of setting a shorter \headwidth and adding in \fancyheadoffset to shift it all to the right/left, but I cannot figure out the syntax for achieving this. If I use just \headwidth, the rule is shorter but still misaligned. If I add \fancyheadoffset after it, \headwidth is ignored. If I put \headwidth after \fancyheadoffset, it gives a compilation error. My attempts are included with comments in the example.
However, it is also possible that this could be considered a pdfpages problem, and I need to include the PDF differently so that content is not shifted. (NB: In my actual document, the outer file also has content, so margins do need to be set in it.)
This is the minimal example producing the included content (save output as Include.pdf) :
\documentclass[twoside,12pt,openany]{article}
\usepackage{setspace}
\usepackage{lipsum}
\setlength{\oddsidemargin}{1.5cm}
\setlength{\evensidemargin}{0 cm}
\setlength{\topmargin}{1mm}
\setlength{\headheight}{1.36cm}
\setlength{\headsep}{1.00cm}
\setlength{\textheight}{20.84cm}
\setlength{\textwidth}{14.5cm}
\setlength{\marginparsep}{1mm}
\setlength{\marginparwidth}{3cm}
\setlength{\footskip}{2.36cm}
\begin{document}
\doublespacing
\lipsum
\end{document}
And here is the code that uses it to generate the example images above:
\documentclass[twoside,12pt,openany]{book}
\usepackage{pdfpages}
\usepackage{fancyhdr}
\setlength{\oddsidemargin}{1.5cm}
\setlength{\evensidemargin}{0 cm}
\setlength{\topmargin}{1mm}
\setlength{\headheight}{1.36cm}
\setlength{\headsep}{1.00cm}
\setlength{\textheight}{20.84cm}
\setlength{\textwidth}{14.5cm}
\setlength{\marginparsep}{1mm}
\setlength{\marginparwidth}{3cm}
\setlength{\footskip}{2.36cm}
\fancypagestyle{papertwostyle}
{
\fancyhf{}
\renewcommand{\headrulewidth}{1pt}
\fancyhead[RO]{\bfseries{\MakeUppercase{Chapter title}}}
\fancyhead[LE]{\bfseries{Chapter 3}}
\fancyfoot[C]{\thepage}
}
% \renewcommand{\headwidth}{3in}
% \fancyheadoffset[ORH]{-2.1em}
% \fancyheadoffset[ELH]{-2.1em}
\begin{document}
\pagestyle{papertwostyle}
\includepdf[pages={1-3}, pagecommand={}]{Include}
\end{document}


pdfpages. Thank you for identifying the issue, and providing a work-around. I still need to try to fix the margins so that the header isn't overwriting the text, but at least now it is correctly aligned. – Ann Apr 06 '19 at 15:45geometrypackage; you've never used it before? – frougon Apr 06 '19 at 16:10