2

I want to include a document into another one. The document, which should be included, exists as pdf and tex file. The document which I want to include is about 30 pages. I want to include the document in the manner described below.

The included document should have a border around. Furthermore around the text of the sub document is a lot of white space due to the documentclass article. This white can be deleted. So that the text begins near the border(see screenshot). Because the sub document has a lot of graphics and tikz drawings it isn't that simple just making the size/format of the document smaller. Because this would have an effect on the graphics which would be too small.

desired outcome

An short extract of the header of my Main Document:

\documentclass[paper=A4,abstracton,twoside,openright,11pt,headsepline,BCOR=1cm,DIV=10,utf8]{scrreprt}
\begin{document}

\appendix
    %here should be my included document

\end{document}

An example of my Sub Document:

\documentclass[11pt]{article}
\usepackage{geometry}
%i have done this, to clip the white space around
\geometry{a4paper, top=10mm, left=10mm, right=10mm, bottom=10mm,headsep=10mm, footskip=5mm}
%...
\begin{document}
example text example text example text example text example text example text  example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text 
\end{document}
d4rty
  • 779
  • 1
    \\includegraphics[]{} or \includepdf[]{} from graphicx or pdfpages. Both offer cropping and you can add frames as you wish. pdfpages provides an option for this, I think. – cfr Nov 20 '15 at 14:12
  • 1
    http://tex.stackexchange.com/questions/89792/change-document-class-per-page, http://tex.stackexchange.com/questions/200169/the-frame-of-a-framebox-disappears-in-pdfpages. – cfr Nov 20 '15 at 14:18
  • I included my pdf with \includepdf[pages={1-},frame,scale=0.8]{sub/subdocument.pdf}. I deleted the white space around the subdocument with the geometry package. But the pagenumber from the main document (see screenshot above) is still missing. How can i achieve this? – d4rty Nov 20 '15 at 14:52
  • Also the \includepdf.. gives me not the option to customize the border/frame. Is there a better solution? – d4rty Nov 20 '15 at 14:59
  • Please edit your question to include a minimal working example (MWE). That makes it much easier to anyone who would like to help you to determine what happened to the page number. – jarauh Nov 20 '15 at 15:44
  • If you want to draw a border, you can try \fbox around \includepdf. – jarauh Nov 20 '15 at 15:45
  • I just revised the question by providing a MWE – d4rty Nov 20 '15 at 15:49
  • you can recompile your sub-file with \usepackage[paperwidth=\textwidth,paperheight=\dimexpr\textheight+\footskip\relax,text={\textwidth,\textheight},top=0pt]{geometry} – touhami Nov 20 '15 at 15:56
  • If you want a fancy frame, add it in the sub file. Or use \includegraphics, for example. Or see the second of the links I posted in my earlier comment. For the page numbers, see the first link I posted in my earlier comment. Did you even look at those links? I thought you didn't want to scale it. – cfr Nov 20 '15 at 16:59
  • @jarauh You can try, but it won't work. See the second link in my earlier comment which addresses this issue. – cfr Nov 20 '15 at 17:01
  • @cfr actually \includegraphics wont work. It will print all sites from the pdf on top od each other on one site. – d4rty Nov 20 '15 at 18:21
  • Maybe it is better to include the tex file appropriately and directly and don't create a pdf file first. – d4rty Nov 20 '15 at 18:24
  • Did you try the method in the second link? Your example document does not include more than one page, so it isn't clear from that about \includegraphics{}. In any case, you could do it that way if you burst the PDF. But, personally, I would think it worth at least taking a look at the link if I were doing this. You know, just in case it might be of use. – cfr Nov 23 '15 at 01:23
  • The frame bit is just a duplicate of that question. The page numbers bit is a duplicate of one of the other questions linked from here. The cropping is just compiling the file with no margins or using an option to \includepdf{}. There are multiple ways to do this. You just have to pick your poison. If just including the .tex file is an option, why don't you do that? What's the problem? We have no idea. – cfr Nov 23 '15 at 01:26
  • Can maybe someone just taking the example from my question and produce my desired output. – d4rty Nov 23 '15 at 10:53
  • can you please say what happen if you compile as in my first comment? – touhami Nov 24 '15 at 07:34

3 Answers3

1

In case someone wants a pure TikZ framework, here is it.
(notice that even clipping is done in TikZ.)

\documentclass{scrreprt}
\usepackage{tikz}
\usetikzlibrary{calc,spy}
\begin{document}

\appendix
\chapter{Special Package}

