The PracTEX Journal, 2007, No. 3 Article revision 2007/08/21

ALATEX2ε “-like” environment on Mac OS X Vinicius Provenzano

Abstract Free and commercial LATEX2ε implementations for the Mac OS X are avail- able on the internet. If you have always used a Mac, the best starting point is to download and install one of these systems. However if you have al- ways used Linux and now find yourself in front of a brand new Mac OS X machine and have no time to learn new tools from scratch, your best op- tion would be to use your familiar Linux applications on Mac OS X. This paper aims to show you how to install and configure a Linux-like LATEX2ε environment in the Mac OS X, using Fink, teTEX and Kile.

1 Introduction

The Apple Mac OS X has a great collection of tools for LATEX2ε users. If you have always used Mac OS X this article is not for you. But, if you need a familiar Linux LATEX2ε environment and tools, then we can talk. Most Linux distributions have teTEX as the default LATEX environment. teTEX is no longer being updated, but is still widely used1 on Linux systems. Since we want to reproduce a Linux environment on a Mac, we will work with teTEX. I assume you have Apple’s original DVD Media and a stable Internet connection — these are the main requirements to achieve our goal.

2 Preparing Mac OS X for the traditional Linux tools

The Linux uses the X Windows System2 as the server to run graphic applications, and Mac OS X uses Aqua. It is possible to make Mac OS X

1. The migration to TeXLive in the Linux world is still in its early stages. 2. also known as X11, XFree86 or simply X use an X server to handle graphical applications, such as Kile, originally written for Linux OS. The Apple Website3 gives more details about X11 and Mac:

(...) X11 for Mac OS X offers a complete X Window System implemen- tation for running X11-based applications on Mac OS X. Based on the de facto-standard for X11, the open source XFree86 project, X11 for Mac OS X is compatible, fast and fully integrated with Mac OS X. It includes the full XFree86 4.4 distribution including a window server, libraries and basic utilities such as xterm. Native Aqua and X11 appli- cations run side by side on the Mac OS X desktop. You can cut and paste between X11 and Aqua windows. You can minimize X11 win- dows to the Dock - even with the “Genie Effect.” You use the Aqua window controls to close, minimize and zoom X11 windows. And of course, each X11 window comes with its own carefully rendered drop shadow. Experts may choose to replace the native Aqua window manager with their own familiar, standard X Window Manager.

In this sense, Apple provides the X Windows system for Mac OS X. X11 will need to be installed in order to get Kile up and running4. Xcode Tools are necessary and can be found on the same DVD set. Xcode Tools contains a set of developer tools provided by Apple, and some of its bundled tools are required in order to have the environment set.

3 Mac meets Linux! Mac meets LATEX2ε! Thanks to Fink!

The next is to install Fink. Fink is an open-source project that ports common Linux software to Mac OS X. The Fink website5 offers some background on the project:

The Fink project wants to bring the full world of Open Source software to Darwin and Mac OS X. We modify Unix software so that

3. Please visit http://www.apple.com/macosx/features/x11/ 4. Please visit http://developer.apple.com/opensource/tools/runningx11.html. 5. Please visit http://finkproject.org/

2 it compiles and runs on Mac OS X (“port” it) and make it available for download as a coherent distribution. Fink uses tools like and -get to provide powerful binary package management. You can choose whether you want to download pre-compiled binary packages or build everything from source.

Installing Fink is easy but its usage can seem a bit complicated at first. If you are a Debian-based distro user you will find yourself at home. Fink uses apt- like commands to deal with its repository, so managing software dependencies is done automatically. You can download Fink from the link: http://www.finkproject.org/download/index.php?phpLang=en Please note that you need to choose the right Fink .dmg package for your Mac OS X version. I have already successfully installed Fink on both PPC and Intel Macs under Tiger, but builds for earlier versions of Mac OS X are also avail- able. Double click the and follow the instructions. You can choose the default options without fear. If you have any problems please refer to the Fink page referenced above. After completing the Fink installation process, check under your Applications Folder to see if FinkCommander’s icon was placed there. If not, just drag it from the Finder Window to the Application folder Finkcommander will be installed. Finkcommander is a very powerful tool similar to Ubuntu Linux’s synaptic pack- age tool. It can update, delete, compile, or just install software from binary files. Like Debian distros, Fink categorises software in stable or unstable trees. The stable tree gathers software systems that were tested and approved as not prone to bugs. On the other hand, the Unstable tree has software that still needs testing to be considered stable. You can browse Fink’s stable and unstable package lists on Fink’s website, and learn more about their packaging system. You can also help developers and maintainers by testing software, like Kile, to get it listed as stable6. When you run Finkcommander, it lists all the available software from the stable tree. 6. http://pdb.finkproject.org/pdb/index.php?phpLang=en

