4

I'm inserting an pdf file for a section with the command \includepdf[scale=0.9,pagecommand=\section*{\begin{center} ANEXO \end{center}}]{Oficio5S.pdf}, so the pdf is inserted in the page of the APPENDIX and not in a new page.

But, the title "APPENDIX" it's below from where it should be (fitting the top margin). So, how can I fix this?

Another issue, what can I do to insert the pdf file with a size that fits the document margins, but the pdf file included must stays above the title of the section?

Image:

title of the section way below from top margin

Code:

  \documentclass[12pt,a4paper]{article}
  \pagestyle{myheadings}
  \usepackage[utf8]{inputenc}
  \usepackage[brazilian]{babel}
  \usepackage[T1]{fontenc} %code
  \usepackage{uarial} % for
  \renewcommand{\familydefault}{\sfdefault} %arial font
  \usepackage{pdfpages}
  \usepackage[top=2cm,left=2cm,right=2cm,bottom=2cm]{geometry}
  \usepackage{titlesec}
  \titleformat*{\section}{\normalsize\bfseries}
  \begin{document}
  \includepdf[scale=0.9,pagecommand=\section*{\begin{center}
        APPENDIX    \end{center}}]{Oficio5S.pdf}
    \newpage
   textetxttextetxttextetxttextetxttextetxt                     textetxttextetxttextetxttextetxttextetxt    textetxttextetxttextetxttextetxttextetxt    textetxttextetxttextetxttextetxttextetxt    textetxttextetxttextetxttextetxttextetxt    textetxttextetxttextetxttextetxttextetxt    textetxttextetxttextetxttextetxttextetxt    textetxttextetxttextetxttextetxttextetxt    textetxttextetxttextetxttextetxttextetxt    textetxttextetxttextetxttextetxttextetxt    textetxttextetxttextetxttextetxttextetxt    textetxttextetxttextetxttextetxttextetxt    textetxttextetxttextetxttextetxttextetxt    textetxttextetxttextetxttextetxttextetxt    textetxttextetxttextetxttextetxttextetxt    textetxttextetxttextetxttextetxttextetxt    textetxttextetxttextetxttextetxttextetxt    textetxttextetxttextetxttextetxttextetxt    textetxttextetxttextetxttextetxttextetxt
        \end{document}

There's a page with text for the sake of margin comparation.

2
  • I think it's better to use \includegraphics[trim=<....>, clip=true,page=<...>]{file}
    – touhami
    May 1, 2016 at 7:57
  • You can use a \vspace to move the title up: ` \includepdf[scale=0.9,pagecommand=\vspace*{-2cm}\section*{\centering APPENDIX}]{example-image}` May 1, 2016 at 9:39

1 Answer 1

4

It's wrong to use center to begin with.

In the following example I used the PDF for another answer; in the second page I added the same heading, in order to see that they're typeset in the same way.

\documentclass[12pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[brazilian]{babel}

\usepackage[top=2cm,left=2cm,right=2cm,bottom=2cm]{geometry}
\usepackage{titlesec}
\usepackage{pdfpages}

\usepackage{lipsum} % just for this example

\titleformat*{\section}{\normalsize\bfseries}
\pagestyle{myheadings}

\begin{document}
\includepdf[
  scale=0.9,
  pages=1-1,
  pagecommand=\section*{\centering APPENDIX},
]{sonia.pdf}

\section*{\centering APPENDIX}
\lipsum

\end{document}

enter image description here

2
  • thank you for your post, but I have a new question... Since is related to this topic, I think I can answer here. Do you know a way to write some text beetwen the section "appendix" and the pdf included? May 1, 2016 at 19:36
  • @gustavoreche Just add it after \section*{\centering APPENDIX}
    – egreg
    May 1, 2016 at 19:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .