In short my document is compiling without a problem with TeXShop and not at all with command line pdflatex. What is strange is that pdflatex does not recognize some basic packages, that are installed, for sure (ex: url.sty).

I need to use the command line option because I am calling it from another script.

What do I need to update? Is it a question of setting paths?

I am on a OSX 10.6.8, running MacTeX2013. The same set up runs without a problem with command line pdflatex on Ubuntu 12.04 LTS.

  • 3
    Do you have more than one latex installation? I've seen several times that the PATH for commandline latex was wrong on Mac. Try a simple hello world document (i.e. no extra packages and just that phrase), compile it using both the commandline and TeXShop (different document names), then look in the .log files, it will list where it got the class file from. – daleif Nov 6 '13 at 10:40
  • Indeed the .log shows different versions. Version 3.1415926-2.5-1.40.14 (TeXShop) vs Version 3.1415926-2.4-1.40.13 (command line). Should I wipe out all older versions, or can I redirect everything to the newest somehow? – user39572 Nov 6 '13 at 10:51
  • 2
    You have a MacPorts provided distribution; uninstall it. – egreg Nov 6 '13 at 11:36
  • @egreg: Thank you, that's what it was. I had issues uninstalling texlive/latex from macports (same as the discussion here bit.ly/18YBujT), so in end I appended the MacTex path to the front of my $Path. That worked. – user39572 Nov 6 '13 at 12:52

By inspecting the output of which pdflatex, it seems you are using a TeX distribution provided by MacPorts. Personally, I think the use of a TeX distro via MacPorts should be discouraged; MacTeX is IMHO the best way of getting an updated and stable TeX distro on a Mac, and not to mention the handy TeX manager in the System Settings.

If you remove the TeX distro from MacPorts, the path inspection will return only one ocurrence of the TeX tools you need, i.e, the one living inside /usr/texbin, which is the one TeXShop is using. In any case, if you want to stick with those two distros, let's see how to handle them.

Setting MacPorts TeX distro in TeXShop

TeX tools from MacPorts live inside /opt/local/bin. If we want to use them in TeXShop, we need to add the full path. In TeXShop, from the menu, go to TeXShop, and Preferences. Select the Engine tab. The following screen will pop up:


Setting the TeX tools via command line

If you want to set up your terminal to use a certain TeX distro, we need to inspect the path first. Issue

echo $PATH

and see the output. If, say, /usr/texbin comes first than /opt/local/bin, because of path search priority, the TeX tools will be from MacTeX instead of MacPorts. If by any chance you want to reverse the order, we need to edit the path. I'd recommend setting either .bashrc or .bash_profile. I usually prefer the latter.

Go to the terminal and type:

touch ~/.bash_profile
open ~/.bash_profile

The first command will create the .bash_profile if it doesn't exist, while the second will open it in your default editor. Now, add the following line to your file

export PATH=/opt/local/bin:${PATH}

if you want the TeX distro from MacPorts to appear first, or

export PATH=/usr/texbin:${PATH}

to have MacTeX inspected first. Then save the file. You can apply modifications to your current session by issuing

source ~/.bash_profile

Additional info

As egreg and Alan mentioned in the commands, it's way better to rely on the official MacTeX distribution instead of relying on the MacPorts one. Besides, relying on /opt/local/bin as the first search path might interfere with other system tools because of path priority. MacTeX is always the best solution.

Hope it helps. :)

  • Yes, turns out I have two pdflatex's: this one and /usr/texbin/pdflatex this one: /opt/local/bin/pdflatex. My system (not TeXShop) seems to think the latter is the default. How do I change that? – user39572 Nov 6 '13 at 11:10
  • @user39572: Oh sorry, I thought it was the other way around. I'll update the answer. – Paulo Cereda Nov 6 '13 at 11:15
  • 2
    @paulocereda I think this is still confusing since it mixes both distributions in the same answer depending on which direction you go. But the answer should be IMO "Get rid of the MacPorts distrbution." – Alan Munn Nov 6 '13 at 14:13
  • @Alan: agreed. :) I think PATH must be left untouched. I'll try to make things clear. Hold on. :) – Paulo Cereda Nov 6 '13 at 14:20
  • @Alan: I rewrote the answer, maybe it looks better now? – Paulo Cereda Nov 6 '13 at 14:46

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.