2

I'm coauthoring a book and we use DropBox. I need to work on little test projects that use the same macro files as the main project. Ideally I would like to link to them using aliases so as not to have to make copies of the macro files, which is an obviously painful and limited solution. I've tried using an absolute path instead of an alias, but even that doesn't work.

I've created a mini project to demonstrate.

project.tex

\documentclass[10pt,a5paper]{book}

\input{macros.tex}

\begin{document}

$\srf$

\end{document}

macros.tex

% special relativity factor
\def\srf{\gamma\hskip1pt}

I put macros.tex in the folder above project.tex to simulate a differently located include file and created an alias. Here's the console output when I try to typeset.

console output when trying to use alias

Here's the console output when I use the full absolute path to macros.text instead.

console output when using absolute path

Am I doing something wrong; is there a better method; can anyone help?

2

The Problem

I have seen that this question does come up a lot in various guises with a mixed bag of specific answers and not always all the detail. I believe the question I have asked, with the only limitation that it applies specifically to Mac users, with a full answer on creating symlinks (symbolic links) and the difference between aliases and symlinks would be valuable.

An alias is not the same as a symlink. The alias is a facility provided for general OSX users. They are handled differently to symlinks which are a unix level facility, hence the need to use Terminal to create them. Any software using unix under the hood, such as TeXShop indirectly because it uses the underlying TeX distribution in this case, which uses specific unix methods, so symlinks will work when aliases won't.

If you're new to symlinks you need to know that they are hard coded in the sense that you can change the original file as much as you like but you can't rename or move it without breaking the symlink. You'd need to create another symlink with the new name and/or location.

Aliases are provided at the GUI level to automatically adjust when a file is moved and/or renamed. That's amazing, right, so why all the fuss about symlinks? Because, as mentioned above, whichever application you use to manage your TeX or LaTeX projects, such as TeXShop, the underlying TeX distribution uses unix facilities and must be provided with symlinks.

Creating Symlinks

Open Terminal and use the following command:

ln -s path/to/original/file path/to/symlink/directory

If any of your path elements has spaces in the names you must either escape them with a backslash \, or, either surround each element including spaces with quotes, or just surround the whole path with quotes, which is the simplest in my opinion.

ln -s "the path/to/the original/file" "the path/to/the symlink/directory"

If you leave out the destination path, it will use the current directory. Note that it easy to get paths from files in the finder by typing Command-I to get the info window for the file and you can then just copy its path from there. Same with the info window for the destination folder.

Finally I will mention the solution I am now trying, in case you don't like messing around with Terminal, which is a system service created by Nick Zitzmann and can be found at

https://github.com/nickzman/symboliclinker/releases

This is very easy to install and you use it like any other system service. Two finger click (trackpad) or control click or right click (mouse) on the file you want to link to, select the Make Symbolic Link option in the Services menu and it creates what looks like an alias, which you can drag to where you need it. As easy as using aliases.

Addendum

In the OP I mention that I tried using the absolute path and that also failed. Well, I realise now that was due to spaces in the path. I just went back to that experiment and put double quotes around the path and it worked fine. So, there's always the absolute path if for some reason or other you don't want to use a symlink.

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.