4

I need to use an absolute path for my package. One of the folder I use contains a space. I cannot change the name of this folder.

So, how can I use paths containing the space character in usepackage ?


EDIT

I tried to put my path between double quotes (") but then, Latex tries to open the "<my path>".sty !!

I am using pdftex (I don't know if this info is relevant).

12
  • 1
    Did you try to use quotes? {"foo/other foo/foo"}
    – Sigur
    Jun 10, 2013 at 14:19
  • You might find your answers here: link
    – papabravo
    Jun 10, 2013 at 14:20
  • Yes I tried, see the edit
    – Colas
    Jun 10, 2013 at 14:23
  • 1
    The argument to usepackage is a package name not a file path. It sometimes half works (but usually gives a warning) if you use a path (whether or not there is a space) but it is always incorrect usage. Jun 10, 2013 at 14:48
  • 1
    @Colas The proper place for local packages in MacTeX is in ~/Library/texmf/ with the proper internal structure. Anything you put there will be found automatically. See How do I add a .sty file to my MacTeX/TeXShop installation? Do you have some reason for not putting local packages there?
    – Alan Munn
    Jun 10, 2013 at 15:05

3 Answers 3

9

The initial statement is false:

I need to use an absolute path for my package.

\usepackage does not take a path at all --- it takes a package name.

Set TEXINPUTS to include the folder in which you have placed mdframed.sty and then just use

\usepackage{myownmackage}

For TeX Live and other web2c based systems you can set TEXINPUTS either as an environment variable or (better) in your texmf.cnf file.

2
  • Isn't this a bad example given that it would make much more sense to use tlmgr to install it?
    – cfr
    Sep 12, 2016 at 23:11
  • @cfr not sure why I used that package name, probably I just had it in another answer at the time. Changed to a non standard name. Sep 13, 2016 at 6:47
5

If you're an expert with the terminal, you can add a symbolic link to the directory with a space in its name:

mkdir -p ~/Library/texmf/tex/latex
ln -s "/path/to/the/folder/with/space in name" ~/Library/texmf/tex/latex/spaceinname

Then simply doing \usepackage{mypackage} will find the file mypackage.sty in the folder with a space in its name. You can use whatever name you prefer instead of spaceinname, so long as it doesn't contain spaces (but it could).

On GNU/Linux systems, the Library/ part should be omitted, it's specific for MacTeX on Mac OS X.

1

For example, if the path is /User/Bob/Google\ Drive/file.sty.

I think the simplest way is:

\usepackage{"/Users/Bob/Google\space Drive/file"}

I am using Latex. And it works.

4
  • 1
    \usepackage only takes a package name. If the package uses \ProvidesPackage, then LaTeX will generate a warning, if the name specified in \ProvidesPackage does not match the name in \usepackage. Sep 12, 2016 at 19:02
  • @HeikoOberdiek But it works for my Latex engine.
    – Alanthink
    Sep 12, 2016 at 22:50
  • As David said above, it may half-work, but it is wrong and liable to break. If you want to use it yourself, fine. If it breaks, you get to keep all the itsy-bitsy teeny-weeny pieces in the funeral urn of your document. But please don't recommend this to others as they may not want funeral urns.
    – cfr
    Sep 12, 2016 at 23:09
  • @cfr Thanks for your advice. I may use David's solution.
    – Alanthink
    Sep 12, 2016 at 23:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .