The Lumber Room

"Consign them to dust and damp by way of preserving them"

Posts Tagged ‘latex

Converting old PS files (generated with LaTeX) to searchable PDFs

with 8 comments


A common (or at least, more common than it should be) scenario: you find a PostScript file of some paper, clearly written in (La)TeX, but which looks blurry on screen and you cannot copy any text. Converting to PDF with, say, ps2pdf does not help either. You curse the .ps format, and put up with the blurriness or print it out (where it looks fine) to read it.

Turns out it doesn’t have to be this way. The problem is that the PS file is using bitmap fonts, but assuming you have the scalable (Type 1) versions of those same fonts on your system, you can convert the fonts! There’s a script called pkfix, distributed with TeX Live, which will take a ps file that uses bitmap fonts and try to convert it to use scalable fonts. Just run it as


This should produce a PS which isn’t blurry and is searchable, but if you prefer PDF, the usual way will work


or on Mac OS X if you don’t have ps2pdf for some reason, o -a macps2pdf where macps2pdf comes with MacGhostView.

If the file is very old (generated with dvips from before 1996) and pkfix doesn’t work, there’s a further script called pkfix-helper that may make the file appropriate for pkfix.

BTW, if it’s your own files that are coming out blurry, something is wrong with your setup. Just install the package cm-super from CTAN—sudo tlmgr install cm-super or whatever—and no other change is needed. Or you can use the lmodern fonts with \usepackage{lmodern}, but that shouldn’t be necessary.


Written by S

Thu, 2011-05-05 at 11:42:30

Posted in compknow

Tagged with , ,

A nice theorem, and trying to invert a function

with one comment

[Inspired by N, my first use of LaTeX on this blog… and it’s not as much of a pain as I had thought it would be.]

Here’s a nice theorem (“Levy–Desplanques theorem”):
Given a n \times n matrix A, if for every row i, \left|a_{ii}\right| > \sum_{j \ne i}\left|a_{ij}\right|, then \det A \ne 0.

It’s quite easy to prove: Suppose \det A = 0, then there exists a vector x = (x_1,x_2,\dots,x_n) such that Ax = 0. Pick a coordinate x_r that has maximum magnitude (i.e., let r \in \arg \max_{i}{|x_i|}). Then look at row r. We have a_{rr}x_r + \sum_{j \ne i}{a_{rj}x_j} = 0, so |a_{rr}||x_r| = \left|\sum_{j \ne i}{a_{rj}x_j}\right| \le \sum_{j \ne i}{|a_{rj}||x_j|} \le \left(\sum_{j \ne i}{|a_{rj}|}\right)|x_r|, which is a contradiction.

This theorem has apparently been discovered and rediscovered many times. According to Wikipedia:

This result has been independently rediscovered dozens of times. A few notable ones are Lévy (1881), Desplanques (1886), Minkowski (1900), Hadamard (1903), Schur, Markov (1908), Rohrbach (1931), Gershgorin (1931), Artin (1932), Ostrowski (1937), and Furtwängler (1936).

Olga Taussky has written a short paper on “A Recurring Theorem on Determinants“, in which she mentions 25 references. (This was in 1949… it’s probably been rediscovered a lot of times since.)

Applying this theorem to |A-\lambda I| gives us the Gershgorin circle theorem: For a matrix A, let R_i be \sum_{j \ne i}\left|a_{ij}\right|, then for any eigenvalue \lambda, there exists an i such that |\lambda-a_{ii}| < |R_i|.
That is, consider discs D(a_{ii},R_i) centred at a_{ii} and of radius R_i. Then every eigenvalue lies inside one of these “Gershgorin discs”.
(This theorem can also be proved directly in a similar way, in which case the original theorem follows directly.)

Where I encountered this: In an economics paper, where we have a function that is a demand system. That is, there are n (substitutable) varieties of a product, and the demand for each product is a function of all the n prices. So for a given vector of prices, there is a vector of demands, thus we have a function g: \mathbb{R}^n \to \mathbb{R}^n, such that g(p_1,p_2,\dots,p_n) is a vector whose ith component is the demand for the ith product when the prices are (p_1,p_2,\dots,p_n). In this case, it is “natural” to assume (rather not too implausible :-)) that in the Jacobian of this function (the matrix of partial derivatives whose (i,j)th entry is the partial derivative of the demand for the ith product with respect to the jth price), we have:

  1. J_{ii} < 0 : If you increase your price, fewer people will want it
  2. J_{ij} \ge 0 \text{ for } j \ne i: If someone else increases their price, you can expect to get at least a few converts to your product.
  3. \left|J_{ii}\right| > \sum_{j \ne i}\left|J_{ij}\right|, i.e. \sum_{j}{J_{ij}} < 0: If everyone increases their price, the total demand in the market does not go up. It also implies that the demand for your product depends more on your price than on everyone’s price put together!

