My scenario consists of some sections and subsections. A slice of the aforementioned group has been presented, as below:




\includepdf[trim=0 0 0 -7cm,pages=1,pagecommand=\subsection{child}]{"D:/A/A_"}
\includepdf[trim=0 0 0 -3cm, pages=2-,pagecommand={}]{"D:/A/A_"}

Each section acts just as an empty parent container for its child subsection. So, one might infer that the subsection must be placed right after its corresponding section heading. But the result after compilation would be:

% page break does occur here

I have not modified the default section nor subsection, nor any other command in this file.

  • I have just tried a solution using the samepage environment, but that did lead to nothing promising.

  • Using \nobreak & \nopagebreak commands did not help, too.

  • Plus useless utilization of \let\clearpage\relax.

Would you please help me to handle this case?

  • if you use pagecommand=\subsection{child} the subsection heading will be in the included page so new page after \section. – touhami Jan 25 '16 at 19:25
  • @touhami: So, what kind of modification should I apply to resolve that new page?! – Roboticist Jan 25 '16 at 19:28

I created the following 10-page lipsum:

enter image description here

  \bfseries This is \verb|lipsum[1-50]|

This is how I would include it in the way you may be after (which avoids a page-break:

enter image description here


  \includegraphics[page=1,trim=0 0 0 9cm,clip]{lipsum50}%


The main approach is to include the first page using \includegraphics[page=1,...]{<file>} from graphicx (loaded by pdfpages).

Some adjustments need to made to ensure proper loading:

  • We trim (and clip) the first page so only the relevant content is included. Based on your example, it seems like you have some blank space at the top of the first page.

  • The included first page is "raised" into position with a 0pt height and depth so it doesn't affect any overflow (vertically).

  • Subsequent pages are included in the usual way using \includepdf, with an accompanying \thispagestyle that matches the rest of your document.

Note that the above relies on the fact that your text block is centred on the page. Additional adjustments are required if this is not the case.

| improve this answer | |
  • Amazing solution... You precisely hit the mark... Thanks in advance – Roboticist Jan 25 '16 at 19:51

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.