Graphics, Figures & Tables ⇒ Suppress Name and Path of included Graphics File
-
- Posts: 5
- Joined: Sun Nov 09, 2008 11:27 am
Suppress Name and Path of included Graphics File
Thank You All
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
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Re: Suppress Name and Path of included Graphics File
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Suppress Name and Path of included Graphics File
\includegraphics hides the picture and shows only the file name if and only if the draft option is on (either as class option or as package option for the graphics/graphicx package). There is no case where both the picture and the file name are shown. Please provide a minimal working example that exhibits this error.siavash.babaei wrote:How can I suppress the filename and path of a file, when using the \includegraphics command, from being displayed in the output. We I insert a figure, it shows the full path for that figure and makes the figure look very odd.
Suppress Name and Path of included Graphics File
The boldface part is not quite true. As localghost mentioned, leaving blank spaces in the path and/or in the figure name will produce that odd behaviour. A minimal example:phi wrote:...There is no case where both the picture and the file name are shown. Please provide a minimal working example that exhibits this error.
Code: Select all
\documentclass{article}\usepackage{graphicx}\begin{document}\includegraphics{fibo 1.png}\end{document}
- Attachments
-
- fibo 1.png (16.06 KiB) Viewed 10747 times
-
- Posts: 5
- Joined: Sun Nov 09, 2008 11:27 am
Re: Suppress Name and Path of included Graphics File
So, generally speaking, I have to rename the files (no spaces and special characters), and then move them to a directory so that there are no spaces and special characters in the path. Well, I hope they get to fix this in the future. Not that it is too much to do, but a nice piece of work like TeX should have such problems.
Cheers
Suppress Name and Path of included Graphics File
@siavash.babaei: You can use spaces in file names if you surround them by quotation marks. But for \includegraphics, you have to put them in front of the extension, otherwise the extension is not recognized. Like this:
Code: Select all
\includegraphics{"fibo 1".png}
For "special" (non-ASCII) characters, you have to go one step further. These characters are somtimes active (for example when you use the UTF-8 encoding) and get expanded while trying to find the file. You have to convert them to inactive characters:
Code: Select all
\includegraphics{\detokenize{"fibo áéó 1".png}}
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Suppress Name and Path of included Graphics File
Before doing this, try the grffile package from the oberdiek bundle. It allows at least blank spaces. For the future you may put your graphics files into a subdirectory of your project with a simple name (like gfx) and give them simple names, too.siavash.babaei wrote:[...] So, generally speaking, I have to rename the files (no spaces and special characters), and then move them to a directory so that there are no spaces and special characters in the path. Well, I hope they get to fix this in the future. Not that it is too much to do, but a nice piece of work like TeX should have such problems. [...]
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Suppress Name and Path of included Graphics File
Thank you so much for your reply!
It was indeed helpful!
@siavash.babaei
Thank you for posting this query
- Ijon Tichy
- Posts: 640
- Joined: Mon Dec 24, 2018 10:12 am
Suppress Name and Path of included Graphics File
Just a note: With up-to-date LaTeX the package is not needed any more and by default does nothing. See section 2.1 of the manual.
