Extending latex memory

Latex is a very powerful typesetting application. A powerful package to be used with this is pgfplots, which allows you to render your plots using the latex engine. Unfortunately the default latex settings assume you’re running latex on an ancient 20 MHz 486 with less ram than your average mobile phone. This is ok if you’re just asking it to process text, but if you’re using pgfplots it will run out of memory trying to draw your images.

The solution is to increase the amount of memory latex uses.

Windows – Miktex
We’re doing this in the windows command line. You can get to this by opening the start menu and do run .... Type cmd to start the terminal. On vista and up, you can just type cmd in the search field.

  1. Go the folder where Miktex is installed. Most likely this is C:\Program Files\Miktex 2.7\
  2. Go to the subfolder Miktex
  3. Go to the subfolder bin
  4. run
    initexmf --edit-config-file=pdflatex

    Replace pdflatex with latex or xetex if you’re using that.

  5. You’ll get a notepad screen with a file called pdflatex.ini. Add the line

    Don’t worry about the exact number, just make it big.

  6. Save the file
  7. run
    initexmf --dump=pdflatex
  8. That’s it. Enjoy your nice pgfplots figures

Linux – Texlive
Do the following things in a terminal as root.

  1. Find out where your texmf.cnf is located
    kpsewhich texmf.cnf

    This will most likely be /usr/share/texmf/web2c/texmf.cnf

  2. Open it and search for main_memory line and modify it to
  3. Save the file
  4. run
    fmtutil-sys --all

    to load the new settings

Latex formula as a native powerpoint object

It’s always a dilemma: latex is great for formulas but well, not so much at making slideshows or posters. Powerpoint on the other hand is great at the latter, but sucks balls at the first. No matter which tool you use to create your powerpoint, a lot of frustration, broken coffee mugs and hairloss ensues. Wouldn’t it be great if you could just typeset formulas in powerpoint using latex?

Enter: Tex 4 PPT
It renders your latex formula in the native ppt vector format. This means that it’ll look good at any resolution.

It requires a working Miktex install and microsoft’s .net framework.

Boot ISO files from USB with grub4dos

The goal is to make a universal bootable usb device with a small boot partition and a data partition on which we’ll store the iso files. This means you can just download almost any bootable iso and boot it without having to burn a cd or unpack the iso. We’ll install grub4dos as boot loader, using the ‘triple mbr’ feature to increase the compatibility with different mainboard and BIOS configurations. We’ll be using command line linux applications to reach our goal, any distro will do.

1) Find the path to your usb device, here we’ll use /dev/sdb
2) Optionally, to erase the usb device, issue the following commands as root:

shred -v -n0 -z /dev/sdb

3) Note down the size of the device in bytes:

fdisk -lu /dev/sdb

Disk /dev/sdb: 1031 MB, 1031798272 bytes

4) To make fdisk happy, partitions must end on cylinder boundaries. Here we’ll use the standard 63 sectors/track and 255 heads, so to calculate the number of cylinders and the last sector of the last cylinder, do the following:

num_cyl = floor( 1031798272 / 512 / 63 / 255 ) = 125
last_sector = num_cyl*255*63 - 1 = 2008124

5) We’ll make two partitions: a small boot partition with a ext2 filesystem and a second fat32 (or ntfs) partition to hold the iso files. Choosing ext2 as the boot filesystem hides it from windows systems, and makes the second fat32 partition visible. The boot partition only has to hold the ‘grldr’ and the ‘menu.lst’ file, so we set its size to 1 cylinder (or a little less if we take the first 95 boot sectors into account). The last sector of the first partition is 1*255*63-1 = 16064.

We use fdisk to set up the geometry of the device and make the first partition. Replace $num_cyl and $last_sector with the appropriate values.

fdisk /dev/sdb << EOF

6) At this point, remove the usb device and plug it back in. The final layout should look like this:

fdisk -lu /dev/sdb

Disk /dev/sdb: 1031 MB, 1031798272 bytes
255 heads, 63 sectors/track, 125 cylinders, total 2015231 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0x8d7751c5

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *          95       16064        7985  83  Linux
/dev/sdb2           16065     2008124      996030    c  W95 FAT32 (LBA)

7) Create the filesystems:

mke2fs -L boot /dev/sdb1
mkdosfs -F 32 -n data /dev/sdb2

8) As root, make a temporary working folder. Download the latest grub4dos and install boot code on the first partition:

mkdir usbtemp
cd usbtemp
wget http://download.gna.org/grub4dos/grub4dos-0.4.4-2009-06-20.zip
unzip grub4dos-0.4.4-2009-06-20.zip
cd grub4dos-0.4.4
./bootlace.com --floppy=0 /dev/sdb1

9) Extract the first 96 sectors and create the triple MBR:

dd if=/dev/sdb of=boot.img bs=512 count=96
./bootlace.com boot.img
dd of=/dev/sdb if=boot.img bs=512 count=96

10) Mount the boot partition and copy the necessary grub4dos files:

mkdir /mnt/usbboot
mount /dev/sdb1 /mnt/usbboot/
cp grldr /mnt/usbboot/

11) As a test, we’ll boot the SliTaz LiveCD from the usb device. The iso will be saved to the second partition, and an entry in the ‘menu.lst’ file on the boot partition will make the iso available for booting.

mkdir /mnt/usbdata
mount /dev/sdb2 /mnt/usbdata
mkdir /mnt/usbdata/images
cd /mnt/usbdata/images
wget http://mirror.switch.ch/ftp/mirror/slitaz/iso/2.0/slitaz-2.0.iso
cd /mnt/usbboot/
umount /dev/sdb2
cat > menu.lst << EOF
title Boot SliTaz 2.0 LiveCD
find --set-root /images/slitaz-2.0.iso
map --mem /images/slitaz-2.0.iso (0xff)
map --hook
chainloader (0xff)
umount /dev/sdb1

12) This should do it… To clean up just remove the ‘usbtemp’ folder.

Hello world!

Welcome to this blog. We’re two phd students maintaining a bunch of computers in the lab. This blog just serves as our notebook. Instead of wondering “how the hell did we solve this last time” each time something goes wrong, we’ll just post it here. If you find these posts useful, let us know in the comments.