Skip to content →

Tag: LaTeX

wp-latex’ sweet revenge : wp+MathJax-> ePub

In the early days of math-blogging, one was happy to get LaTeXRender working. Some years later, the majority of math-blogs were using the, more user-friendly, wp-latex plugin to turn LaTeX-code into png-images. Today, everyone uses MathJax which works with modern CSS and web fonts instead of equation images, so equations scale with surrounding text at all zoom levels.

However, MathJax has one downside : it doesn’t parse in ePub-readers. Peter Krautzberger wrote a post Epub and mathematics in which he suggested two methods to turn MathJax into ePub, but after dozens of experiments I still fail to reproduce these.

No doubt, someone will soon come up with a working alternative, but for the impatient here’s a quick but dirty method to turn your MathJax powered wordpress post into ePub :

the tools

  • download and install the ePub export plugin. It automatically creates an ePub file when a post or page is published or updated. The ePubs are stored in the uploads directory (to be found in the wp-contents directory).
  • download and install the wp-latex plugin. MathJax uses the normal \$ tex-delimeters whereas wp-latex requires \$latex, so this plugin doesn’t interfere with the default use of MathJax.
  • download the wp2latex python script. It converts a standard LaTeX file into a format that is ready to be copied into WordPress.

the routine

  • Edit the post you want to convert to ePub. Copy the contents of the post box to a file say post1.tex and save this in the same directory containing the latex2wp.py script.
  • In Terminal go to that directory and type the command ‘python latex2wp.py post1.tex’. It will produce a new file post1 in the same directory.
  • Copy the contents of post1 into the post box of your WordPress-post and press the update button. This time the TeX-commands in your post will be rendered using wp-latex and the ePub export-plugin will have created an ePub-version of it.
  • Locate this newly created ePub file in the relevant wp-contents/uploads/ folder (file has a number.epub name) and, if wanted, change its name into something easier to recognize and copy it somewhere outside the uploads directory. This will be your desired ePub-version of the post.
  • Replace the contents of the post box of your WordPress-post with the contents of the post1.tex file and hit the ‘Update’ button, to restore your original post (powered by MathJax).
  • Email your ePub-file to your iPad and open it with iBooks. Not quite as nice as MathJax-parsed TeX but a lot better than reading unparsed TeX-commands.
Leave a Comment

From WordPress to ePublishing (1)

Perhaps, the tips and tricks I did receive to turn a selection of wordpress-posts into a proper ePub-file may be of use to others, so I will describe the procedure here in some detail.

It makes a difference whether or not some of the posts contain TeX. This time, I’ll sketch the process for non-LaTeX posts and hence we will turn the Bourbaki-code posts into ePub-format to read on your iPad, rather than merely into a pdf-file as last time. Next time, I’ll add some tricks to repeat this when some of your posts do contain LaTeX.

1. Install the ePub export plugin

Get the epub export wordpress plugin, install and activate it in the usual way. ePub Export automatically creates an ePub file when a post or page is published or updated. The ePubs are stored in the uploads directory. For later use, remember that your uploads directories are located under BLOGHOME/wp-content/uploads.

2. Update the posts you want to include

Decide which posts you want to include in your eBook, edit them (or not) and press for each one of them the update-button. This will populate today’s uploads-directory with a number of epub-files. Transfer them all, for example using Transmit, to a directory on your home-computer, named say MyFirstEBook.



3. Unpack the epub-files

The crucial fact to remember about epub-files is that they are really zipped archives containing xhtml-, css- and other files and directories. As we want to edit some of those, we first have to unpack the directories. So, change the .epub extensions to .zip and double-click on them to create the directories.



The crucial files in each directory are preface.xhtml (containing title author and blog-name), text.html (containing the blog-post) and the images-directory (containing copies of all the images used in the post).

4. Rename the directories user-friendly

As all the posts will be chapters in our eBook in some specific order, we will rename the numbers of the directories to something more user-friendly such as shortened blog-titles. To do this, double-click in each of the directories on the preface.xhtml file. This will open Safari and will show the title of the blog-post. Use it to rename that directory. For convenience let us call the directory corresponding to the first chapter in our book MasterDirectory

5. Move all images to the master directory

For each of the other chapter-directories, drag all the files contained in the images-subdirectory to MasterDirectory/images.

6. Edit the MasterDirectory/text.xhtml file

Because we will have to open and copy-paste all the text.xhtml files of the different directories, it is perhaps best to rename momentarily the MasterDirectory/text.xhtml file to something like master.xhtml.

Now, open this file with a text-processor such as TextWrangler. Edit it to remove unwanted html-code (such as links to other posts at the start if you are using the series-plugin, or previous/next post links at the end). Also add the title of the blog-post between h1-tags (and if you want to include a table of contents later, give it an anchor-name).

Go to the directory of your second chapter, open that text.xhtml file and copy/paste only the post-content over to the master-xhtml file at the appropriate place. As before, add title/anchor before the copied post-content.

Repeat this procedure, in order, for all the chapters of your eBook.

Once finished, doubleclick the master.xhtml file and correct remaining errors (as it is an xhtml-file, it is rather picky about opening and closing tags) and see whether all your images are included. If you’re satisfied with it, rename the master.xhtml to text.xhtml (don’t forget this!).

7. Edit the MasterDirectory/preface.xhtml file

Open the preface.xhtml file and change the first blogpost-title to the title of your booklet, alter your name (by default it uses your wp-nick) and add a frontipiece-picture if you so desire.

8. Re-package the directory into an epub-file

This is the (only) tricky part. E-book readers require that the mimetype file is the first one in the zip document. What’s more, to be fully compliant, this file should start at a very specific point – a 30-byte offset from the beginning of the zip file (so that the mimetype text itself starts at byte 38).

Here’s how to do this on a Mac (Linux-users being the geeks they are will have given up on reading this post a while ago and as to Windows-users, yeah well …). Open Terminal.app and cd to your MasterDirectory. Now type:

zip -X MyFirstEBook.epub mimetype

Next, type:

zip -rg MyFirstEBook.epub * -x *.DS_Store

(of course you’ll have to change your book-title to whatever you want). If you want to know more about these 2 magical commands, read this post.

9. Edit metadata

Get Calibre and add the MyFirstEBook.epub to Calibre by clicking on the ‘Add Books’ button.



You can preview your eBook by clicking on the ‘View’-button. Next, click the ‘Edit metadata’-button and alter the title and author entries (and whatever else you want to include) and click the OK button. Then click ‘Save to disk’.

10. Read your eBook on your iPad

Finally, we want to see how it looks on the iPad. Mail MyFirstEBook.epub to yourself as attachement, open it with iBooks and enjoy!

Leave a Comment

eBook – ePub : comments

There were some great comments by Peter before this post was taken offline. So, here they are, once again.

4 Comments

eBook ‘geometry and the absolute point’ v0.1


In preparing for next year’s ‘seminar noncommutative geometry’ I’ve converted about 30 posts to LaTeX, centering loosely around the topics students have asked me to cover : noncommutative geometry, the absolute point (aka the field with one element), and their relation to the Riemann hypothesis.

The idea being to edit these posts thoroughly, add much more detail (and proofs) and also add some extra sections on Borger’s work and Witt rings (and possibly other stuff).

For those of you who prefer to (re)read these posts on paper or on a tablet rather than perusing this blog, you can now download the very first version (minimally edited) of the eBook ‘geometry and the absolute point’. All comments and suggestions are, of course, very welcome. I hope to post a more definite version by mid-september.

I’ve used the thesis-documentclass to keep the same look-and-feel of my other course-notes, but I would appreciate advice about turning LaTeX-files into ‘proper’ eBooks. I am aware of the fact that the memoir-class has an ebook option, and that one can use the geometry-package to control paper-sizes and margins.

Soon, I will be releasing a LaTeX-ed ‘eBook’ containing the Bourbaki-related posts. Later I might also try it on the games- and groups-related posts…

2 Comments

Penrose tilings and noncommutative geometry

Penrose tilings are aperiodic tilings of the plane, made from 2 sort of tiles : kites and darts. It is well known (see for example the standard textbook tilings and patterns section 10.5) that one can describe a Penrose tiling around a given point in the plane as an infinite sequence of 0’s and 1’s, subject to the condition that no two consecutive 1’s appear in the sequence. Conversely, any such sequence is the sequence of a Penrose tiling together with a point. Moreover, if two such sequences are eventually the same (that is, they only differ in the first so many terms) then these sequences belong to two points in the same tiling,

Another remarkable feature of Penrose tilings is their local isomorphism : fix a finite region around a point in one tiling, then in any other Penrose tiling one can find a point having an isomorphic region around it. For this reason, the space of all Penrose tilings has horrible topological properties (all points lie in each others closure) and is therefore a prime test-example for the techniques of noncommutative geometry.

In his old testament, Noncommutative Geometry, Alain Connes associates to this space a $C^*$-algebra $Fib$ (because it is constructed from the Fibonacci series $F_0,F_1,F_2,…$) which is the direct limit of sums of two full matrix-algebras $S_n$, with connecting morphisms

$S_n = M_{F_n}(\mathbb{C}) \oplus M_{F_{n-1}}(\mathbb{C}) \rightarrow S_{n+1} = M_{F_{n+1}}(\mathbb{C}) \oplus M_{F_n}(\mathbb{C}) \qquad (a,b) \mapsto ( \begin{matrix} a & 0 \\ 0 & b \end{matrix}, a)$

As such $Fib$ is an AF-algebra (for approximately finite) and hence formally smooth. That is, $Fib$ would be the coordinate ring of a smooth variety in the noncommutative sense, if only $Fib$ were finitely generated. However, $Fib$ is far from finitely generated and has other undesirable properties (at least for a noncommutative algebraic geometer) such as being simple and hence in particular $Fib$ has no finite dimensional representations…

A couple of weeks ago, Paul Smith discovered a surprising connection between the noncommutative space of Penrose tilings and an affine algebra in the paper The space of Penrose tilings and the non-commutative curve with homogeneous coordinate ring $\mathbb{C} \langle x,y \rangle/(y^2)$.

Giving $x$ and $y$ degree 1, the algebra $P = \mathbb{C} \langle x,y \rangle/(y^2)$ is obviously graded and noncommutative projective algebraic geometers like to associate to such algebras their ‘proj’ which is the quotient category of the category of all graded modules in which two objects become isomorphisc iff their ‘tails’ (that is forgetting the first few homogeneous components) are isomorphic.

The first type of objects NAGers try to describe are the point modules, which correspond to graded modules in which every homogeneous component is 1-dimensional, that is, they are of the form

$\mathbb{C} e_0 \oplus \mathbb{C} e_1 \oplus \mathbb{C} e_2 \oplus \cdots \oplus \mathbb{C} e_n \oplus \mathbb{C} e_{n+1} \oplus \cdots$

with $e_i$ an element of degree $i$. The reason for this is that point-modules correspond to the points of the (usual, commutative) projective variety when the affine graded algebra is commutative.

Now, assume that a Penrose tiling has been given by a sequence of 0’s and 1’s, say $(z_0,z_1,z_2,\cdots)$, then it is easy to associate to it a graded vectorspace with action given by

$x.e_i = e_{i+1}$ and $y.e_i = z_i e_{i+1}$

Because the sequence has no two consecutive ones, it is clear that this defines a graded module for the algebra $P$ and determines a point module in $\pmb{proj}(P)$. By the equivalence relation on Penrose sequences and the tails-equivalence on graded modules it follows that two sequences define the same Penrose tiling if and only if they determine the same point module in $\pmb{proj}(P)$. Phrased differently, the noncommutative space of Penrose tilings embeds in $\pmb{proj}(P)$ as a subset of the point-modules for $P$.

The only such point-module invariant under the shift-functor is the one corresponding to the 0-sequence, that is, corresponds to the cartwheel tiling

Another nice consequence is that we can now explain the local isomorphism property of Penrose tilings geometrically as a consequence of the fact that the $Ext^1$ between any two such point-modules is non-zero, that is, these noncommutative points lie ‘infinitely close’ to each other.

This is the easy part of Paul’s paper.

