Home

 

January 18, 2003

Line numbering your LaTeX documents

STEPHAN B÷TTCHERS LaTeX macros. Some journals like the ones published by the American Society for Microbiology, recommend manuscripts to be submitted with the lines of text numbered. I knew I hadn't have been the first person required to have this feature for LaTeX, so I did a google search and found one interesting site. Apparently Stephan Bottchers has written a style file that can be used by LaTeX to automatically generate a document with lines numbered. It's easy to use, just have a \usepackage{lineno} in the preamble; and where you want the line numbering to start in the document, you place a command like \pagewiselinenumbering and it starts at that page. Stephan also has a manual that explains the package in more detail.

Posted by johnvu at 01:33 AM | Comments (2)

January 17, 2003

Followup on LaTeX to HTML

developerWorks: Linux : Tip: Get to know your textutils. In my previous post of how to convert your LaTeX document to HTML, I talked about how to remove underlining of links in your HTML document by editing your style section. I also talked about how you can make tth specific macros which help in tagging superscript and subscript text. In this post, I'll be commenting on how to make that html document of yours just right after tth is finished with it, and automating this process.

My HTML document still wasn't cutting it after tth converted my LaTeX document to HTML. For example, my citations of my paper were bound by square brackets [] rather than parentheses. And tth annoyingly added & nbsp ; to areas in the HTML code that it thought required an actual space; however, a regular empty space would have been sufficient. My options were:
1. live with it
2. use emacs to search-and-replace the offending characters, strings, words
3. or automate the process with a sed script file
Well, needless to say, I chose the third option---I'm a sucker for automation (and less work on my part in the long run). Making a sed script file is not all that difficult. However, the resulting commands ended up looking like an alien language honestly and could have easily scare away casual users from even trying out sed. I duked it out and hacked something like this in the sed script text file:

#!/bin/sed -f
s/serif/Times New Roman, Times, serif/g
s/\[\(< a href="\#\)/(\1/g
s/\([0-9]<\/a>\)\]/\1)/g
s/\[\([0-9]*\)\]/\1./g
s/figures\/eps\_files\/\([a-z0-9\_\-]*\)"/figures\/\1.jpg"/g
s/< dl compact="compact">/\< table border=0 cellpadding=0>/g
s/< dt>/\< tr\>\< td valign=top\>/g
s/<\/dt>/\<\/td\>/g
s/< dd>/\< td\>/g
s/<\/dd>/\< p\>\<\/td\>\<\/tr\>/g
s/<\/dl>/\<\/table\>\
\
\< p\>/g
s/< hr \/>< small>[a-zA-Z0-9 ]*//g
s/T< sub>< font size="-1">[a-zA-Z0-9 ,]*//g
s/<\/font><\/sub>X//g
s/by < a href="http\:\/\/hutchinson\.belmont\.ma\.us\/tth\/">//g
s/<\/font><\/sub>H<\/a>\,//g
s/version[0-9 \.]*< br \/>[a-zA-Z0-9 \:\.,]*<\/small>//g
s/\(& nbsp;\)/ /g

Notice the first line: it tells the shell where to look for sed in my installation. Briefly, the commands take care of changing the square brackets of the citations to parentheses. It removes the tagline of the html page. And I added lines handling the changes that I mentioned in my previous post on converting LaTeX to HTML using tth. BTW, I run tth with the following options: "tth -e2 -n1 -w2 -V". -e2 tells tth to embed images rather than using links and URLs.

Running the sed script text file is not difficult. I changed ownership of the file to allow executing it (chmod 755 filename).

Running the LaTeX compilers individually each time was too tedious, it needed automation. So I turned to trusty old Makefile. I placed the following lines in my Makefile:

----------cut------------
# My makefile to automate compiling all necessary docs

TARGET = paper

all: ps pdf html php

ps: $(TARGET).tex
latex $(TARGET).tex
bibtex $(TARGET)
latex $(TARGET).tex
bibtex $(TARGET)
latex $(TARGET).tex
dvips $(TARGET).dvi -o $(TARGET).ps
ghostview $(TARGET).ps &

pdf: $(TARGET).tex
pdflatex $(TARGET).tex
bibtex $(TARGET)
pdflatex $(TARGET).tex
bibtex $(TARGET)
pdflatex $(TARGET).tex
acroread $(TARGET).pdf

html: $(TARGET).tex
tth -e2 -n1 -w2 -V $(TARGET).tex
bibtex $(TARGET)
tth -e2 -n1 -w2 -V $(TARGET).tex
bibtex $(TARGET)
tth -e2 -n1 -w2 -V $(TARGET).tex
./tthpostproc.sed $(TARGET).html > index.html

php: header.php footer.php $(TARGET).tex
tth -r -e2 -n1 -w2 -V $(TARGET).tex
bibtex $(TARGET)
tth -r -e2 -n1 -w2 -V $(TARGET).tex
bibtex $(TARGET)
tth -r -e2 -n1 -w2 -V $(TARGET).tex
cat header.php > index.php
./tthpostprocraw.sed $(TARGET).html >> index.php
cat footer.php >> index.php

tidy:
rm -f *~

clean:
rm -f *~
rm -f *.aux *.log *.toc *.lof *.lot *.bbl *.blg *.out *.brf

----------end-----------

When I want to compile, I type "make ps" at the commandline and it just works. Same goes for html "make html", etc. Just change "paper" to the name of the LaTeX document. Or if I want to compile everything, I do a "make all." Linux is nice eh? In Winblows, I'd have to write a batch file to automate compiling; however, good luck in trying to find a program for text stream editing installed by default in windows (like sed).

More on my LaTeX publishing system later.

