Urania

A blog named for the muse of Astronomy containing musings by an astronomer

Archive for the ‘LaTeX’


Experimenting with a little Homebrew 0

Posted on March 01, 2011 by Juan

Well, today it finally happened.  I got sick and tired of MacPorts behavior of replacing every binary already included in the Mac OS with its own version.  I don’t need two versions of perl or python installed on my Macs and I am getting tired that every time I try to install a port, it insists on installing a complete perl/python installation or its own set of libraries the MacOS already has built in,  in order to install a small utility.  I know that MacPorts has some justification for this, but it seems messy to me.

As such, I started looking for alternatives and came back to homebrew, which I had discovered a few months ago.  It is a package management system in which everything relies on already installed Mac binaries/libraries as much as possible.  By default, homebrew packages are installed into their own isolated directory (/usr/local/Library/Cellar/) and then symlinked into /usr/local/bin, /usr/local/sbin, or /usr/local/lib directories as needed. But it is flexible enough that you can install it where ever you want and it will still run.  Another nice feature, it doesn’t require you install it as root, it can run completely as the user permission level!

The negatives of homebrew:

  1. There are no where near as many packages (they call them “Formula”) are available for Homebrew as for MacPorts or Fink.
  2. For an astronomer, another big problem, there is no TeX under Homebrew.

It turned out the first negative was a bit of annoyance, but I was willing to live with it because the installation was so much cleaner and most of the important packages I needed MacPorts for were already there.  The second negative turned into a postive because I discovered here is a very easy to install MacTeX package available now that installs a complete TeXlive installation, including AASTeX, by default!  It even has some nice GUI controls included for keeping it up to date.

What follows is a description of what I did to transition from MacPorts to HomeBrew+MacTeX.

  1. Backing up MacPorts: No need to not have a way to change my mind if this blows up in my face.  I backed up my entire MacPorts installation by using the command

    tar czvf /opt_backup.tgz /opt

    and then when that was done, I had a 1.6 Gig tarball at the root level of my drive called opt_backup.tgz.

  2. Disable MacPorts: At this point, I deleted the /opt directory and commented out the commands in my ~/.tcshrc that added those directories to the PATH environmental variable.   If you use the default bash shell, you will need to edit ~/.bashrc to disable MacPorts.
  3. Install Homebrew: Following the directions on the Homebrew site. I originally wanted to place homebrew in its own custom install directory (/usr/local/homebrew).But after reviewing the Homebrew installation documentation, I came to realize that using the default /usr/local location for the install makes the most sense.

    I did this in the recommended manner, using the install script, which does some nice permission checking to make sure things will run nicely before installing. Since my default shell isn’t bash, I had to switch to it, then just run the install script from the command line:

    bash
    ruby -e "$(curl -fsSLk https://gist.github.com/raw/323731/install_homebrew.rb)"

    The first time I ran it, it failed because my permissions for /usr/local had been tweaked. So I had to run the command

    sudo chown -R root:staff /usr/local

    to get the permissions so the script could run.

  4. Activate Homebrew: Since I am not using a custom directory for the installation, there is not configuration needed in terms of setting up the environment. /usr/local/bin/ is in the default PATH, so as soon as I start up a new terminal window, homebrew is available! Otherwise, I would have to edit my default ~/.tcshrc or ~/.bashrc to add the homebrew binaries directories (bin and sbin) to the PATH environmental variable.
  5. Install my favorite packages using homebrew: Installing packages in homebrew is just a matter of making sure the Formula for the package exists (all the publicaly available Formula are here) and then typing

    brew install (formula name)

    So for example, installing CFITSIO was just a matter of typing:

    brew install cfitsio

    Actually, this was for the most part simple for my attempts to install git.  It kept crashing with an error that said:

    The current directory must be set to the ITT directory.

    Well, ITT is the vendor of IDL (a package commonly used by astronomers for data reduction) and I discovered that I had accidentally set the IDL binary directory to be in the PATH ahead of the default system directories.  This meant the IDL version of a binary called install was replacing the system default version of this.  Just the kind of problem I was trying to get away from in MacPorts.  I  changed to my ~/.tcshrc to make sure the IDL binaries directory was later in the PATH than the system directories fixed things.  The only package this affected the install of was git, all the other packages installed without a hitch thus far.  The other brew formulae I installed were installed with the following commands:

    brew install subversion  imagemagick ghostscript macvim lynx coreutils findutils plotutils

    I can get a list of all the packages I have installed using the command:

    brew list

  6. Installing MacTeX: This was extremely easy, I downloaded the MacTeX 2010 package (The version I got was dated 10 Sept 2010 and was 1.6 Gig) and then uncompressed it and double clicked it. It installs using the Mac Installer. I did make sure to customize the install to remove some of the stuff I didn’t feel I needed, but I kept the GUI tools. Turns out there is a nice TeX Live Utility installed in /Applications/TeX that lets you customize which TeX packages are installed and can automatically update things. Review of this tool also showed a very astronomer friendly decision to include AASTeX by default! The TeX installation is in the /usr/local/texlive/ directory and it installs a symlink at /usr/texbin/ to all the LaTeX binaries. I added the following lines to my ~/.tcshrc file to get the tex binaries in my PATH:

    # Set up MacTeX 2010 by including path to that installation of LaTeX
    setenv PATH ${PATH}:/usr/texbin