The truly, truly amazing part is that he is able to recover Connes’ AF-algebra $Fib$ from $\pmb{proj}(P)$ as the algebra of global sections! More precisely, he proves that there is an equivalence of categories between $\pmb{proj}(P)$ and the category of all $Fib$-modules $\pmb{mod}(Fib)$!

In other words, the noncommutative projective scheme $\pmb{proj}(P)$ is actually isomorphic to an affine scheme and as its coordinate ring is formally smooth $\pmb{proj}(P)$ is a noncommutative smooth variety. It would be interesting to construct more such examples of interesting AF-algebras appearing as local rings of sections of proj-es of affine graded algebras.

2 Comments

changes (ahead)

In view or recents events & comments, some changes have been made or will be made shortly :

categories : Sanitized the plethora of wordpress-categories to which posts belong. At the moment there are just 5 categories : ‘stories’ and ‘web’ (for all posts with low math-content) and three categories ‘level1’, ‘level2’ and ‘level3’, loosely indicating the math-difficulty of a post.

MathJax : After years of using LatexRender and WP-Latex, we’ll change to MathJax from now on. I’ll try to convert older posts as soon as possible. (Update : did a global search and replace. ‘Most’ LaTeX works, major exceptions being matrices and xymatrix commands. I’ll try to fix those later with LatexRender.)

theme : The next couple of days, the layout of this site may change randomly as I’ll be trying out things with the Swift wordpress theme. Hopefully, this will converge to a new design by next week.

name : Neverendingbooks will be renamed to something more math-related. Clearly, the new name will depend on the topics to be covered. On the main index page a pop-up poll will appear in the lower right-hand corner after 10 seconds. Please fill in the topics you’d like us to cover (no name or email required).

This poll will close on friday 21st at 12 CET and its outcome will influence name/direction of this blog. Use it also if you have a killer newname-suggestion. Among the responses so far, a funnier one : “An intro to, or motivation for non-commutative geometry, aimed at undergraduates. As a rule, I’d take what you think would be just right for undergrads, and then trim it down a little more.”

guest-posts : If you’d like to be a guest-blogger here at irregular times, please contact me. The first guest-post will be on noncommutative topology and the interpretation of quantum physics, and will appear soon. So, stay tuned…

2 Comments

Lists 2010 : StackExchange sites

One of the trends of 2010 was the proliferation of StackExchange sites. I guess by now most of us visit MathOverflow along with the arXiv daily. But, there are plenty of other StackExchange sites around that may be of interest to the mathematics-community :

“Opening a StackExchange site is damn hard. First you have to find at least 60 people interested in the site. Then, when this limit is reached, a large amount of people (in the hundreds, but it really depends on the reputation of each participant) must commit and promise to create momentum for the site, adding questions and answers. When this amount is reached, the site is open and stays in closed beta for seven days. During this time, the committers have to enrich the site so that the public beta (which starts after the first seven days) gets enough hits and participants to show a self-sustained community.” (quote from ForTheScience’s StackExchange sites proliferation, this post also contains a list of StackExchange-projects in almost every corner of Life)

The site keeping you up to date with StackExchange proposals and their progress is area51. Perhaps, you want to commit to some of these proposals

or simply browse around area51 until you find the ideal community for you to belong to…

Leave a Comment

Link problems : Markdown versus latex2wp.py

As John Baez (and hopefully others) noticed most links here on NeB are now screwed up.

For years I’ve used the Markdown syntax to include links in posts (that is something like [this is what you see](and here is the URL)). NeB used an older version ( Version 1.0.1k) of php Markdown to convert these to proper links (as I did have problems with the newer version).

Ever since the Return to LaTeX post, I’m trying to re-educate myself to write posts in LaTeX and convert them into wp-format using the Latex2WP python script.

Unfortunately this script doesn’t go together nicely with the Markdown-syntax, forcing me to go over the converted latex-file almost line by line fixing errors in order to be able to post. Not the time-saver I had in mind…

I hope to post a lot of new material once the semester finishes and therefore disabled the Markdown-plugin. This causes all links to remain in Markdown-format, which is a nuisance but, if you really want to follow the link it is still there for you to copy-paste. Depending on how exciting the christmas-break will be I’ll try to hard-code the links in some of the more popular posts.

