## Posts Tagged ‘LaTeX’

### My Software Stack 2011 edition

Saturday, December 31st, 2011

I realize that I haven’t written my customary “software stack” post for this year yet. But hey, from where I’m sitting, I still have … 36 minutes to spare

I’ll be using the same categories as last year; system, communications, web, development, office suite, server, organization, and entertainment.

System

The OS of choice is still Archlinux, my window manager is still wmii, my terminal emulator is rxvt-unicode, upgraded by also installing urxvt-tabbedex.

My shell is still bash, my cron daemon is still fcron, and my network manager is wicd.

To this configuration I’ve added the terminal multiplexer tmux, and have lately found out just how useful mc can be. Oh, and qmv from the renameutils package is now a given part of the stack.

Communications

Not much change here, Thunderbird for email, Pidgin for instant messaging, irssi for IRC.

Heybuddy has been replaced by identicurse as my micro-blogging (identi.ca) client. Heybuddy is very nice, but I can use identicurse from the commandline, and it has vim-like bindings.

For Pidgin I use OTR to encrypt conversations. For Thunderbird I use the enigmail addon along with GnuPG.

This means that Thunderbird still hasn’t been replaced by the “mutt-stack” (mutt, msmtp, offlineimap and mairix) and this is mostly due to me not having the energy to learn how to configure mutt.