So there you have it, how I went from using MacPorts and the literally hundreds of packages to support the few I wanted to trimming things down to a few packages in homebrew and one double-clickable TeX installer.

[Edited on Mar. 2, 2011 11:04 am to update the instructions to the default homebrew instructions, which are cleaned and easier to implement.]

LaTeXit Updated for Leopard Compatibility 0

Posted on April 16, 2008 by Juan
One of my favorite little programs is LaTeXit.  It allows you to typeset LaTeX equations outside of a text editor and then drag the results into programs like Keynote or Pages.  It was not fully compatible with Leopard and my fix was a kludge that could break other programs.  Pierre Chatelier has released updated LaTeXit to version 1.15.0, which restores Leopard compatibility.  Notably, you can now use the default0 /etc/profile file without fear.

A fix for LaTeXit under Leopard 4

Posted on March 08, 2008 by Juan

[A better fix to this problem is to upgrade to LaTeXit 1.15, which was released on April 16, 2008.  It fixes the problems with Leopard and allows you to keep the default /etc/profile file for Leopard.]

Apparently, LaTeXIt, which I use to generate equations with Latex which can then be copied into Apple’s Keynote and Pages documents, locks up on launch a vanilla install of Leopard. This post on MacOSXHints.com provides a hack, but it wasn’t that nice, since it involves re-installing a particular version of latex. It turns out the solution was really much simpler and shows up in the comments on that page. In the comments, user Paolo Bosetti notes that