If someone knows of an elegant solution, such as a micro-markdown wp-plugin only parsing links, please drop a comment.

UPDATE : I have downloaded the Markdown quicktags plugin. It replaces the standard HTML-editor of WordPress with a Markdown-editor. There is an option “Render” which transforms Markdown to HTML and then updating the post will save the HTML-version. This looks like a relative quick way to get my old post-links back. So far, I’ve rescued the posts of the last year, more later. Hopefully, this causes no overload in your RSS-aggregator…

3 Comments

Who was ‘le P. Adique’?

Last year we managed to solve the first few riddles of the Bourbaki code, but several mysteries still remain. For example, who was the priest performing the Bourbaki-Petard wedding ceremony? The ‘faire part’ identifies him as ‘le P. Adique, de l’Ordre des Diophantiens’.

As with many of these Bourbaki-jokes, this riddle too has several layers. There is the first straightforward mathematical interpretation of the p-adic numbers $latex \hat{\mathbb{Z}}_p$ being used in the study of Diophantine problems.

For example, the local-global, or Hasse principle, asserting that an integral quadratic form has a solution if and only if there are solutions over all p-adic numbers. Helmut Hasse was a German number theorist, held in high esteem by the Bourbaki group.

After graduating from the ENS in 1929, Claude Chevalley spent some time at the University of Marburg, studying under Helmut Hasse. Hasse had come to Marburg when Kurt Hensel (who invented the p-adic numbers in 1902) retired in 1930.

Hasse picked up a question from E. Artin’s dissertation about the zeta function of an algebraic curve over a finite field and achieved the first breakthrough establishing the conjectured property for zeta functions of elliptic curves (genus one).

Extending this result to higher genus was the principal problem Andre Weil was working on at the time of the wedding-card-joke. In 1940 he would be able to settle the general case. What we now know as the Hasse-Weil theorem implies that the number N(p) of rational points of an elliptic curve over the finite field Z/pZ, where p is a prime, can differ from the mean value p+1 by at most twice the square root of p.

So, Helmut Hasse is a passable candidate for the first-level, mathematical, decoding of ‘le P. adique’.

However, there is often a deeper and more subtle reading of a Bourbaki-joke, intended to be understood only by the select inner circle of ‘normaliens’ (graduates of the Ecole Normale Superieure). Usually, this second-level interpretation requires knowledge of events or locations within the 5-th arrondissement of Paris, the large neighborhood of the ENS.

For an outsider (both non-Parisian and non-normalien) decoding this hidden message is substantially harder and requires a good deal of luck.

As it happens, I’m going through a ‘Weil-phase’ and just started reading the three main Weil-biographies : Andre Weil the Apprenticeship of a Mathematician, Chez les Weil : André et Simone by Sylvie Weil and La vie de Simone Weil by Simone Petrement.


[abp:3764326506] [abp:2283023696] [abp:2213599920]

From page 35 of ‘Chez les Weil’ : “Après la guerre, pas tout de suite mais en 1948, toute la famille avait fini par revenir à Paris, rue Auguste-Comte, en face des jardins du Luxembourg.” Sylvie talks about the Parisian apartment of her grandparents (father and mother of Andre and Simone) and I wanted to know its exact location.

More details are given on page 103 of ‘La vie de Simone Weil’. The apartment consists of the 6th and 7th floor of a building on the Montagne Sainte-Geneviève. The Weils bought it before it was even built and when they moved in, in may 1929, it was still unfinished. Compensating this, the apartment offered a splendid view of the Sacre-Coeur, the Eiffel-tower, la Sorbonne, Invalides, l’Arc de Triomphe, Pantheon, the roofs of the Louvre, le tout Paris quoi…

As to its location : “Juste au-dessous de l’appartement se trouvent l’Ecole des mines et les serres du Luxembourg, avec la belle maison ancienne où mourut Leconte de Lisle.” This and a bit of googling allows one to deduce that the Weils lived at 3, rue Auguste-Comte (the W on the map below).

Crossing the boulevard Saint-Michel, one enters the 5-th arrondissement via the … rue de l’Abbe de l’Epee…
We did deduce before that the priest might be an abbot (‘from the order of the Diophantines’) and l’Epee is just ‘le P.’ pronounced in French (cheating one egue).