Posted by johnvu at 02:04 AM | Comments (0)

January 10, 2003

Making a favicon.ico with free software

png2ico - PNG to icon converter (Linux,GNU,Windows,Unix). For a while, I had a favicon for my site, but it was in PNG format. I made it using The Gimp. Mozilla worked well in showing it, but Internet Exploder wouldn't show it in the bookmarks. I thought I had to resort to using Icon Editor in MS Windows, until I stumbled upon this great program. It's not only written in Unix, but also has a DOS/Windows version! It works well, I just have to figure out a nice design.

Did I mention how much better Mozilla is than IE? I finally learned how tabbed browsing worked. For those of you who don't know what I mean, hit -t and find out what I mean (that is, if you're using Mozilla). I also went into the Preferences menu to disallow unauthorized window opening--no more pop-up ads! Lastly, for some of the most CPU-intensive, annoying animated ads, I disallowed images to be served from certain sites by right-clicking the picture and choosing that option.

BTW, tomorrow's my son's one-month mark!

Posted by johnvu at 12:14 AM | Comments (2)

January 09, 2003

LaTeX to HTML conversion of my paper

TTH: the TEX to HTML translator. I needed a break from my editing/writing/re-edit positive feedback loop. So I figured, why not write more in my blog? While writing my first paper in LaTeX, I suddenly worried about having it in MS Word format for the slaves to Gates at work. Good thing someone on the pybliographer list suggested I try TTh. It does a fairly exceptional job in converting my LaTeX document to HTML format, which I can open in OpenOffice and convert to MS Word (95 or 97) format. The problems I was having, though, were:

1. Incorrect handling of my \superscript and \subscript LaTeX macros.
2. Didn't use the textcomp package as I had hoped it would for the \textdegree\ command which would show my temperatures as 37° C, and not 37 C.
3. Created links for graphics called on \includegraphics, and not as in-line graphics.
4. BibTeX works too well, with hyperlinks to my references, but the links are in blue and underlined--not what you want if you need to convert to Word format, since that formatting is retained.

Delving into the TTh manual and man pages, I learned how to tweak my LaTeX files (in the preamble) in order for TTh to work properly. The first was to create TTh specific macros that would handle \superscript and \subscript correctly. That meant putting lines like:

%%tth:\def\superscript#1{\special{html:< SUP >}#1\special{html:< /SUP >}}

in the preamble for TTh specific macros. The above line means that \superscript(2) will take number 2 and bind it with < SUP > and < /SUP >when converting to HTML.

For the second problem, a TTh specific macro also did the job:

%%tth:\def\textdegree{\special{html: & deg ;}}

For the third problem, I had to first use the command line switch -e2 to enable in-line graphics, and the used emacs to replace out the incorrect links to my images directory.

Lastly, I wanted to remove all underline formatting for all the links in my document. I could have done it the hard way by putting the text:

style="text-decoration:none"

to the a href HTML command, for each and every link. But by placing the lines:

A:link {text-decoration: none;}
A:visited {text-decoration: none;}

in the cascading style section, I was able to remove underlining for all my links. I guess I could also change the color with a color:#FFFFF.

The point of all this is that you can live without MS Windows and Office and still be able to publish/share your documents with those who are stuck in Bill Gates' box.

I also got my hands on a pendrive/mini-drive at work. It's actually a USB mini-drive called a KanGuru. I tried using it on the Mac (running OS 9.1) and it was recognized without requiring the addition of any drivers! Tried it on both machines at work running Win98, but had to install the included drivers (supposedly, win2k, Me, XP works without additional drivers). But, does it work on Linux Mandrake 9.0? It does, but you have to know what you're doing. In Mandrake 9.0, I didn't have to install any additional modules. Though I suspect, you MUST have usb-ohci or usb-uhci modules installed already, as well as scsi generic modules installed, but since LM 9.0 has these installed by default, I didn't need to do anything other than plug in the mini-drive/pendrive and locate it. Just as with any other drives, when they're installed you still need to "mount" it in a mount point/directory. So I made a /mnt/pendrive directory. Then I went searching for the device. Did a list of /dev/sd* and saw that I had /dev/sda, /dev/sdb, and /dev/sdb1. Hmmm.../dev/sdb1? That must be it. Did a quick "mount -t vfat /dev/sdb1 /mnt/pendrive" as root and voila!, I could access the mini-drive as root in /mnt/pendrive. I guess I could have mounted with permissions to regular users and not just root. Now, if only I had USB ports in my regular linux box (which runs on a dinky Pentium 133 by the way).

Posted by johnvu at 07:17 PM | Comments (0)

January 02, 2003

I was wrong

Slashdot does know a good story. Slashdot | Daily Digital Updates for Archaeology Site at Luxor. I've bettered my track record at slashdot! My submission got accepted.

Posted by johnvu at 02:05 AM | Comments (1)

January 01, 2003

Slashdot doesn't know good stories...

even if it bit them in the butt. First of all, HAPPY NEW YEAR! Anyhow, I was browsing through Google News and stumbled upon this article and thought it was worthy a Slashdot submission, as opposed to just my blog :). The bottom of the article mentioned an expedition team from Johns Hopkins going to Egypt and posting their work to a blog with digital pics on their website. That's some cool stuff right? I mean how often do you get daily news of an archaeological site (at an ancient temple in Luxor, Egypt no less). Well, my track record at slashdot has been poor. I've had 13 submissions rejected and only 3 accepted (if anyone out there has better numbers, either way, please let me know. I'd like to know if I'm an average guy or just someone who has no eye for catchy news).

Posted by johnvu at 02:23 AM | Comments (0)