Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Adding a jpeg in LaTeX automatically adds directory address

  1. Sep 11, 2012 #1
    Hello! When I add a picture in my LaTeX document, the system automatically adds the directory of the file like seen in the attachment. Is there a way to fix it? because I don't need the directory to be seen.
    My code is:

    \begin{center}
    \includegraphics[width=0.50\textwidth]{E:/Game Theory E600/HW6/5.png}
    \end{center}

    I use package graphicx

    Thank you!
     

    Attached Files:

    • 12.png
      12.png
      File size:
      9.8 KB
      Views:
      93
  2. jcsd
  3. Sep 12, 2012 #2
    I would move the picture to the directory, where your latex document is, or at least to its subfolder - in this case you don't even need to write the full path to the picture, only {picture.jpg} or {subfolder/picture.jpg}. It works for sure :)
     
  4. Sep 12, 2012 #3

    AlephZero

    User Avatar
    Science Advisor
    Homework Helper

    The graphicx package does not do what you got by default. If you run it in "draft" mode it will just draw a rectangle the size of the image with the file name inside (to save time). Otherwise it will just display the image, not the fikle name.

    Try replacing
    \usepackage{graphicx}
    with
    \usepackage[final]{graphicx}
    which should make sure some strange option is not switched on when you don't want it.

    If that doesn't work, can you attach a complete (preferably short) LaTeX file that produces this output? My guess is that some other package is redefining what \includegraphics does.
     
  5. Sep 12, 2012 #4
    The picture is located in the same folder where my latex file is.
     
  6. Sep 12, 2012 #5
    Weird things happen with my TeXnicCenter. Now, a table got stuck in between my picture no matter where I place this table within the document.

    Also, the last suggestion did not help. Let me attach the file.
     
  7. Sep 12, 2012 #6
    Here is the latex file and the document.

    % !TEX TS-program = pdflatex
    % !TEX encoding = UTF-8 Unicode

    % This is a simple template for a LaTeX document using the "article" class.
    % See "book", "report", "letter" for other types of document.

    \documentclass[11pt]{article} % use larger type; default would be 10pt

    \usepackage[utf8]{inputenc} % set input encoding (not needed with XeLaTeX)

    %%% Examples of Article customizations
    % These packages are optional, depending whether you want the features they provide.
    % See the LaTeX Companion or other references for full information.

    %%% PAGE DIMENSIONS
    \usepackage{geometry} % to change the page dimensions
    \geometry{a4paper} % or letterpaper (US) or a5paper or....
    % \geometry{margin=2in} % for example, change the margins to 2 inches all round
    % \geometry{landscape} % set up the page for landscape
    % read geometry.pdf for detailed page layout information

    \usepackage[final]{graphicx} % support the \includegraphics command and options

    % \usepackage[parfill]{parskip} % Activate to begin paragraphs with an empty line rather than an indent

    %%% PACKAGES
    \usepackage{booktabs} % for much better looking tables
    \usepackage{array} % for better arrays (eg matrices) in maths
    \usepackage{paralist} % very flexible & customisable lists (eg. enumerate/itemize, etc.)
    \usepackage{verbatim} % adds environment for commenting out blocks of text & for better verbatim
    \usepackage{subfig} % make it possible to include more than one captioned figure/table in a single float
    \usepackage{enumerate}
    \usepackage{amsmath}
    \usepackage{graphicx}

    % These packages are all incorporated in the memoir class to one degree or another...

    %%% HEADERS & FOOTERS
    \usepackage{fancyhdr} % This should be set AFTER setting up the page geometry
    \pagestyle{fancy} % options: empty , plain , fancy
    \renewcommand{\headrulewidth}{0pt} % customise the layout...
    \lhead{}\chead{}\rhead{}
    \lfoot{}\cfoot{\thepage}\rfoot{}

    %%% SECTION TITLE APPEARANCE
    \usepackage{sectsty}
    \allsectionsfont{\sffamily\mdseries\upshape} % (See the fntguide.pdf for font help)
    % (This matches ConTeXt defaults)

    %%% ToC (table of contents) APPEARANCE
    \usepackage[nottoc,notlof,notlot]{tocbibind} % Put the bibliography in the ToC
    \usepackage[titles,subfigure]{tocloft} % Alter the style of the Table of Contents
    \renewcommand{\cftsecfont}{\rmfamily\mdseries\upshape}
    \renewcommand{\cftsecpagefont}{\rmfamily\mdseries\upshape} % No bold!

    %%% END Article customizations

    %%% The "real" document content comes below...

    \title{STAT S516: Homework 2. Due: September 17th, 2012}
    \author{ }
    \date{} % Activate to display a given date or no date (if empty),


    \begin{document}

    \maketitle

    \section*{Problem 1. 2.72}

    For a certain population of employees, the percentage passing or failing a job competency exam,
    listed according to sex, were as shown in the accompanying table. That is, of all the people
    taking the exam, $24\%$ were in the male-pass category, $16\%$ were in the male-fail category, and
    so forth. An employee is to be selected randomly from this population. Let A be the event that
    the employee scores a passing grade on the exam and let M be the event that a male is selected.

    \begin{center}
    \includegraphics[width=0.60\textwidth]{E:/FALL 2012/STAT-S516/HW2/1.png}
    \end{center}


    \begin{center}
    \includegraphics[width=0.80\textwidth]{E:/FALL 2012/STAT-S516/HW2/2.png}
    \end{center}

    \end{document}
     

    Attached Files:

  8. Sep 12, 2012 #7

    AlephZero

    User Avatar
    Science Advisor
    Homework Helper

    The problem is that you have a blank in your file names E:/FALL 2012/etc. If you get rid of that, it should work OK. Blanks in file names are never a good idea, especially if you are using software that isn't specifically written for MS Windows only.

    I've no idea WHY it does what it does. I get a warning saying "file not found" but LaTeX then includes it (plus part of the file name starting after the blank) even though it says it can't find it! This looks like a bug (or at least a "feature") in the graphicx package.
     
  9. Sep 12, 2012 #8
    Thank you a lot!
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Adding a jpeg in LaTeX automatically adds directory address
Loading...