Posts Tagged ‘LaTeX’

Fun with LaTeX

Thursday, March 26th, 2009

So I have finally gotten my shit together and seriously started putting my ideas for the FS/OS course into writing. $DIETY knows cultivating those ideas has taken long enough…

I started out, as I usually do, with my trusty LaTeX template:

\documentclass[english,a4paper,utf8]{report}
\usepackage[utf8]{inputenc}
\usepackage{verbatim}
\usepackage[dvips,bookmarks=false]{hyperref}
\hypersetup{
    colorlinks=true,
    citecolor=black,
    filecolor=black,
    linkcolor=black,
    urlcolor=blue
}
\author{}
\title{}

\begin{document}
    \maketitle
    \tableofcontents
    \input{./00_chapters}
    \bibliographystyle{unsrt}
    \bibliography{./bibtex/ref}
\end{document}

I then proceeded to copy the old build-system which mra rigged for us while doing our bachelor thesis, and all seemed good and well, until I realized that the hyperrefs (i.e. supposedly clickable URLs) weren’t all that clickable. I was baffled. What had gone wrong?

Had I missed to install a required package? Why then had not rubber (which the build-system use)  died with an error? No, packages seemed fine.

Had I found a feature which Adobe Acrobat Reader possessed, but Evince didn’t? Nope, opening the pdf-file in didn’t yield a better result (only a slower result… jeebuz acroread is bloated…)

I knew that I had gotten clickable links to work in LaTeX-generated pdfs before, so what was different? Ah! It might be that I used mra’s old build-script, the one he wrote before learning about rubber. Ok, $ less bin/makedoci.sh told me all I needed to know. The relevant procedure in that file was:

  1. call latex
  2. call bibtex
  3. call latex
  4. call latex
  5. call dvips
  6. call ps2pdf

As it turns out, the new “rubberized” build-system called rubber with flags -d and -f (i.e. produce pdf output, and force compilation). At the same time I was following up another lead, trying to figure out the documentation for the hyperref package in CTAN. I may have spent too little time reading the actual content in there, but when I came over a list about drivers and \special commands, I started seeing some patterns.

rubber -d calls pdftex, and it might have just been easier to switch “dvips” in the hyperref configuration in the template, but then I’d have to check and possibly dig even deeper to find what the actual string to put in the configuration should be.

This was less attractive since I knew that the current template had worked before (using dvips). But that would involve finding out if rubber could pass through DVI, to PS, and then to PDF. Coincidentally, this is just what rubber -p does.

Which sortof create a really cute little circumstance, to create a pdf-file, you call rubber with the flags -p -d and -f.

PDF, rubber -p -d -f, get it? XD

Putting technologies to use in peculiar ways

Wednesday, March 4th, 2009

I just read a daily WTF and I can’t be sure why, possibly because they were generating invoices, an activity which my mind for some reason has been linked to PDFs, I had a flashback to term 5 at ITU, where our project group collected a bunch of data through a web-based questionnaire, and stored in a database.

Then there was the question about retrieving the information and presenting it in our document (a PDF, generated by LaTeX), which, if I remember correct, was done by me by ugly-hacking together a PHP-script which, depending on what script you called from the webserver, either presented you with a csv file, or a LaTeX formatted file. To be completely honest I guess stream would be the better description, which the browser interpreted as a file and rendered.

In any case, I have a little suspicion that this wasn’t one of the intended domains for PHP, but it did the job well nonetheless.

LaTeX hacking

Tuesday, February 17th, 2009

A friend of mine is currently writing his thesis, and is using LaTeX to do it (I would like to think that I had something to do with him chosing LaTeX over an ordinary word processor, but that remains to be discovered).

In any case, he has become increasingly good at groking it (somewhat better at it than me I might add), and since he doesn’t have a blog (I’m working on getting him to “see the light” there as well ;) ) and here are two issues which he encountered, and resolved on his own:

The first problem was that some of the document classes reset the counter on the footnotes for every chapter, which he didn’t want. The solution:

% no footnote counter reset
\usepackage{remreset}
\makeatletter \@removefromreset{footnote}{chapter}
\makeatother

The second problem was how to decrease the counter on an ordered list (for those few occasions when you want your list to start at 0 for instance):

\begin{enumerate}
\addtocounter{enumi}{-1}
\item{...}
\end{enumerate}

And there you have it.

Benefits of the Portable Document Format

Monday, June 11th, 2007

As my summer holiday started I found myself with the urge to promote the document preparation system LaTeX. But during drafting a post about it (which soon grew in my mind to a whole series of posts) I realized that all this work would be almost completely uninteresting to the majority of the people on the Internet since the majority runs Windows, and although LaTeX can produce other formats than pdf, these other formats are mostly irrelevant to the average Windows user.

The pdf format on the other hand, although not overly liked by the average Windows user, is at least a format that is well-known and available even to the most green of computer users.

So before I set out on my LaTeX promotion crusade I have to promote the portable document format.

I know why I didn’t like pdf before, and I am sure that the very same reason, or a permutation of it, is why people still doesn’t like pdf.

  • Why another frickin’ format? We already have Microsoft Word’s .doc, isn’t that enough?!
  • Building on the first point, this means one more program (Adobe Reader or whatever other pdf viewer you use) to install and keep up to date
  • It is sooo fun having your browser freeze up for a second or two every time you click on a link at a homepage, which turns out to be a pdf file

I felt all of this before, so what has changed?

First of all I started building web-pages. I wanted to be good at it, so I did my research, I went to the bottom with this fixation of linking to pdf files.

My first question was “Why not just link to another web page?”
The answer to this question was rather simple. Different web-browsers render the content in their own way. There is no way to achieve consistency, not to mention that it all to some extent also depends on whatever features the user has activated in his/her browser (Javascript and/or CSS may be turned off, as well as images)
Also, the very same thing applies should a user want to print the content. Since the browsers render the pages in their own way, the printed copy will reflect this.

“Great” I thought, “then why not link it to a Word document?”
This is where different systems enter the picture. I admit, many of these examples are more or less moot today, but back then they were very much a factor to consider. GNU/Linux does not have the Office suite, and as such have (had) no way of reading Word documents. Today this has somewhat been mitigated by the advent of projects like OpenOffice.org which more or less reliably can open and correctly render Microsoft Word documents.

But back then, and also today, not all systems can reliably read Word documents. Also, opening Word documents found on the Internet (at least if you are running Windows) is almost akin to begging to have your computer infected by viruses.

So clearly none of these two seemingly good alternatives would work. But there was still that small matter of creating pdf files. For that you needed Adobe Acrobat (the full program, not the Reader) and that cost money.
Of course, back then I didn’t have anything to put in a potential pdf file anyway, which I couldn’t readily present with html, so it mattered not.

Another thing that changed recently, but all the same made my views towards pdf even more positive, was that I myself changed operating system, from Windows to GNU/Linux.

This brought two things into my life. The lesser of the two was that I could no longer rely on the Word .doc format.

And the more important aspect, I began appreciating free and open source software (FOSS). This second aspect made me forcefully reject the .doc format from my life as best I could (not easy when the majority of the world uses it) but luckily I am still studying, and in this world of academia students come from different situations, have different backgrounds, experience, and run different systems. Most run Windows, some run GNU/Linux, and one or two run Mac.

It makes for a rather diverse environment. Which in turn means that the teachers/examiners must either be able to read every single format that each of these systems can produce (or at least a subset based on the most widely popular document format for each individual system) or require of the students to hand in each assignment and report in a standard format which exists across all (or at least most) systems.

Our teachers doesn’t do any of this, or rather, they adjust for the Windows crowd, and feel safe in the fact that the Mac and GNU/Linux crowd will behave. And of course we do. Since we can only reliably say that the teachers will have the ability to read documents from Windows users, we either have to produce Windows documents ourselves, or some document that can be read on a Windows system, which we can produce. PDF solves that.

In fact, I need not worry what system the teacher is on, because I can rest assured that my pdf will be readable. I can simply care less what system they are operating. Windows? Pdf works! Mac? Pdf Works! GNU/Linux? Pdf works! You start to see a trend here? ;)

And not only can they open and view the reports, it will actually look to them exactly as it looked to me when I reviewed the document before submission. Whatever settings they have, the margins won’t be changed (in turn changing the entire flow of the document and re-arranging graphics etc.)

Also, since pdf nowadays is an open standard, and aspiring to become ISO certified, from a libertarian perspective this is also great. Sure, Adobe is the “owner” of the technology, but this is still less of a vendor lock-in than say, using Microsoft Word and their proprietary formats.

The one drawback with pdf files is that you need some sort of editing software to have any hope of modifying them. These usually cost money.

But then again, this is where LaTeX comes into play…