1

Suppose i have a complete document containing 100 pages. i want to replace 48th page with another PDF file (just one page). Replacing here means i delete the 48th page and put a new page. That new page is the PDF file that i'm talkng about. I know i can use PDF editor like Adobe Acrobat or anything else, but my point here is what if i need to change my document like revising or adding another page? So, it must be done in the raw document using TeX editor.

Idk if it's necessary, but here's my MWE (it's not 100 pages)

\documentclass[a4paper,12pt,oneside,openany]{book}
\usepackage{pgf, tikz}
\usepackage[a4paper, inner=4cm, outer=3cm, top=4cm, bottom=3cm]{geometry}
\usepackage{geometry}
\usepackage[onehalfspacing]{setspace}
\usepackage{fancyhdr}
\usepackage{titlesec}
\usepackage{setspace}
\usepackage[titles]{tocloft}
\usepackage{tocbibind}
\usepackage{indentfirst}
\usepackage{blindtext}
\usepackage{tocloft}
\usepackage{etoolbox}



\patchcmd{\section}{\bfseries}{\bfseries\boldmath}{}{}
\setlength{\cftbeforesecskip}{10pt}
\setlength{\cftbeforesubsecskip}{10pt}
\fancyhf{}
\cfoot{\thepage}
\linespread{1.5}
\pagestyle{plain}
\renewcommand\cftchapdotsep{\cftdotsep}
\titleformat{\chapter}[block]
{\normalfont\bfseries\centering}
{}{0pt}{}
\titleformat{\section}
{\normalfont\bfseries}
{\thesection}{1em}{}
\titleformat{\subsection}
{\normalfont\bfseries}
{\thesection}{1em}{}
\titlespacing*{\chapter}{0pt}{10pt}{20pt}
\titlespacing*{\section}{0pt}{0pt}{0pt}
\titlespacing*{\subsection}{0pt}{0pt}{0pt}

\renewcommand{\contentsname}{DAFTAR ISI}
\renewcommand{\listtablename}{DAFTAR TABEL}
\renewcommand{\listfigurename}{DAFTAR GAMBAR}

\addtocontents{toc}{\protect\null\protect\hfill{Halaman}\protect\par}
\setlength\parindent{1.25cm} 



\begin{document}
    
    \clearpage
    \thispagestyle{empty}
    \pagenumbering{roman}
    
    \begin{spacing}{0.1}
        \tableofcontents
        \listoffigures
        \listoftables
    \end{spacing}
    \Blinddocument
    
\end{document}
5
  • You've tagged this pdfpages, which is what you should use. Why aren't you using that in your document? (BTW, a MWE doesn't need most of those packages.)
    – Teepeemm
    Apr 9, 2021 at 22:25
  • @Teepeemm that was just a MWE that i copied from my full document and i didn't remove some packages cz i'll need it later. And about the tag, i don't really have an idea about what i should put on. So, i just writing PDF and randomly i chose that. Doesn't really know what it means. Sorry
    – user516076
    Apr 9, 2021 at 22:27
  • You need to copy all the pages but one from one document, and the page to be replaced from the other, creating a new document. Apr 9, 2021 at 22:32
  • @JohnKormylo my teacher is using some kind of plagiarism tool. If i put my whole document here, i'm going to get 100% plagiarized. Sorry but i can't. And about what page i should to change, i've tried to compile my MWE, suppose i want to change page iii. Or maybe just put a newpage and then replacing that page with another PDF file. Thanks.
    – user516076
    Apr 9, 2021 at 22:37
  • 1
    Adding a single page is easy using pdfpages. Replacing a page is plagiarism or possibly forgery. Apr 9, 2021 at 22:44

1 Answer 1

2

You can use the atbegshi package to tap into the shipout routine. At that stage, the page number is accurate, where you can condition on including something from a different document by placing it in the foregrounds of the current page.

enter image description here

\documentclass{book}

\usepackage{blindtext}
\usepackage{graphicx,atbegshi}

\AtBeginShipout{%
  \ifnum\value{page}=20
    \AtBeginShipoutUpperLeftForeground{%
      \raisebox{-\height}{\includegraphics[page=7]{example-image-letter-numbered}}%
    }%
  \fi
}%

\begin{document}
    
\tableofcontents
\listoffigures
\listoftables

\Blinddocument
    
\end{document}
1
  • +1: I hope my edit is ok, if not, then I will undo it. Apr 10, 2021 at 2:03

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.