Friday 29 July 2011

Installing Latex and PGF

I smugly advised in my last post that you should simply look at my post to identify how to install Latex with PGF Tikz support. Turns out my previous post was as deficient as a very deficient thing on a day of particular deficiency.

Ahem.

What you need to do is to grab two files off t'internet. These are the TexLive Latex distribution (this is a biggie) and the PGF add on.

The TexLive distribution is best downloaded as a single file if you are going to be pissing about trying to repeatedly install it to get the fucker working. It is 2Gb though, so set aside some time for the download. You can find various download options, including torrents, at this page. My nearest CTAN mirror is in the UK, so my command to download the DVD Image is:

cd ~
wget http://mirror.ox.ac.uk/sites/ctan.org/systems/texlive/Images/texlive2011.iso

You can then grab the PGF file by running these commands:

wget http://sourceforge.net/projects/pgf/files/pgf/version%202.10/pgf_2.10.tds.zip/download
mv download pgf_2.10.tds.zip

However, if it is regularly updated, you would probably just want to go to this page and download the latest version manually.

To install the software first you need to mount the DVD image. You can do that as follows:

mkdir ~/texlivedvd
sudo mount -o loop ~/texlive2011.iso ~/texlivedvd

You can then run the graphical installer from TexLive. It requires the perl-tk package, which you can install as follows if you do not already have it:

sudo apt-get install perl-tk

To then run the installer, you use this command:

sudo ~/texlivedvd/install-tl -gui perltk

You want to install as comprehensive a system as possible, but you can omit language packs you are not going to use to save some time and space.

The best idea I have found to avoid permissions bullshit is to install to your home directory, so you would choose an install path like [~/texlive].

Once installed, you want to tell your system where to find the nice new files, which you can do as follows:

cat >> ~/.bashrc << "EOF"
PATH=~/texlive/2011/bin/i386-linux:$PATH
export PATH
MANPATH=~/texlive/2011/texmf/doc/man:$MANPATH
INFOPATH=~/texlive/2011/texmf/doc/info:$INFOPATH
export MANPATH
export INFOPATH
EOF
source ~/.bashrc
What that command does is add those lines to your [.bashrc] file. They add the folders containing the TexLive install to your path so that other programs (like ktikz) can find them. The last command just processes the file to prevent you from having to reboot. I am not entirely sure, but I think this may only affect programs run from the command line, because I have been having problems with ktikz if I run it from the desktop icon. Installing PGF is much easier. Just change into the correct TexLive directory, and unpack the archive:
cd ~/texlive/2010/texmf/
sudo unzip ~/pgf_2.10.tds.zip
sudo texhash
The [texhash] command just (I think) lets the rest of TexLive know that this extra stuff has been installed. That's it for PGF. To install ktikz you are going to need a few packages. Install them as follows:
sudo apt-get install build-essential cmake libqt4-dev qt4-dev-tools libpoppler-qt4-dev kdelibs5 kdelibs5-dev khelpcenter4
Basically what you are doing here is installing software that supports KDE applications. If you happen to be running KDE anyway you should have most of this stuff. Once installed, you can grab the ktikz source code, compile and install it using these commands:
cd ~
wget http://www.hackenberger.at/ktikz/ktikz_0.10.tar.gz
tar -xzvf ktikz_0.10.tar.gz
cd ktikz
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=`kde4-config --prefix` ..
make -j2
sudo make install
That should be that. Remember that ktikz needs to load up the PGF packages you want to use. Common ones for me are loaded as follows:
\usetikzlibrary{calc,through, intersections,decorations.text, decorations.pathreplacing}

2 comments:

  1. Just a couple comments.

    1. The net install might be a bit easier.

    2. Towards the end of the tlmgr --install it asks if you wish to put symlinks for PATH, MANPATH, and INFOPATH. If you do this you don't need to muck with .bashrc.

    3. I think it may be preferable to use tlmgr install pgf because [a] it's more up to date and [b] it'll integrate automatically with the rest of /usr/local/texlive/2011/texmf/. For some reason tlmgr install ktikz doesn't find anything for me. (TeXLive 2011, Ubuntu 10.04, early Sep 2011)



    Thank you for putting up these demonstrations; this is EXACTLY the most helpful kind of google result when one is foaming at the mouth. Very helpful.

    ReplyDelete
  2. Lao Tzu,

    When you have tried and failed to get the sodding net install to work several times, and are on the verge of tears, what you want is the huge DVD Image sitting there so you wipe everything and start again. Or at least that's what I wanted.

    I tried 2. Didn't fucking work. I hate PATH based nonsense, almost as much as I hate permissions based nonsense. I have installed everything, just bloody work.

    3. I had no idea that Tex would auto install pgf. I suspect though that my source is probably the most up to date PGF you are going to get. It's right from the equine's oral cavity after all.

    ReplyDelete