General ⇒ Chapters and Importing PDFs
Chapters and Importing PDFs
Hello again, I've now run into 2 problems, I want to prevent a chapter from showing, but still appear on the table of contents (report where I placed the chapter).
My second problem is trying to import pages from a data sheet. I'd like latex to place a page from a PDF into the document, without applying any formatting or shrinking it to the boarders, whilst still counting as a page so that the table of contents and page numbering is correct for pages that follow.
My second problem is trying to import pages from a data sheet. I'd like latex to place a page from a PDF into the document, without applying any formatting or shrinking it to the boarders, whilst still counting as a page so that the table of contents and page numbering is correct for pages that follow.
NEW: TikZ book now 40% off at Amazon.com for a short time.
- Stefan Kottwitz
- Site Admin
- Posts: 10321
- Joined: Mon Mar 10, 2008 9:44 pm
Chapters and Importing PDFs
Hi Lysit,
first you can use \addcontentsline:
For the second problem you could use the pdfpages package, that's designed for inserting pages of external pdf documents.
Stefan
first you can use \addcontentsline:
Code: Select all
\addcontentsline{toc}{chapter}{chapter title}
Stefan
Re: Chapters and Importing PDFs
I would suggest to write every chapter in a separate file, named, for example, ch1.tex, ch2.tex and so on. Through commands of the form \include{ch1}, \include{ch2}, etc. you include them in the document. Generate a full document, with all the chapters and a table of contents. Then, to get a restricted document with only, say, chapters 1, 3 and 5 (so excluding chaps. 2, 4...), add to the preamble the command \includeonly{ch1,ch3,ch5}. The table of contents, numbering of chapters, sections, equations, etc. will not be affected.
If, for some reason, the pdfpages package fails, you can still include a specific page of a PDF document through the well known \includegraphics command: write something like \includegraphics[page=n]{file.pdf}, where n is the page number you want. I frequently follow this approach, for example, to include pages of a A5 document in an A4 one. Of course, you can use the remanining parameters of \includegraphics to fine tune of the page inclusion.
If, for some reason, the pdfpages package fails, you can still include a specific page of a PDF document through the well known \includegraphics command: write something like \includegraphics[page=n]{file.pdf}, where n is the page number you want. I frequently follow this approach, for example, to include pages of a A5 document in an A4 one. Of course, you can use the remanining parameters of \includegraphics to fine tune of the page inclusion.
Re: Chapters and Importing PDFs
Having problems with both methods of inserting pdfs, \includepdf leaves blank pages in place of the acual PDF and \includegraphics complain s about th lack of bounding box (I did attempt a conversion to EPS to include it, it worked but shrunk to the page margins).
Re: Chapters and Importing PDFs
In order to be able to provide more help, I find necessary to have some code (the exact preamble of your document), a copy of a PDF file and a list of the pages you want to include, and a precise specification on how the pages should be included.
Chapters and Importing PDFs
Main latex file
app2.tex
Can't put the PDF here due to privacy concerns
Code: Select all
\documentclass[a4paper,12pt]{report}
\usepackage{fullpage} %Forces 1 inch boarders
\usepackage{graphicx,amssymb,amstext,amsmath}
\usepackage{sectsty}
\usepackage{txfonts}
\usepackage{setspace} %see \doublespacing
\usepackage{float} %sub floats
\usepackage{fancyhdr}%Custom headers
\usepackage{listings} %fr ansi c
\usepackage{url} %wrap URLS
\usepackage{appendix}
\usepackage{tocbibind}
\usepackage{pdfpages} %Allows direct insertion of PDFs
%
%-------------------- start of the 'preamble'
%
%
%% homebrew commands -- to save typing
\newcommand\etc{\textsl{etc}}
\newcommand\eg{\textsl{eg.}\ }
\newcommand\etal{\textsl{et al.}}
\newcommand\Quote[1]{\lq\textsl{#1}\r
q}
\newcommand\fr[2]{{\textstyle\frac{#1}{#2}}}
\newcommand\miktex{\textsl{MikTeX}}
\newcommand\comp{\textsl{The Companion}}
\newcommand\nss{\textsl{Not so Short}}
%
%--------------------- end of the 'preamble'
%
\begin{document}
%-----------------------------------------------------------
\title{XXX}
\author{XXX}
\maketitle
%-----------------------------------------------------------
\begin{abstract}\centering
Something here soon \texttrademark .
\end{abstract}
%-----------------------------------------------------------
\tableofcontents
\listoftables
\listoffigures
%-----------------------------------------------------------
\doublespacing %Forces double space with above package
\setcounter{secnumdepth}{5} %allows for more numbered subsections
\renewcommand{\chaptername}{} %Remove word Chapter from chapters
\pagestyle{fancy}
\rhead{} %Remove undesired header elements
\renewcommand{\headrulewidth}{0.5pt}
\makeatletter
\renewcommand*\@makechapterhead[1]{%
{\parindent \z@ \raggedright \normalfont
\huge\bfseries
\ifnum \c@secnumdepth >\m@ne
\thechapter . \space
\fi
#1\par\nobreak
\vskip 20\p@
}}
\makeatother
\renewcommand{\chaptermark}[1]{%
\markboth{\thechapter.\ #1}{}}
\headsep = 25pt
\include{chap1}
\include{chap2}
\include{chap3}
\include{chap4}
%-----------------------------------------------------------
\singlespacing %Forces single space with above package
\bibliographystyle{biostyle}
\bibliography{bibdatabase}
%-----------------------------------------------------------
\appendix
\include{app4}
\include{app1}
\include{app2}
\include{app3}
%-----------------------------------------------------------
\end{document}
Code: Select all
%\chapter{Statement of Work}
\addcontentsline{toc}{chapter}{Statement of Work}
\includepdf[pages=1-2]{sow2.pdf}
%\includegraphics[page=1]{sow2.pdf}
- Stefan Kottwitz
- Site Admin
- Posts: 10321
- Joined: Mon Mar 10, 2008 9:44 pm
Chapters and Importing PDFs
Hi Lysit,
do you use latex or pdflatex? If you can include eps files, then it's latex, but that cannot include pdf files. For that you should use pdflatex, that means compiling directly to pdf instead of going the way over dvi and ps.
If that's not clear for you, look at the first line in your .log file: there you should read format=pdflatex, not format=latex.
Stefan
do you use latex or pdflatex? If you can include eps files, then it's latex, but that cannot include pdf files. For that you should use pdflatex, that means compiling directly to pdf instead of going the way over dvi and ps.
If that's not clear for you, look at the first line in your .log file: there you should read format=pdflatex, not format=latex.
Stefan
Re: Chapters and Importing PDFs
Yes I use EPS files (and Dvi->PS method). In that case how would I insert full page EPS graphics?I can covert these PDS to EPS files (Though quite large ones).
- Stefan Kottwitz
- Site Admin
- Posts: 10321
- Joined: Mon Mar 10, 2008 9:44 pm
Re: Chapters and Importing PDFs
Hi Lysit,
I recommend to convert those eps files to pdf format using eps2pdf or epstopdf. Then you can include them as pdf files using pdflatex.
Stefan
I recommend to convert those eps files to pdf format using eps2pdf or epstopdf. Then you can include them as pdf files using pdflatex.
Stefan
Re: Chapters and Importing PDFs
Seems to have corrected the problem, thanks.