Abbé Charles-Michel de l’Épée lived in the 18th century and has become known as the “Father of the Deaf” (compare this to Diophantus who is called “Father of Algebra”). Épée turned his attention toward charitable services for the poor, and he had a chance encounter with two young deaf sisters who communicated using a sign language. Épée decided to dedicate himself to the education and salvation of the deaf, and, in 1760, he founded a school which became in 1791 l’Institution Nationale des Sourds-Muets à Paris. It was later renamed the Institut St. Jacques (compare Rue St. Jacques) and then renamed again to its present name: Institut National de Jeunes Sourds de Paris located at 254, rue Saint-Jacques (the A in the map below) just one block away from the Schola Cantorum at 269, rue St. Jacques, where the Bourbaki-Petard wedding took place (the S in the map).

Completing the map with the location of the Ecole Normale (the E) I was baffled by the result. If the Weil apartment stands for West, the Ecole for East and the Schola for South, surely there must be an N (for N.Bourbaki?) representing North. Suggestions anyone?

Leave a Comment

Return to LaTeX

To most mathematicians, a good LaTeX-frontend (such as TeXShop for Mac-users) is the crucial tool to get the work done. We use it to draft ideas, write papers and courses, or even to take notes during lectures.

However, after six years of blogging, my own LaTeX-routine became rusty. I rarely open a new tex-document, and when I do, I’d rather copy-paste the long preamble from an old file than to start from scratch with a minimal list of packages and definitions needed for the job at hand. The few times I put a paper on the arXiv, the resulting text resembles a blog-post more than a mathematical paper, here’s an example.

As I desperately need to get some math-writing done, I need to pull myself away from the lure of an ever-open WordPress admin browser-screen and reacquaint myself with the far more efficient LaTeX-environment.

Perhaps even my blogging will benefit from the change. Whereas I used to keep on adding to most of my tex-files in order to keep them up-to-date, I rarely edit a blog-post after hitting the ’publish’ button. If I really want to turn some of my better posts into a book, I need them in a format suitable for neverending polishing, without annoying the many RSS-feed aggregators out there.

Who better than Terry Tao to teach me a more proficient way of blogging? A few days ago, Terry announced he will soon have his 5th (!!) book out, after three years of blogging…

How does he manage to do this? Well, as far as I know, Terry blogs in LaTeX and then uses a python-script called LaTeX2WP ’a program that converts a LaTeX file into something that is ready to be cut and pasted into WordPress. This way, you can write, and preview, your post in LaTeX, then run LaTeX2WP, and post into WordPress whatever comes out.’ More importantly, one retains a pure-tex-file of the post on which one can keep on editing to get it into a (book)-publishable form, eventually.

Nice, but one can do even better, as Eric from Curious Reasoning worked out. He suggests to install two useful python-packages : WordPressLib “with this library you can control remotely a WordPress installation. Use of library is very simple, you can write a small scripts or full applications that allows you to automate publishing of articles on your blog/site powered by WordPress” and plasTeX “plasTeX is a LaTeX document processing framework written entirely in Python. It currently comes bundled with an XHTML renderer (including multiple themes), as well as a way to simply dump the document to a generic form of XML”. Installation is easy : download and extract the files somewhere, go there and issue a **sudo python setup.py install** to add the packages to your python.

Finally, get Eric’s own wplatex package and install it as explained there. WpLaTeX has all the features of LaTeX2WP and much more : one can add titles, tags and categories automatically and publish the post from the command-line without ever having to enter the taboo WordPress-admin page! Here’s what I’ve written by now in TeXShop

I’ve added the screenshot and the script will know where to find it online for the blog-version as well as on my hard-disk for the tex-version. Very handy is the iftex … fi versus ifblog … fi alternative which allows you to add pure HTML to get the desired effect, when needed. Remains only to go into Terminal and issue the command

wplpost -x http://www.neverendingbooks.org/xmlrpc.php ReturnToLatex.tex

(if your blog is on WordPress.com it even suffices to give its name, rather than this work-around for stand-alone wordpress blogs). The script asks for my username and password and will convert the tex-file and post it automatic.

5 Comments