Tips and tricks

Converting HTML to MS Word

You've written a document in HTML, and then someone complains that it's not in a reusable format and could they have it as a Word document instead. Weep not for that person's soul. Simply add the following line to the head of your HTML document

<meta name="Generator" content="Microsoft Word 11 (filtered)">

You or they should now be able to open the document in Word as a ‘real’ document (i.e. not as HTML markup) and either do whatever it was they wanted to do with it, or save it as a Word document.

Distros on distros

One of the great things about modern Linux-based operating systems is their package management. Software is compiled into lots of different packages, and the package manager handles dependencies between them, updates them and so on. But what happens if the software itself has its own set of packages to manage? There are two common solutions: either the software package manager is turned off and its functions simulated by OS package manager (TeX Live), or the software packages are handled in a per-user profile directory (Firefox addons).

The problem with the former is that the guys that do the packaging for the OS have to duplicate the work done by the guys that do the packaging for the software, so unless they're really keen they lag behind a fair bit. The latter is fine, but can be inefficient if each user needs the same packages, or if core packages need to be updated.

Here's a method for letting users share the task of managing software packages using a 'vanilla' installation of the software distribution.

  1. If you're replacing one or more of the OS's packages with this custom installation, you might want the OS package manager to pretend that they're installed regardless. This is more important when other packages depend on these packages. To do this on a Debian-based system like Ubuntu, use equivs.

    sudo apt-get install equivs

    Switch to a working directory and run the following command to get a template document. I'll use TeX Live as an example.

    equivs-control texlive-local

    Here's how I filled out the template.

    Section: misc
    Priority: optional
    Standards-Version: 3.6.2
    
    Package: texlive-local
    Version: 2009-9~9
    Maintainer: Alex Ball 
    Provides: asymptote, dvipdfmx, dvipng,
     cm-super, cm-super-minimal, context, latex-beamer, latex-cjk-all,
     latex-cjk-chinese, latex-cjk-chinese-arphic-bkai00mp,
     latex-cjk-chinese-arphic-bsmi00lp, latex-cjk-chinese-arphic-gbsn00lp,
     latex-cjk-chinese-arphic-gkai00mp, latex-cjk-common, latex-cjk-japanese,
     latex-cjk-japanese-wadalab, latex-cjk-korean, latex-cjk-thai, latex-sanskrit,
     latex-xcolor, lmodern, luatex, musixtex, pgf, prosper, tex4ht, tex4ht-common,
     texlive-base, texlive-base-bin, texlive-base-bin-doc,
     texlive-binaries, texlive-common, texlive-doc-base,
     texlive-doc-bg, texlive-doc-cs+sk, texlive-doc-de, texlive-doc-el,
     texlive-doc-en, texlive-doc-es, texlive-doc-fi, texlive-doc-fr, texlive-doc-it,
     exlive-doc-ja, texlive-doc-ko, texlive-doc-mn, texlive-doc-nl, texlive-doc-pl,
     texlive-doc-pt, texlive-doc-ru, texlive-doc-si, texlive-doc-th, texlive-doc-tr,
     texlive-doc-uk, texlive-doc-vi, texlive-doc-zh,
     texlive-font-utils, texlive-fonts-extra, texlive-fonts-extra-doc,
     texlive-fonts-recommended, texlive-fonts-recommended-doc, texlive-formats-extra,
     texlive-full, texlive-games, texlive-generic-extra, texlive-generic-recommended,
     texlive-humanities, texlive-humanities-doc, texlive-lang-african,
     texlive-lang-all, texlive-lang-arab, texlive-lang-arabic, texlive-lang-armenian,
     texlive-lang-croatian, texlive-lang-cyrillic, texlive-lang-czechslovak,
     texlive-lang-danish, texlive-lang-dutch, texlive-lang-finnish,
     texlive-lang-french, texlive-lang-german, texlive-lang-greek,
     texlive-lang-hebrew, texlive-lang-hungarian, texlive-lang-indic,
     texlive-lang-italian, texlive-lang-latin, texlive-lang-latvian,
     texlive-lang-lithuanian, texlive-lang-manju, texlive-lang-mongolian,
     texlive-lang-norwegian, texlive-lang-other, texlive-lang-polish,
     texlive-lang-portuguese, texlive-lang-spanish, texlive-lang-swedish,
     texlive-lang-tibetan, texlive-lang-ukenglish, texlive-lang-vietnamese,
     texlive-latex-base, texlive-latex-base-doc,
     texlive-latex-extra-doc, texlive-latex-recommended,
     texlive-latex-recommended-doc, texlive-latex3, texlive-luatex,
     texlive-metapost, texlive-metapost-doc, texlive-music,
     texlive-omega, texlive-pictures, texlive-pictures-doc, texlive-plain-extra,
     texlive-pstricks, texlive-pstricks-doc, texlive-publishers,
     texlive-publishers-doc, texlive-science, texlive-science-doc, texlive-xetex,tipa,
    Architecture: all
    Description: My local installation of TeX Live 2009.
     A full "vanilla" TeX Live 2009.
     http://tug.org/texlive/debian#vanilla

    You will need to keep track of the version numbers to ensure this always appears to be more up-to-date than the real packages. To turn this file into a Debian package, run the following command.

    equivs-build texlive-local

    This should produce a file called texlive-local_2009-9~9_all.deb, which you can install graphically (clicking on it) or using the command line again.

    sudo dpkg -i texlive-local_2009-9~9_all.deb

    If you do mimic lots of packages like this, remember that you have the responsibility of installing resources that other programs depend on.

  2. Now comes the point at which you install the software for real. For TeX Live, this means running install-tl as root. For, say, Eclipse, this means unzipping a folder and copying it somewhere sensible as root. The sensible place for software not managed by the package manager is /opt/, so in this example you'd tell TeX Live to use a root directory of /opt/texlive/.

  3. To make sure the system can find all the executables, make symlinks to them from /usr/local/bin. With TeX Live, tlmgr can do this when run as root.

  4. To avoid having to run the program's package manager (which in some cases is the program itself) as root, create a new group for the program. Then add root to the group, along with any users you want to allow to act as administrators for the program. Apparently you can do it like this:

    sudo addgroup tex
    sudo usermod -a -G tex root
    sudo usermod -a -G tex me

    but I did it graphically. Now switch the group for the installation folder and ensure that the group has write access.

    sudo chgrp -R tex /opt/texlive
    sudo chmod -R g+w /opt/texlive

    You'll need to log out and log in again for these changes to take effect.

Local fonts in TeX Live

Setting up local fonts should be a lot easier in TeX Live than it is. Here's my solution, used in conjunction with the technique above.

  1. Assuming you have a TeX tree set up (say, in ~/Data/TeX/myfontmf/) with all the font and support files in the right places, add the following lines to your ~/.profile.

    TEXMFHOME="$HOME/Data/TeX/{myfontmf,any-other-trees}"; export TEXMFHOME
    TEXMFLOCAL="$HOME/.texlive2009/texmf-local"; export TEXMFLOCAL

    You can then wait until the next time you log in, or issue the same commands at the command line in order for them to take effect.

  2. Copy the system-wide texmf-local (say, /opt/texlive/texmf-local) to wherever you said you'd put it (here, ~/.texlive2009/texmf-local).

  3. Start a file called updmap-local.cfg in ~/.texlive2009/texmf-local/web2c containing the list of map files you want the system to know about.

    Map myfont.map
    Map myotherfont.map

Now whenever you issue the updmap command, your local fonts should be included.