3

In Mac OSX, using latex, I have a long class file that includes various macros containing commands of the sort

\includegraphics[#5]{/Users/myname/Desktop/book/images/#2.eps}

\includemovie[#4]{/Users/myname/Desktop/book/movies/#2.mpg}

I would like to make this portable to computers with different absolute paths. (For compatibility reasons, I need absolute paths.) Probably the simplest would be to define a \imagedirectoryname and a \moviedirectoryname and do something like

\includegraphics[#5]{\imagedirectoryname/#2.eps}

\includemovie[#4]{\moviedirectoryname/#2.eps}

How exactly do I do this in latex? Thank you in advance for any help! It is for a book that is free to download on the internet.

I am using OSX, latex, MacTeX/texlive 2014, and the dvi -> ps -> pdf typesetting method.

P.S. Yes, I know that movie15 is obsolete, but it works, and the successor package media9 is not compatible with it, as far as I understand.

4

You can do one of these:

  1. Update \graphicspath to point towards the folders that may include graphics. It's syntax for paths <pathA>, <pathB>, ... is

    \graphicspath{{<pathA>}{<pathB>}{..}...}
    

    See How to use \graphicspath?

  2. Define a macro to hold the path via something like

    \newcommand{\imagefolder}{/your/image/folder/here}
    

    and then use it in your commands as

    \includegraphics[..]{\imagefolder/<image>}
    
  3. Of course, (2) could also be hard-coded by changing \includegraphics to always use a specific path via something like

    \let\oldincludegraphics\includegraphics
    \renewcommand{\includegraphics}[2][]{\oldincludegraphics[#1]{\imagefolder/#2}
    

    You need to know your use-case/environment to be confident that such hard-coding would work though.

  • Thanks. I'm working on Ubuntu 14.04LTS and TexLive2015 and solutions 2 works -- after 2h of search & try. (-; – alex Nov 30 '15 at 16:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.