\pgfdeclarelayer{back}
\pgfdeclarelayer{fore}
\pgfsetlayers{back,main,fore}
\tikzset{
    on layer/.code={\pgfonlayer{#1}\begingroup\aftergroup\endpgfonlayer\aftergroup\endgroup}
}
\clearpage
\tikz[remember picture,overlay]{
    \scoped\clip[rounded corners=20,postaction={on layer=fore,line width=10,draw}]($(current page.south west)+(2,7)$)rectangle($(current page.north east)+(-2,-7)$)(current page)node{\includegraphics[page=1]{tikz-3dplot_documentation}};
    \draw[<-,red,line width=2,bend right](current page)++(4,2)to++(2,10)node[above]{\Huge Notice This};
}
\clearpage
\tikz[remember picture,overlay,spy using outlines={circle,magnification=4,size=4cm,connect spies}]{
    \scoped\clip[rounded corners=20,postaction={on layer=fore,line width=10,draw}]($(current page.south west)+(2,7)$)rectangle($(current page.north east)+(-2,-7)$)(current page)node{\includegraphics[page=2]{tikz-3dplot_documentation}};
    \spy[red]on(5,-15)in node at(4,-23);
}
\clearpage
\tikz[remember picture,overlay]{
    \scoped\clip[rounded corners=20,postaction={on layer=fore,line width=10,draw}]($(current page.south west)+(2,7)$)rectangle($(current page.north east)+(-2,-7)$)(current page)node{\includegraphics[page=3]{tikz-3dplot_documentation}};
    \fill($(current page)+(-6,-2.3)$)rectangle node[white]{\Huge Censored}($(current page)+(6,-.6)$);
}
\clearpage
\tikz[remember picture,overlay]
{
    \scoped\clip[rounded corners=20,postaction={on layer=fore,line width=10,draw}]($(current page.south west)+(2,7)$)rectangle($(current page.north east)+(-2,-7)$)(current page)node{\includegraphics[page=4]{tikz-3dplot_documentation}};
    \fill[on layer=back,yellow]($(current page)+(-6.1,.8)$)rectangle($(current page)+(6,-1.7)$)node[below left,olive]{\Huge Important};
}
\clearpage
\tikz[remember picture,overlay]
{
    \clip[draw](current page)circle(5);
    \scoped\clip[rounded corners=20,postaction={on layer=fore,line width=10,draw}]($(current page.south west)+(2,7)$)rectangle($(current page.north east)+(-2,-7)$)(current page)node{\includegraphics[page=5]{tikz-3dplot_documentation}};
}
\clearpage
\tikz[remember picture,overlay]
{
    \scoped\clip[rounded corners=20,postaction={on layer=fore,line width=10,draw}]($(current page.south west)+(2,7)$)rectangle($(current page.north east)+(-2,-7)$)(current page)node{};
}
\vfill
\Huge\it This page is intentionally left blank.

\end{document}

Symbol 1
  • 36,855
1

One of OP's comments says

I included my pdf with \includepdf[pages={1-},frame,scale=0.8]{sub/subdocument.pdf}. I deleted the white space around the subdocument with the geometry package. But the pagenumber from the main document (see screenshot above) is still missing. How can i achieve this?

The problem with main document page numbers is due to pdfpage's option pagecommand which by default is pagecommand={\thispagestyle{empty}}.

Forcing a new pagecommand will solve the problem:

\documentclass[paper=A4,abstracton,twoside,openright,11pt,headsepline,BCOR=1cm,DIV=10,utf8]{scrreprt}
\usepackage{pdfpages}
\begin{document}

\appendix
    %here should be my included document
    \includepdf[pages={1-},frame,scale=0.8, 
          pagecommand={}]%  <---------- doesn't change `pagestyle`
          {arsclassica/ArsClassica.pdf}
\end{document}

enter image description here

Ignasi
  • 136,588
0

The document you want to include is not two-sided. Therefore, you could perform the same per-page clip to trim off the excess whitespace (margins), and include each page using a straight-forward \includegraphics:

\documentclass{article}
\usepackage{multido,graphicx,lipsum}
\begin{document}

\section{Introduction}
\lipsum[1-10]

\section{Appendix}

% https://tex.stackexchange.com/q/198091/5764
\pdfximage{lipsum50.pdf}% Contains 50 pages of \lipsum text
\multido{\i=1+1}{\the\pdflastximagepages}{%
  \fbox{\includegraphics[scale=.5,page=\i,viewport=50 40 565 750,clip]{lipsum50}}%
  \clearpage}

\end{document}

The principle of this solution is to count the number of pages in the document to be included, and then iterate over each page using a framed \includegraphics. The viewport is set to only include the relevant part of each page, clipping the margins. You may have to play with the viewport values (they're in bp).

Werner
  • 603,163