3 4 Installing teTEX

The complete teTEX packages are not available in Fink‘s stable software column, and thus we need to tell Fink it should also consider unstable packages. Fink developers encourage you to change the default setting to only install the appli- cations you need from the unstable tree. Once the software you need is installed you should reset Fink to work with stable packages only. Go to Fink Commander → Preferences → Fink and click on use “unstable packages”. It will add the unstable packages repository to the list of repos to check. Save the preferences. Close Fink Commander and open it again so it will update the package list. On Fink’s Commander main window you have a Spotlight like search box. Type teTEX on it to see all teTEX packages available.

Choose teTEX from the list, go to the binary menu and choose install. If you want to do it the Linux way, just type on a :

sudo apt-get install tetex

4 The teTEX environment is large and takes some time to download. After the download finishes, your LATEX2ε environment will be installed and 7 configured. LATEX2ε will be up and running !

5 Kile? Finally!

While this article was being written, the latest version of Kile was available in Fink‘s unstable repository. But since there are no binary packages for it, nor for KDE8 (which Kile relies on to run), Kile will need to be compiled from source. The compilation can be performed by FinkCommander. To compile Kile, FinkCommander will download all dependencies not already installed and compile all programs from scratch. It takes a long time to download, compile, and install all Kile dependencies. Thus it is better to install available binary packages needed by Kile, and then build and run it. The available binary packages that can be installed (on my system) are listed below9: aspell aspell-dev aspell-shlibs audiofile audiofile-bin audiofile-shlibs autoconf cyrus-sasl2-dev cyrus-sasl2-shlibs daemonic db44-aes db44- aes-shlibs default-icon-theme docbook-dsssl-nwalsh docbook-dtd docbook- utils docbook-xsl esound esound-bin esound-common esound-shlibs expat expat-shlibs flex-devel freetype219 freetype219-shlibs gd2 gd2- shlibs gettext gettext-dev gettext-tools glib glib-shlibs glib2 glib2-dev glib2-shlibs gtk-doc help2man html-tagset-pm intltool jadetex lesstif lesstif-shlibs libart2 libart2-shlibs libgettextpo2-shlibs libidn libidn-shlibs libjpeg libjpeg-bin libjpeg-shlibs libkpathsea4 libkpathsea4-shlibs lib- mad libmad-shlibs libogg libogg-shlibs libpng3 libpng3-shlibs libtiff libtiff-bin libtiff-shlibs libusb libusb-shlibs libvorbis0 libvorbis0-shlibs libwww libwww-bin libwww-pm586 libwww-shlibs libxml2 libxml2- bin libxml2-shlibs libxslt libxslt-bin libxslt-shlibs m4 openjade open- motif3 openmotif3-shlibs openslp-ssl-dev openslp-ssl-shlibs opensp4

7. Emacs, vi or Xemacs editors have binary packages available! If you are familiar with them you can start writing right away! 8. Perhaps when you read this article new binary packages will have been made available! Fink is very a dynamic project. 9. This list will vary from system to system, and depends on many factors.

5 opensp4-dev opensp4-shlibs openssl097-shlibs pcre pcre-bin pcre-shlibs pkgconfig qt3 qt3-designer qt3-doc qt3-linguist qt3-shlibs readline5 readline5-shlibs remap-bad-apple-keys scrollkeeper sgml-entities-iso8879 sgmls-pm system-openssl-dev t1lib5 t1lib5-shlibs texi2html texinfo xdg- base xfontpath xml-parser-pm586

You can select each package on Fink Commander and choose binary → install or just “sudo apt-get install” the list above.

Setting up Kile will be faster after the packages are installed . Select Kile from FinkCommander’s packages list. Since it has no binaries we are forced to compile it and its missing dependencies. From the Source Menu choose the option Install. Answer the questions10 and FinkComander will down-

