Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable absolute paths in LaTeX

Tags:

latex

I have one document under ~/my_files/test.tex and want to include in test.tex some styling informations, which can be found under ~/latex/styles/info_hypersetup.tex.

When I include the following statement into my test.tex:

%% setting the infos for the pdf
\include{home/helex/latex/styles/info_hypersetup.tex}

I get the following error when running pdflatex test.test:

! I can't write on file `~/latex/styles/info_hypersetup.tex.aux'.

I set the rights to 777 but this doesn't changed anything. It works, if I put info_hypersetup.tex in the directory-structure where test.tex is. But I want to use this styleinformation as a global setting for all my documents and don't want to copy it into every project.

Thanks for your help.

like image 825
Matthias Guenther Avatar asked May 21 '10 19:05

Matthias Guenther


People also ask

How do you specify an absolute path?

An absolute path is defined as the specifying the location of a file or directory from the root directory(/). In other words we can say absolute path is a complete path from start of actual filesystem from / directory.

Does absolute path always start?

Absolute path names always begin with the slash (/) symbol. Traces the path from the current directory through its parent or its subdirectories and files. An absolute path name represents the complete name of a directory or file from the /(root) directory downward.

Why do we use absolute paths?

An absolute path makes no assumptions about your current location in relation to the location of the file or directory it's describing. An absolute path always begins from the absolute start of your hard drive and describes every step you must take through the filesystem to end up at the target location.


2 Answers

~ is not a path in Unix, rather it is a path that Unix shells expand to the value of $HOME.

You've got a few possible ways to solve your problem:

  1. Define a macro \homedir whose value is coded in your Latex file to be the absolute path to your home (i.e., the contents of $HOME). Nonportable: if you move your file to another machine, it probably won't work.
  2. Use relative paths: this is what your solution does. If you move subhierarchies of files about, and are careful that that are self-contained, this works well.
  3. Create your own style file, say thisfilesystem.sty, with hardcoded values for various directories. You can then just change the values of this from machine to machine. This can also be created automatically from a Makefile.
  4. Use \write18 to run echo $HOME and bind this to you \homedir macro. It's portable, but I don't advise it: you should get into the habit of avoiding \write18, because it is an awful security hole.

I'd recommend #2.

like image 160
Charles Stewart Avatar answered Sep 18 '22 23:09

Charles Stewart


Here is my dirty solution (because many people out there says not to use input but I want to get on :)):

\newcommand{\home}{../..}
\input{\home/latex/styles/info_hypersetup}

If you find something better, just let me know. The hint with setting output_any = a int the texmf.conf didn't work. I'm using ubuntu.

like image 29
Matthias Guenther Avatar answered Sep 18 '22 23:09

Matthias Guenther