I also considered trying to replace Pidgin with irssi and bitlbee but Pidgin + OTR works so well, and I have no idea about how well OTR works with bitlbee/irssi (well, actually, I’ve found irssi + OTR to be flaky at best.

Web

Not much changed here either, Firefox dominates, and I haven’t looked further into uzbl although that is still on the TODO list, for some day.

I do some times also use w3m, elinks, wget, curl and perl-libwww.

My Firefox is customized with NoScript, RequestPolicy, some other stuff, and Pentadactyl.

Privoxy is nowadays also part of the loadout, to filter out ads and other undesirable web “resources”.

Development

In this category there has actually been some changes:

• gvim has been completely dropped
• eclipse has been dropped, using vim instead
• mercurial has been replaced by git

Thanks in no small part to my job, I have gotten more intimate knowledge of awk and expect, as well as beginning to learn Perl.

I still do some Python hacking, a whole lot of shell scripting, and for many of these hacks, SQLite is a faithful companion.

Doh! I completely forgot that I’ve been dabbling around with Erlang as well, and that mscgen has been immensely helpful in helping me visualize communication paths between various modules.

“Office suite”

I still use LaTeX for PDF creation (sorry hook, still haven’t gotten around to checking out ConTeXt), I haven’t really used sc at all, it was just too hard to learn the controls, and I had too few spreadsheets in need of creating. I use qalculate almost on a weekly basis, but for shell scripts I’ve started using bc instead.

A potential replacement for sc could be teapot, but again, I usually don’t create spreadsheets…

Server

Since I’ve dropped mercurial, and since the mercurial-server package suddenly stopped working after a system update, I couldn’t be bothered to fix it, and it is now dropped.

screen and irssi is of course always a winning combination.

nginx and uwsgi has not been used to any extent, I haven’t tried setting up a VPN service, but I have a couple of ideas for the coming year (mumble, some VPN service, some nginx + Python/Perl thingies, bitlbee) and maybe replace the Ubuntu installation with Debian.

Organization

I still use both vimwiki and vim outliner, and my Important Dates Notifier script.

Still no TaskJuggler, and I haven’t gotten much use out of abook.

remind has completely replaced when, while I haven’t gotten any use what so ever out of wyrd.

Entertainment

For consuming stuff I use evince (PDF), mplayer (video), while for music, moc has had to step down from the throne, to leave place for mpd and ncmpcpp.

eog along with gthumb (replacing geeqie) handles viewing images.

For manipulation/creation needs I use LaTeX, or possibly Scribus, ffmpeg, audacity, imagemagick, inkscape, and gimp.

Bonus: Security

I thought I’d add another category, security, since I finally have something worthwhile to report here.

I’ve begun encrypting selected parts of my hard drive (mostly my email directory) using EncFS, and I use my passtore script for password management.

And sometimes (this was mostly relevant for when debugging passtore after having begun actively using it) when I have a sensitive file which I for a session need to store on the hard drive, in clear text, I use quixand to create an encrypted directory with a session key only stored in RAM. So once the session has ended, there is little chance of retrieving the key and decrypting the encrypted directory.

Ending notes

That’s about it. Some new stuff, mostly old stuff, only a few things getting kicked off the list. My stack is pretty stable for now. I wonder what cool stuff I will find in 2012

:wq

### 2011w36 — 2011w37

Monday, September 19th, 2011

The regular readers might have noticed that there weren’t any weekly summaries the last two weeks, and the reason for this was a series of rather fortunate events which conspired to leave me with very little time or energy to compose a summary in.

Very shortly summarized, I have gotten a job at a pretty cool consulting company, and Wednesday (7th, week before last) was my first day at my assignment, quickly followed by an introduction day at my company, and a long weekend (Friday–Monday) conference trip to Barcelona.

So, a great big thank you to CoyPu, pesa, hesa, jonaso and razor for all your help in both acquiring the job, and keeping my spirits up. I really appreciate it.

There really isn’t much more to say, the previous week was filled with reading GPRS documentation and figuring out how an SGSN fits into it all, and I kindof suspect that the coming weeks will be equally devoid of cool stuff I’ve found, while I get myself settled at work.

hook’s suggestion to check out ConTeXt has begun rooting itself as I feel myself more and more drawn to exploring it. And I also believe the time have come for me to learn the LaTeX Beamer class in ernest.

To that end I have actually located what looks to be a rather good resource.

I have also begun seriously considering starting encrypting (parts of) my home partition, and have started looking at EncFS for that purpose.

pesa had some good ideas for how to integrate this into an auto-starting process. I’ll have to experiment a bit with that.

Finally, another tip from pesa was to replace ~/.Xdefaults with ~/.Xresources and in .xinitrc execute xrdb -m ~/.Xresources

:wq

### 2011w33

Sunday, August 21st, 2011

LaTeX

The adventures in LaTeX-land continues. Rikard didn’t want any page number displayed on the table of contents page, and after having tried a couple of different variants of \pagestyle{empty} and the likes we realized that for some reason that won’t work at all in the book-class. \pagenumbering{gobble}, however, seems to work in every class, but NOT inside the actual document (so I guess this means after having issued the first \chapter or \section command).

For the interested, I found the answer by searching and finding this post, which in turn lead me here.

I am toying with the idea of writing a small daemon which would create an RSS feed (or Atom or whatever is popular today, I don’t care) which I could then plug into feed2imap which I have on the server.

The idea then would be that I could write small monitoring scripts for whatever I wanted, check the temperature, check space on the disks, whatever, and have fcron execute these scripts every now and then, and the result of these scripts would be fed into the RSS daemon.

I haven’t thought this through yet at any rate, but I quite like the idea. We’ll see what comes of it

Revisiting my old friend Django

Grégoire (or as we like to call him, greg) began working on a Django implementation of the myConf concept, and I am helping out as best I can with it.

There were some template bugs which made the template overly complex which I am currently trying to iron out, and mostly the problem seems to boil down to that the input data to the template is stored in a way which makes access in the template harder than necessary.

So I’m attempting splitting the data up further, and using dictionaries as the overall structure, which of course meant that I needed to find how to iterate over a dictionary in Django.

I admit that it was quite some time since I read the Django docs, and had I done so I would eventually have found the solution, but google, as usual, beat me to finding the solution somewhere else.

The relevant parts are:

{% for key, value in dictionary.items %}{{ value }}{% endfor %}

A non-intrusive (but javascript-required) approach to comment spam filtering. It’s probably a good solution, but I don’t like forcing users to activate javascript in their browser.

This is just plain frakking disgusting.

Interesting, and well-documented, approach to combating email spam.

### 2011w27

Sunday, July 10th, 2011

Imagemagick hackery

This post outlines how to create an image containing text, using imagemagick. The comment made by Severin improved upon the original snippet by cropping the image to just fit around the text.

One could use this in a script if you just set the following variables: width, height, fontsize, text and filename. I could have added another variable for font, but that would have made the example code below less informative.

convert -size ${width?}x${height?} xc:transparent -font /usr/share/fonts/truetype/ttf-dejavu/DejaVuSansCondensed.ttf -fill black -pointsize ${fontsize?} -draw "text 0,${fontsize?} '${text?}'" -trim +repage${filename?}.png

LaTeX and variables

One of the neatest things about LaTeX (except for the automagic table of contents generation, ease of use when it comes to references, and never having to worry much about typesetting) is that it really is a markup language. A markup language where you can define your own “macros” (commands as they are called in LaTeX). And these commands can be just as simple or complex as you have the skill to make them.

So for instance, if you are writing something in LaTeX, and you find that you have to write the same thing over and over again, you could define a new command which prints that for you wherever you call the command (this of course relies on that what you are writing many times is longer than the name you give your command, otherwise it wouldn’t make much sense. Unless of course this something you are repeating, may be subject to change later, and you don’t look forward to doing a search / replace across the entirety of the document(s).

I remember that our group used this during a semester at ITU, but then I “rediscovered” it this Monday as I embarked on a small writing project, being unsure if I liked the names I’d given my characters.

So now I have a “characters.tex” file, which just defines a couple of commands. These commands, in turn, do little more than return the name I have currently given the character. characters.tex is then imported into the main file (“novel.tex“) and whenever I need to call a character by name, I just use the command I defined for that character.

This question over at Stackoverflow.com helped me with an answer:

\newcommand{\protagonist1}{Tony}

I.e. We call the command \newcommand which takes two arguments, whereof the first is the name of the new command (in this case \protagonist1) and a command body, what the new command should do, which, in this case simply is to output the string “Tony”.

Ok, protagonist1 sounds kindof silly, and perhaps I should have named the command nightclubOwnerFname instead, but that would have been a fingerfull to type.

What you take away from all this is that if I ever decide to rename Tony to… iunno, Mark? I will only have to change it in one place, the characters.tex file.

To include a file in LaTeX you use:

\input{characters}

Why the “.tex” from “characters.tex” should be omitted in the input command I have no idea about, but that’s how I learnt it, and it works. One day I should really sit down and figure that one out.

Finally, to use the command inside your text you just write your stuff, but instead of writing the name you call the command:

She looked at \protagonist1{} in disbelief.

That’s pretty much all there is to it. Ain’t LaTeX neat?

Creating diffs in git

I started looking into fugitive but hit a brick wall smack dab in the beginning of the adventure as I’m running Arch, and its version of git was just slightly newer than that of p4bl0.

Once I got fugitive running, I wanted to get it to handle markdown (i.e. parse the markdown marked up as a part of the process of generating the published html), which had some unintended consequences for the <title> tag (i.e. markdown had already parsed the first line in the file, which is used as the post title) and this resulted in <title><p>my post title here</p></title>… that ain’t so good

The upside to it was that I got to do a little digging around in code (which I need to get better at anyway) and I ended up solving that little problem (but that introduced a bug (yes, I suck, should’ve tested more first) but I have submitted another patch which should undo all my stupidity and make it right. This time I have done more testing ;))

BUT, it also meant that I needed to generate a diff that p4bl0 could use to patch fugitive. This blog post gave me all I needed to know, i.e.:

$git diff --no-prefix > patchfile Automatically mounting removable media in Arch Although it can be reckless to automount stuff (because you never know where that USB stick has been ;)) it can be nice (comfortable) to have it all done for you, and that’s where autofs can help you. Links http://make-everything-ok.com/ Update: fixed silly typo, thank you mina86 ### 2011w26 Sunday, July 3rd, 2011 How silly of me… I totally forgot to publish last weeks summary yesterday. So without further ado, only one day late: bashPhotoGallery I don’t know how I get myself into these things… all of a sudden I found myself needing a, reproducible, way of setting up a photo gallery, complete with thumbnails and affixing a content license to the images. When it comes to creating a batch of thumbnails, imagemagick is the tool to use. Accept no substitutes! I am also going through a little crush on markdown. Getting rid of UTM variables I am not all that fond of those UTM variables that some “services” tack onto their links in order to better track where people are coming from (I understand why they’d do it, but I have no interest in being tracked, even if all they want to know is whether or not their push to be visible on$SOCIAL_MEDIA_SITE_OF_THE_MONTH is successful.
I know that I by accident stumbled upon a blog post outlining how to get rid of them programmatically, and I also know that I for some reason or other couldn’t find it, but without being too paranoid, I can understand why Google might not want to help people find the knowledge to do that
In any case, I stumbled upon two resources for doing just that, but I think that was more due to dumb luck than any concentrated effort on my part, actually, it was quite by accident while looking for something else.

