1

I have read the following posts on this site: How to avoid showing the filename when using graphicx? and Include figure from PDF file, but havent had any luck following the answers posted in the questions.

I am using \includegraphics to bring in figures and the file locations for the figures are showing up with the figures when I compile the PDF.

A working example:

 \documentclass[12pt]{article}

%preamble - set document settings

%package for loading images
\usepackage{graphicx}

%package needed for setting graphicspath with spaces in directory name
\usepackage[space]{grffile} 

\begin{document}

\includegraphics[width=0.5\linewidth]{{S:/Adv/Scallop Central/Logos/fullcolorlogo}.png}

\end{document}

I have also tried the following:

\includegraphics[width=0.5\linewidth]{{"S:/Adv/Scallop Central/Logos/fullcolorlogo"}.png}


\includegraphics[width=0.5\linewidth]{"S:/Adv/Scallop Central/Logos/fullcolorlogo".png}

but the PDF did not compile. There was a warning that the image couldn't loaded because it is not a recognized file format.

When I do get the image in the PDF it looks like:

enter image description here

Any help would be appreciated .

Martin Scharrer
  • 262,582
user41509
  • 165
  • Did you try {"S:/Adv/Scallop Central/Logos/fullcolorlogo.png"}? – Sigur Feb 12 '19 at 19:56
  • Why is the .png outside? I've never seen anyone do that "...." Ln the entire file name should be enough. Best if course is to never use spaces in folder or file names – daleif Feb 12 '19 at 19:57
  • The answer below is why - it is from one of the two other answers above \usepackage{graphicx}

    \begin{document} \begin{figure} \includegraphics{{"../Current folder/1.This file"}.png} \end{figure} \end{document}

    – user41509 Feb 12 '19 at 20:01
  • Yes I did try {"S:/Adv/Scallop Central/Logos/fullcolorlogo.png"} and got the same error message. – user41509 Feb 12 '19 at 20:05
  • Another answer has this: \includegraphics{{example2.2}.png} - which also didnt work. – user41509 Feb 12 '19 at 20:09
  • 1
    with pdflatex \includegraphics[width=0.5\linewidth]{"S:/Adv/Scallop Central/Logos/fullcolorlogo".png} should work (although not having spaces is better and not having the full path makes the document more portable) so \includegraphics[width=0.5\linewidth]{fullcolorlogo} would be best. If you are using latex+dvips then it can not include png files. This form should work just with graphicx, you don't need grffile – David Carlisle Feb 12 '19 at 20:52
  • I just tried your code and got the following: File "S:/Adv/Scallop Central/Logos/fullcolorlog".png not found. The file directory is a long standing directory used by many and cant be changed. – user41509 Feb 12 '19 at 21:16
  • Put \usepackage{grffile} before ...graphicx. I'm not sure that this is necessary here, but my advice stems from using the pdfpages package. If pdfpages is loaded before grffile, grffile doesn't work. – Keks Dose Feb 13 '19 at 08:37
  • I have tried all suggestions and even renamed my directory to exclude spaces. The only way I can get the image to show up is with this \includegraphics[width=0.5\linewidth]{S:/Adv/Scallop Central/Logos/fullcolorlogo.png} and the file directory still shows up. At this point its easy to make a word document. – user41509 Feb 13 '19 at 14:03

1 Answers1

1

Did you tried with no " and {} like below?

\includegraphics[width=0.5\linewidth]{S:/Adv/Scallop Central/Logos/fullcolorlogo.png}

I have tried with below code and it worked, but it does not worked when quotation marks are included.

UPDATE

I got similar result as above answer with XeLaTeX. The filename disappeared when I compiled with pdfLaTeX.

\documentclass{article}

\usepackage{graphicx} \usepackage[space]{grffile}

\title{test} \author{tester}

\begin{document} \maketitle

test

\includegraphics[width=0.5\textwidth]{/Users/j/Desktop/Screen Shot 2019-01-30 at 11.40.38.png}

\end{document}

enter image description here

z0nam
  • 115