Graphics, Figures & TablesGraphics File in custom Folder not found

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Yashar
Posts: 3
Joined: Sun Nov 18, 2012 5:48 pm

Graphics File in custom Folder not found

Post by Yashar »

Hi,

I'm using TeXnicCenter editor with MikTeX 2.9. I want to insert a PDF page, that I called "abc.pdf", in my PDF document. I opened a folder and called it "myfiles", this is where all my source files and "abc.pdf" are. The code related to "abc.pdf" is the following:

Code: Select all

\makeatletter
\AddToShipoutPictureBG*{
  \setlength{\@tempdimc}{.06\paperheight}
  \setlength{\unitlength}{1pt}
  \put(\strip@pt\@tempdimb,\strip@pt\@tempdimc){
    \includegraphics{abc.pdf}
  } 
} 
\makeatother
But when I compile the document from Latex to PDF, "abc.pdf" does not appear in my document and I get the error message:

Code: Select all

Package pdftex.def error: file "abc.pdf" not found. 
By the way, I am sure that there is nothing wrong with the code.
Thanks

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

hugovdberg
Posts: 133
Joined: Sat Feb 25, 2012 6:12 pm

Re: Graphics File in custom Folder not found

Post by hugovdberg »

Could you please clarify your directory structure? Is your main tex-file in the same folder as the abc.pdf? From what folder are you calling latex?
Furthermore please provide a compilable minimal working example, this snippet requires packages that are not mentioned in your post.
Ubuntu 13.10 + Tex Live 2013 + Texmaker / Windows 7 Pro + MikTex 2.9 + TexnicCenter / Android 4.3 + TexPortal + DroidEdit
Yashar
Posts: 3
Joined: Sun Nov 18, 2012 5:48 pm

Graphics File in custom Folder not found

Post by Yashar »

Ok, the document is my thesis. All chapters (tex files) of the thesis with the abc.pdf file are in one folder called "myfiles" and this folder is in My Documents. The main tex file is outside of this folder but still in My Documents.
The main tex file looks something like this:

Code: Select all

\documentclass[11pt]{report}
\usepackage{pdfpages} 
\usepackage{anysize,fancyhdr,graphics}
\usepackage{csthesis}
\usepackage{makeidx}  
\usepackage[titletoc]{appendix}

\makeindex  
\makeatletter
\newcommand\otherlist{%
   \if@twocolumn
      \@restonecoltrue\onecolumn
    \else
      \@restonecolfalse
    \fi
    \chapter*{\otherlistname
      \@mkboth{\MakeUppercase\otherlistname}%
              {\MakeUppercase\otherlistname}}%
    \@starttoc{lop}%
    \if@restonecol\twocolumn\fi
    }
\newcommand*\l@program{\@dottedtocline{1}{1.5em}{2.3em}}
\newcounter{program}[chapter]
\renewcommand\theprogram{\thechapter.\@arabic\c@program}
\def\fps@program{tbp}
\def\ftype@program{3}
\def\ext@program{lop}
\def\fnum@program{\programname~\theprogram}
\newenvironment{program}
               {\@float{program}}
               {\end@float}
\newenvironment{program*}
               {\@dblfloat{program}}
               {\end@dblfloat}
\makeatother

\begin{document}
\setlength{\pdfpagewidth}{8.5in}
\setlength{\pdfpageheight}{11in}
\figurespagetrue
\tablespagetrue
\dedicationpagetrue
\quotationpagetrue
\include{myfiles/title} 
\newpage 
\addcontentsline{toc}{chapter}{put whatever you like} 
\mbox{}
\makeatletter
\AddToShipoutPictureBG*{
            \setlength{\@tempdimc}{.06\paperheight}
            \setlength{\unitlength}{1pt}
           \put(\strip@pt\@tempdimb,\strip@pt\@tempdimc){
	\includegraphics{abc.pdf}
	} 
} 
\makeatother
\newpage

\include{myfiles/abs} 
\include{myfiles/ack} 
\lists
\include{myfiles/int} 
\beforetext
\include{myfiles/intro}
\include{myfiles/chap1} 
\include{myfiles/chap2}
\include{myfiles/chap3}
\include{myfiles/chap4}
\include{myfiles/chap5}
\include{myfiles/bib}
\end{document}


I downloaded the pdf page from internet and put it in that folder. So maybe that's not enough.
hugovdberg
Posts: 133
Joined: Sat Feb 25, 2012 6:12 pm

Graphics File in custom Folder not found

Post by hugovdberg »

Have you tried changing the path to myfiles/abc.pdf? As far as I can see it is included from your main file.

When you include the abc.pdf from a file in myfiles you still have to give the path relative to your main file since the content of that file is sort of on-the-fly copy-pasted into the main file.
Another option is the currfile package which allows you to also include files relative to the included file. So if you have three files (main.tex, myfiles/included.tex and myfiles/abc.pdf) you can refer in included.tex to just abc.pdf as long as you use the package currfile.
Ubuntu 13.10 + Tex Live 2013 + Texmaker / Windows 7 Pro + MikTex 2.9 + TexnicCenter / Android 4.3 + TexPortal + DroidEdit
Yashar
Posts: 3
Joined: Sun Nov 18, 2012 5:48 pm

Graphics File in custom Folder not found

Post by Yashar »

Thank you so much, I just changed \includegraphics{abc.pdf} to \includegraphics{myfiles/abc.pdf} and it worked! So simple! Thanks again, you are awesome!
Last edited by cgnieder on Mon Nov 19, 2012 12:52 pm, edited 1 time in total.
Post Reply