10. If Fink asks you about teTEX or others, choose teTEX even if it is not the default choice.

6 load and compile Kile for you. It’s also possible to achieve the same result by typing the following command: fink install kile

On both types of installations it will take a lot of time to complete the instal- lation. Fink needs to download and compile a large number of KDE libraries. It also has to compile Kile. If Kile is not compiled on the first try, read the messages output by apt-get or by FinkCommander to understand why, and follow the hints to solve the problem11. It is also a good idea to install Kdvi and Kpdf; they are not required to run Kile but I am pretty sure you will need them. Without Kdvi, Kile will loose its preview capacity.

6 Getting Kile to run

First you will need to run X11. Go to the Finder, click Applications, Utilities and then double click X. 11. Most of time the problems you get are related to inconsistencies in the database that can be solved by typing the command “sudo apt-get update”.

7 On the xterm window that will open you can run any X11 program. Type kile in the xterm window and it should start. It takes some time to load since all KDE libraries have to be loaded before Kile.

After all the downloading and compiling, the reward is that Kile up and run- ning!

7 Troubleshooting

Sometimes Fink, X11 and Mac OS X integration do not run as smoothly as it should. Some of the main issues can be easily solved.

8 If your xterm complains about “command not found”, set the path environ- ment for Fink. On any terminal run the following command:

/sw/bin/pathsetup.sh

A window should pop up confirming that the PATH variable is now set12. All programs installed by Fink can now be accessed from the command line. Remember that if the application you want to use needs X11 to run, like Kile, you should start X11 first, and then start any other X program.

The system is configured, but right now you can only start Kile from X11’s xterm. When it runs from Terminal.app a DISPLAY error appears. A DISPLAY variable needs to be set for Terminal.app to be aware that X11 is running. To get more power and be able to start Kile directly from Mac OS X terminal.app13, you

12. if you still have problems please visit Finks Documentation page: http://finkproject.org/ doc/users-guide/install.php#setup 13. Please remember that X11 must be running for Kile to work!

9 can create two little files in your home directory : .bashrc and .bash profile14, that will be used to define an environment variable to tell Terminal.app where X is running. Create .bash profile on your home directory with any text editor with the following content: echo "Reading ~/ .bash\_profile" source ~/.bashrc

Then create .bashrc with the following content: echo "Reading ~/.bashrc" # Initialize FINK if needed if [[ ! -x $(which fink) && -d /sw/bin ]];then source /sw/bin/init.sh fi # Set the DISPLAY variable -- works for Apple X11 with Fast User Switching if [[ -z $DISPLAY && -z $SSH_CONNECTION ]]; then disp_no=($( ps -awx | grep -F X11.app | awk ’{print $NF}’ | grep -e ":[0-9]")) if [[ -n $disp_no ]];then export DISPLAY=${disp_no}.0 else export DISPLAY=:0.0 fi echo "DISPLAY has been set to $DISPLAY" fi

8 Conclusions and alternatives

Setting up this environment is not easy nor fast, but the reward is a perfect work- ing Kile/LATEX2ε environment. 14. Bash code variation from http://xanana.ucsc.edu/xtal/x11.html. Please visit the page for other unix shell examples. You cannot forget the dot in front of the file names, otherwise it will not work.

10 It’s likely that in the near future the same result can be accomplished in a simpler way, since KDE4 applications are being ported natively to Mac OS X and will run without the need of Fink15. Hopefully, Kile will soon be available on a “download and install” basis. Running LATEX2ε on a Mac can also be achieved with a combination of TUG- MacTeX16 and TexMaker17. This is an easy way to install an environment, with major similarities to teTEX and Kile. I like this option and think that most peo- ple familiar with Kile will choose this as the natural transition path from the Linux/KDE environment to Mac OS X. If you want to contact me, please visit one of my blogs: http://provenzano. wordpress.com (english) or http://camelomanco.com (portuguese). Happy writing!

15. For more information visit:http://dot.kde.org/1168899755/ 16. The LATEX environment maintained by TeX Users Group. It is easy to install through a .dmg package. Please visit http://www.tug.org/mactex/ for more information. 17. was the first name of Kile, and its developer, Pascal Brachet, was the original Kile developer. TexMaker runs on Mac, Linux, and Windows and is almost as powerful as Kile. Please visit http://www.xm1math.net/texmaker/ for more info.

11