Bash is so cool!

I already knew about echo {A,B,C,D} (great in conjunction with mkdir -p, but I have realized that bash is cooler than that.
echo {A..D} delivers the same result, without the need to explicitly specify all of the chars I want expanded. Nice!

psquid had a rather interesting solution to blog comments. I’ll have to think more about this. I don’t know how I feel about letting some other party (even if it is as nice a party as identi.ca) host “my” comments, but it is totally worth considering.

Wednesday

All in all a pretty good day. Got to assist razor with both vim and LaTeX skills (the student has become the master, yay!), got some writing out of my head, and ended up doing a little Test-Driven Python hacking.

And although I was a bit sceptical about OlofB‘s pyTDDmon, especially about it blinking continuously, which could get really old really fast, at first, I have to say that it has kindof grown on me since.

### My software stack revisited – “Office suite”

Saturday, December 25th, 2010

Although there are free (as in freedom) “office suites” (LibreOffice) I don’t care much for them. Having said that, I do have LibreOffice installed, but that is out of the need to be able to read attachments people send me.

Instead, I have collected a few applications which perform similar tasks for me:

### Text

For text editing, vim obviously plays a part, although for writing (not editing) longer chunks of text I use PyRoom.

So what I end up with are plaintext files, which is not always the optimal option presentationally. This is where LaTeX comes into play.

All of a sudden, I have snazzy-looking PDFs instead of plaintext

Historically I haven’t used spreadsheets all that much, but as of late that has started to change. Calc (OO.org/LibreOffice) did the trick, so did gnumeric, but I like stuff that is light on resources. Lighter than gnumeric…

And that is where sc comes into play. It has its shortcomings, for instance, when saving to csv it saves the current value of any formula, instead of the formula itself.

### Presentations

There is a LaTeX class called Beamer, which, when compiled, creates a PDF suitable for presentations.

Of course, depending on the complexity of the presentation, a simple PDF (as created by LaTeX without Beamer) could do the trick, but Beamer adds elegance to the simplicity of an ordinary PDF.

There are two applications which comes to mind for presenting a PDF-based presentation: Evince and Impress!ve (which shouldn’t be confused with OO.org Impress.

Evince is an ordinary PDF-viewer, and Impress!ve is a Python-powered presentation tool with support for OpenGL and some rather nice effects and features.

### Database

I don’t particularly like Access, and I have never tried OO.org’s Base, but the idea of having a database contained in a single file always intrigued me, and for smaller applications it kind of begins to make sense.

Now, if we take that idea, of a database contained in a file, with a small library through which you interact with the database file, and we also think “lightweight”, we… well at least I did, end up with SQLite3.

The SQLite3 library has a CLI which means that even my shell scripts can interact with the database. And that is pretty frakkin cool.

### Calculator

Finally, what office suite would be complete without a calculator?

True, I do most of my calculations in a nearby ipython-terminal, but ever since I discovered qalculate, and the CLI version qalc, it has stuck with me.

Why? Because you can ask it to convert between currencies like this:

$qalc \$200 to SEK


Obviously this is only useful if you first let it fetch up to date exchange-rates from the web, but there is a setting for allowing it to do that automatically at the beginning of every program start.

:wq

### Prepending text to a bunch of files

Thursday, June 10th, 2010

Say you have a project, say it is LaTeX, and that you intent to publish the final product.

Say that you have an upcoming deadline, and you wish the publication to be printed and available at a rather fine conference.

Say that you enter that project late in the game, and (stupidly) don’t spend a thought on the source code license, because there are not much time left until the deadline.

And then, after the deadline, say that there are some people interested in said source code. Since the final product was published under a nice license, the intent was of course always to have the source code that way as well, it just… kindof, slipped between the chairs.

So there we are, source code without any license notice of any kind. What do?

Say you are lazy. Manually adding those two lines of license data, even if only to a meager count of 15 files, is a chore you’d rather avoid.

You might start experimenting with cat for instance something along the lines of

cat license somefile > somefile

You realize that that approach is full of fail, but, if you’re in luck, you work in a pretty cool place, and get to have pretty cool work buddies. Work buddies which are pretty good at wielding bash, and concoct stuff like:

for f in *.tex; do (cat license; cat $f) >${f}.new; mv ${f}.new$f; done

The result, finally, speaks for itself.

### Easy permission sanitizing using chmod

Thursday, June 3rd, 2010

Let’s say you have a web app, such as WordPress, and you have installed it on your own server. You are of course security conscious, so you wish to have the permissions set up correctly, no exceptions. this usually means 755 (rwxr-xr-x) for directories and 644 (rw-r–r–) for files.

The way I used to solve this, on every server I worked, I set up a small shell script (sanitize-perms.sh) along the lines of:

#!/bin/sh
TARGET=$1 find$TARGET -type f | xargs chmod 0644
find $TARGET -type d | xargs chmod 0755 This worked well, with one huge caveat: What if you, somewhere in that directory structure had a file which needed to be executable? I don’t know if such a case exists in WordPress, I’ve used that script on a couple of WP installations without any noticeable side-effects, but it’s obviously a flawed approach. I’ll side-track this post a bit, since it is relevant to the overall post, that I, through identi.ca, stumbled upon this blog post (which is awesome by the way, go read it!) about why LaTeX is so cool, and why it can be useful writing your résumé using it. Just by chance I continued into Dan’s code section, and long story short, I found some cool stuff in his .bashrc file. Most notably this little beauty: # sanitize - set file/directory owner and permissions to normal values (644/755) # Usage: sanitize <file> sanitize() { chmod -R u=rwX,go=rX "$@"
chown -R ${USER}.users "$@"
}

I personally, for some reason, have always tended more to the octal representation than the [ugo][+-=][rwx] syntax, but that single chmod line is so outstandingly brilliant that I am almost forced to switch.

In one fell swoop Dan’s command does what I need two commands (really, with the xargs and I suppose one new process per found file/directory to execute chmod, my script needs a lot of processes) to accomplish.

The magic happens in that capital X, which is defined in the chmod man-file as: “execute/search only  if  the file is a directory or already has execute permission for some user”.

Directories automatically receives the executable flag, and any file which already has it, maintains it. Bloody brilliant!

Many thanks to Dan for sharing his configuration files, one of these days I’ll have to follow his good example.

### My software stack

Friday, May 29th, 2009

A week or so ago I stumbled across this blog, which went almost instantly into my RSS feed, due not only to the name of a post which cracks me up (yes, I know my humor is off ;P) but also to the posts I found really interesting.

And then I came along this post which got me thinking about what software I ended up using towards the end of my bachelors. Or the software I have learned of since, but wish I’d known about earlier. I began to write a comment to her post, but realized that it would be too long, so I write here instead. All credit to Hazel though, since without her post I wouldn’t have been inspired to write this one.

My list, as compared to Hazels, will not be as well-rounded, it won’t necessarily fit every student the way her list do. Also, the software I list will only be guaranteed to work in GNU/Linux, as that is what I used in the final semesters, and have continued to use since.

First of all, a text editor. It doesn’t really matter which, just evaluate a bunch until you find one you feel comfortable with. Once you have found “the one” become intimate with it. Become a frakking Jedi-master at wielding it. I’m still a padawan-level user of Vim, but I’m getting there.

I say the same about web browsers, mail clients and instant messaging clients. Find a good one, learn as much as you can about it, and use it effectively. Firefox, Thunderbird and Pidgin are my preferred tools.

A bug-tracker, although often web based creating a need for a web server, can often provide more “good stuff” than just tracking bugs. Stuff like statistics, or, if you think outside the box you’d be able to track things other than bugs, which I guess it was issue-trackers does. Some of these also include a wiki-system, which makes establishing a project-specific knowledge-base kindof easy. In the one university project where we used such a system (and where I realized its potential) we used Trac.

A blogging-system with an RSS-feed capable of being filtered on tags or categories could be used to distribute status updates to other members of a group. That I’m using WordPress should be fairly obvious to all.

Use a version control system wherever and whenever possible. With the next two suggestions on the list, “wherever” will be a lot more commonplace than one might first believe, even for non-programmers. At the university we had access to SVN-servers, and also tried Mercurial, a distributed vcs. Mercurial stuck with me ever since.

From generic suggestions, let’s go specific.

I could encourage you to check out markup languages such as reStructuredText or Markdown, to find one which suits you best and to run with it. And since I’ve now written the terms you’d need to Google, you could do that, but I’ll simply recommend LaTeX. The reason for markup languages in general, and LaTeX specifically is that you can then store your information in one plaintext format (which makes it easy to manage in version control) and can then transform it to a slew of other formats as needed.

Most of the time we needed to hand in PDFs. LaTeX excels in that and manages all the typesetting stuff and (obvious) formatting. Which leaves you with more time to focus on the content. One could also either extend LaTeX with Beamer, to create presentations, or simply generate a PDF and run Impress!ve.

For diagrams, graphs and flowcharts or representations of state-machines, Graphviz would be my recommended way to go. Again using plaintext to control the content, again with the benefits of version control. Inkscape saves files in the SVG format (again, plaintext) which might be usable (especially since it can also save files as both PS and PDF)

If you need graphical representations of statistical data or other plots, matplotlib could be the way to go.

I personally don’t like managing things, or management-related stuff, but lately I have been haunted by the feeling that if I used management tools, even if I would only be managing myself and my pet projects, I could be more organized and efficient. So I have started looking at TaskJuggler. It is similar to Microsoft Project, with the largest difference being that… you guessed it, you code the project plan ;D. Plaintext yet again. And then you compile the plan and TaskJuggler attempts to verify that no resources have been double-booked.

Considering each piece in this list on their own, it might seem like a waste of time to exchange one software with another. I do find each of these softwares impressive in and on their own, but it is when they are put together, when all their strengths are combined, that you tend to get the most out of it.

The all plaintext approach I have tried, both in groupwork at the university, and later on my own, work rather well. That so many of the softwares on the list can be used to communicate and transfer information between parties is also intentional as without communication the chance of a successful project outcome diminish rapidly.

The last (bonus?) item on the list would be to recommend learning, at least superficially, a programming language which you could hack together small scripts with. Something which you could use to “glue” together the other parts. I adore Python, and many of the softwares listed above have python-bindings ready to use. Perl, Ruby and others, which elude me right now, would undoubtedly work equally well or better, but as with the text editor, pick a language you feel comfortable with, and rock on.

Thoughts? Questions?

### LaTeX, ligatures and grep

Thursday, April 16th, 2009

Having finally finished a long overdue paper, I thought I’d share a little knowledge, well, semi-knowledge/-ugly hack actually, that I have found useful while working on this paper.

I like justified text, I think it make the content look sharp. LaTeX seem to agree with me on that point, at least in the style I used (report). Justified text in LaTeX has one drawback however. Sometimes the letter spacing between certain letters become too small, resulting in what I surmise typographers call “broken ligatures”. The term “ligature” seem to simply  refer to a specific part of a letter. A broken ligature, then, would happen when the ligature in a preceding letter “floats into” the next one.

Justified text is sharp, justified text with broken ligatures… not so much. And LaTeX doesn’t seem to be fully able to handle this on its own, so manual intervention seem necessary. (It could of course just be that the version I use (texlive) is silly, but I recall having similar problems back in Uni while I used tetex)

In any case, ugly-hacking tiem!

### SEARCH

First priority: find all occurrences of potential broken ligatures.

One could visually (using the ole trusty eyeball mk.1) scan the generated document for imperfections. That takes a lot of time and there is a large risk that some occurrences “slip through”. Also, in some places the ligatures won’t be broken, because the text has a good fit on the row at present time. But then someone adds a word, a sentence, or just fix a grammatical bug, whatever, and the fit is not so good anymore.

Of course, it is wholly unnecessary to run this procedure until the document is “frozen” and won’t accept any more addition to it in terms of text. I ran it three times, one time before each “beta”/”release candidate” which I sent to some friends for critique/proof-reading/sanity checking, and then once more after having incorporated the input from my friends.

To identify potential trouble, grep is called in to find every instance of the character combinations which can break. In my experience, these combinations are “ff”, “fi” and “fl”.

\$ grep -rn f[fil] chapters/*.tex

Only lower-case letters seem to cause trouble, but that is an assumption I make. I could well see problems stemming from having an initial lower-case f, followed by an upper-case letter. I have never encountered this, so I don’t search for it, but as usual, ymmw.

Now I have a nifty little list with all occurrences of the letter sequences “ff”, “fi” and “fl”, nice! Now what?

### DESTROY

The solution should, preferably, be applied to nearly all instances of these sequences, so that a present “good fit” line, if modified, would just automagically work later on as well. This means that the solution should not screw up the formatting of the “good fit” cases, while kicking into action, iff the good fit turn bad.

The solution I use is “\hbox{}”. This is inserted between the characters (f\hbox{}f, f\hbox{}i, f\hbox{}l) What makes this ugly is of course that your LaTeX code is now littered with this… well umm… shit. This method will of course give your spell checker a nervous breakdown.

Now you are probably thinking that this is a non-issue, just create a small shell-script to use sed, and produce new files with the modified content, copy these files into a build directory and have the make script invoke that shell-script before invoking the build command.

There is a potential pitfall in that solution. My paper linked to a couple of websites, as in clickable hyperlinks inside the pdf. Imagine the fun that would be derived when sed would hit upon \url{http://www.openoffice.org/} and transform that into \url{http://www.openof\hbox{}f\hbox{}ice.org/}.

Making sed aware of the \url{} tag, and verbatim quotes (probably all of the quoting systems), and making it leave the content inside well enough alone is probably doable, but having my favorite text-editor to an interactive search/replace was the method I opted for.