Let’s look at the function f = -g instead, so that the three properties above say that J_f = -J_g has diagonal entries positive, off-diagonal entries nonpositive, and the positive dominant diagonal property in each row. It can be proved that any matrix with positive dominant diagonal property is a P-matrix, i.e., it has all principal minors positive. And there is a “global univalence theorem” due to Gale-Nikaido-Inada that a differentiable function defined on a rectangular region, whose Jacobian is a P-matrix at every point, is globally one-to-one. (So it is invertible if we ignore points outside its range.) (I see this theorem stated in the paper “The Jacobian matrix, global univalence and completely mixed games” by T. Parthasarathy and G. Ravindran — I vaguely remember TP mentioning something of this sort in class some time….)
So our demand system is globally invertible, and we can express the prices in terms of the demands. That was a lot of effort to get this!

Written by S

Wed, 2007-10-03 at 10:35:17

Posted in Uncategorized

Tagged with , ,

Online LaTeX

leave a comment »

Someone has collected a useful bunch of links: Using LaTeX in WordPress » Online LaTeX

(Pasted from somewhere, to be cleaned up –)

For typesetting mathematics, there is LaTeX, of course. But what does one do next with the LaTeX file, if you intend the document to be viewable online? Using PDF files for online viewing is frowned upon. There is simply nothing better than HTML, and so one might consider using latex2html. This, however, usually uses images for almost everything leading to huge files and slow-loading pages. Much better in this regard TtH, which tries to make the mathematics display in plain HTML by hook or by crook, but this ends up looking ugly and defeats what was probably one of the major goals in using LaTeX in the first place. One could use MathML — writing a MathML document by hand is absurdly painful, but there is TtM which can convert LaTeX to MathML. But MathML creates XML (not HTML) files, and thus doesn’t plug into general text easily; it also requires the user to have some specific fonts installed, etc., and if a browser (like IE6) fails to display it correctly, the result is a mess. I just discovered that there is ASCIIMathML, which seems to handle everything very well. LaTeX-style formulas work (one can also use their simpler language, it appears). It still needs the fonts to be installed and everything, but when it fails (if JavaScript is disabled, for example), the user will simply see the “source code” of the mathematical text, which can still be readable.

docbook? tex4ht?


Written by S

Mon, 2007-05-21 at 19:34:26

Posted in compknow

Tagged with , , ,

Collaborative work with LaTeX

with 5 comments

All things considered (after trawling through more than a dozen pages of Google results, that is), I’ve arrived at the conclusion that the best way [as of 2006-10-11] to work on LaTeX documents collaboratively is to use a CVS or Subversion repository, and let everyone commit changes to it.

There seems to be a MediaWiki plugin for collaborative LaTeX, but it needs some attention to security issues…

Someone asked around, and put up an extremely useful summary.

There’s a very short CVS tutorial here.

Update[2007-11-25]: For some reason, the PracTeX journal had three articles about LaTeX+Subversion in 2007-08: LaTeX Document Management with Subversion, Version Control of LaTeX Documents with svn-multi, and Subversion and TextMate: Making collaboration easier for LaTeX users. It’s a good idea to pick the simplest solution that works for you. I haven’t read those articles, but we did use LaTeX in a (somewhat) collaborative way (we weren’t sharing the work much, so it’s not clear the others saw any good in it) for two of our courses, here and here. The websvn interface is a bit crufty; we were using the commandline interface.

The work cycle was as below: (in case you’ve never used version control and don’t know what it is, this will show you that it’s simple after all!)

[Don’t use these URLs; they won’t work for you, of course.]

How to use the algcomp-notes subversion repository.

==Initial setup (only once)==
    svn checkout working-dir	

==Work cycle (each time)==
    svn update     # to get the latest version from the repository
Now work with your files as you usually would. After you're done, do:
    svn diff          #optional: to see what you have changed
    svn commit -m "some message, for the history"

Extra files you create in the directory are ignored. To add a new file, use:
    svn add [filename]

That’s all there is to it (apart from setting up — or getting someone to set up — the repository and access to it in the first place. Ask your sysadmin :-)

Update[2008-02-05]: Gobby is a collaborative text editor, and can be used with LaTeX, as this screenshot shows. Someone even wants to use Darcs’s Theory of Patches, and give it proper Undo etc… and at that point we are back to the version control solution, but with a good version-control system and a simple GUI for doing things.

Update[2008-03-25]: Here is a post by an actual mathematician using version control.

I do think it would be a great idea for someone to provide a version-control service for collaborative LaTeX documents over the internet. They could go further and make it easy to edit LaTeX in a browser, and we would have something along the lines of Google Docs.

Update [2009-10-03]: Some other things worth a mention: online LaTeX editors like MonkeyTex (but no one really likes editing in anything other than their familiar environment), a page at Wikibooks based on one of the PracTeX articles mentioned above, and, coming Real Soon Now, support for LaTeX in Google Wave.(link.)

Update [2010-05-11]: Some more things to mention: ScribTeX (see comments below), and LaTeX-lab, a plugin for Google Docs.

Update [2010-06-23]: Also see this Mathoverflow thread called Tools for Collaborative Paper Writing.

Written by S

Wed, 2006-10-11 at 20:50:53