There is actually a much easier workaround: simply change your /etc/profile commenting the following lines (add the “#” at the begining):

# if [ -x /usr/libexec/path_helper ]; then
# eval `/usr/libexec/path_helper -s`
# fi

and adding the following two:
PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/local/bin:/usr/X11/bin"
export PATH

Why so? Apple changed the Leopard way to set the PATH variable, and now it uses the /usr/libexec/path_helper command, which seems having troubles with LaTeXiT spawned bash scripts. If you make this modification to your /etc/profile, you are simply dropping the new path_helper in favour of the plain old way to set the PATH variable.

This also explains why I wasn’t seeing this on my laptop, since it kept the old /etc/profile file during the upgrade.

Another user comments that the fix could also be done without hacking the /etc/profile but instead just changing ~/.profile such that /opt/local/bin appears in the path last, since /usr/libexec/path_helper is supposed to read ~/.profile. However, I was unable to get this approach to work.

MacPorts getting more functional for this Astronomer 0

Posted on January 24, 2008 by Juan

About 6 weeks ago I posted about the various ports that failed to install in my first attempts at getting “my standard suite” of ports installed under MacPorts on Leopard. My standard suite until Tiger involved issuing the following command:

sudo port install aquaterm chmdump contacts coreutils curl file findutils g95 ghostscript gv ImageMagick ksh93 latex2rtf lynx macutil osxutils plotutils subversion teTeX tidy vim wget wine xterm xephem

Since then MacPorts has released version 1.6 and the various porters have been hacking at the various problems. I can now report that of the ports I reported failed to install:

  • xterm, wine, and g95 all now install without any issues.
  • teTeX can be installed, there was a bad dependency in the portfile. You just needed to install openmotif first manually. I don’t know if the bad dependency is still there, it may have been resolved.
  • subversion can be installed, it also had a bad dependency. You just needed to install nawk first. Again, I don’t know if the bad dependency is still there, it may have been resolved.
  • gv can be installed if you apply a patch. If you check that bug ticket on gv (you need to get a free MacOSForge account), you will find a new patch-setenv.c file is available there. If you download that file and replace /opt/local/var/macports/sources/rsync.macports.org/release/ports/print/gv/files/patch-setenv.c with it, gv will compile and install just fine.

This leaves just two of my standard suite of packages that don’t compile right in Leopard, osxutils (See this post) and xephem (See this post). And xephem installs just fine manually if you download the source code.

Texmaker is my latest LaTeX power tool 0

Posted on October 10, 2007 by Juan

There are a wide variety of LaTeX front-ends out there. I recently discovered Texmaker and I like it a lot. It’s not quite Mac native, so the interface takes a little getting used to, but has a nice syntax-coloring editor, some latex-specific menu items for inserting symbols and math, and it is free. You can download it here, but I would recommend installing aspell (for spell checking) via macports instead of using fink.  

ChkTeX on Mac OS X 0

Posted on October 09, 2007 by Juan

I haven’t played with this personally yet, but since I will be working on a paper for publication shortly, it looks like this might come in very handy. A Dr. Figueroa-Centeno in the Department of Mathematics in Hawai`i has posted instructions for getting the LaTeX syntax checker, ChkTeX, running under MacOS X. It doesn’t look terribly difficult. He includes instructions and a script for BBEdit integration, which makes me a happier BBEdit user. To quote from the ChkTeX website:

[ChkTeX] has been written in frustration because some constructs in LaTeX are sometimes non-intuitive, and easy to forget. It is not a replacement for the built-in checker in LaTeX; however it catches some typographic errors LaTeX oversees. In other words, it is Lint for LaTeX.

Looks promising for me. I use Splint when C programming (I installed splint via MacPorts using the command line sudo port install splint), so the idea of a Lint for LaTeX is appealing. I’ll be visiting Dr. Figueroa-Centeno’s website on ChkTeX on Mac OS X for full details on installing it, once I get a break from teaching.

HINT: Getting AASTeX Installed on a Mac for all users. 0

Posted on July 13, 2007 by Juan

NOTE: I will assume you have installed teTeX (a modern LaTeX package) in one of a variety of ways. Personally I recommend either Fink or MacPorts. However you can get a lot more information about this by visiting the “Getting Started” page at the Mac TeX website.

AASTeX is used to help typeset publications for all the major astronomical journals (at least in the US). You have two fundamental options for installing AASTeX on the Mac:

  1. Single User Install: The easiest way is to download AASTeX (the version for LaTeX 2e) from http://www.journals.uchicago.edu/AAS/AASTeX/ and then just copy the aastex.cls file to whatever directory contains your latex source code for your paper. It should work just fine if you do that.
  2. Global Install: If you want to make the AASTeX class file available to all your Mac users, you need to install it globally where the laTeX installation keeps its latex libraries. The easiest way to do this is to first determine where teTeX keeps its laTeX libraries (referred to as TEXMFMAIN). One simple way to do this is to type the following from the command line
    texconfig conf | grep TEXMFMAIN

    Once you have found that directory, edit the Makefile that comes with AASTeX so that INSTALLDIR equals that directory and fire off a
    sudo make install

    Once you have installed AASTeX, run
    sudo texconfig rehash

    And you should be set.

P.S. – Most teTeX installs come set to European paper sizes. If you want US Letter size, just run the configuration program and set US Letter size pages as the default using:

sudo texconfig

Its text menu driven and pretty straight forward.

  • Translate

  • Astro Pic o' the Day

  • Archives

  • Admin



↑ Top