Skip to content →

Category: web

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

Noncommutative algebra and geometry master-degree

The lecturers, topics and dates of the 6 mini-courses in our ‘advanced master degree 2011 in noncommutative algebra and geometry’ are :

February 21-25
Vladimir Bavula (University of Sheffield) :
Localization Theory of Rings and Modules

March 7-11
Hans-Jürgen Schneider (University of München) :
Nichols Algebra and Root Systems

April 11-12
Bernhard Keller (Université Paris VII):
Cluster Algebra and Quantum Cluster Algebras

April 18-22
Jacques Alev (Université Reims):
Automorphisms of some Basic Algebras

May 3-8
Goro Kato (Cal Poly University, San Luis Obispo, US):
Sheaf Cohomology and Zeta – Functions

May 9-13
Markus Reineke (University of Wuppertal):
Moduli Spaces of Representatives

More information can be found here. I’ve been told that some limited support is available for foreign graduate students wanting to attend this programme.

Leave a Comment

mathblogging and poll-results

Mathblogging.org is a recent initiative and may well become the default starting place to check on the status of the mathematical blogosphere.

Handy, if you want to (re)populate your RSS-aggregator with interesting mathematical blogs, is their graphical presentation of (nearly) all math-blogs ordered by type : group blogs, individual researchers, teachers and educators, journalistic writers, communities, institutions and microblogging (twitter). Links to the last 7 posts are given so you can easily determine whether that particular blog is of interest to you.

The three people behind the project, Felix Breuer, Frederik von Heymann and Peter Krautzberger, welcome you to send them links to (micro)blogs they’ve missed. Surely, there must be a lot more mathematicians with a twitter-account than the few ones listed so far…

Even more convenient is their list of latest posts from their collection, ordered by date. I’ve put that page in my Bookmarks Bar the moment I discovered it! It would be nice, if they could provide an RSS-feed of this list, so that people could place it in their sidebar, replacing old-fashioned and useless blogrolls. The site does provide two feeds, but they are completely useless as they click through to empty pages…

While we’re on the topic of math-blogging, the results of the ‘What should we write about next?’-poll that ran the previous two days on the entry page. Of all people visiting that page, 2.6% left suggestions.

The vast majority (67%) wants more posts on noncommutative geometry. Most of you are craving for introductions (and motivation) accessible to undergraduates (as ‘it’s hard to find quality, updated information on this’). In particular, you want posts giving applications in mathematics (especially number theory), or explaining relationships between different approaches. One person knew exactly how I should go about to achieve the hoped-for accessibility : “As a rule, I’d take what you think would be just right for undergrads, and then trim it down a little more.”

Others want rather specialized posts, such as on ‘connection and parallel transport in noncommutative geometry’ or on ‘trees (per J-L. Loday, M. Aguiar, Connes/Kreimer renormalization (aka Butcher group)), or something completely other tree-related’.

Fortunately, some of you told me it was fine to write about ‘combinatorial games and cool nim stuff, finite simple groups, mathematical history, number theory, arithmetic geometry’, pushed me to go for ‘anything monstrous and moonshiney’ (as if I would know the secrets of the ‘connection between the Mathieu group M24 and the elliptic genus of K3’…) or wrote that ‘various algebraic geometry related posts are always welcome: posts like Mumford’s treasure map‘.

5 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

NeB : 7 years and now an iPad App

Exactly 7 years ago I wrote my first post. This blog wasn’t called NeB yet and it used pMachine, a then free blogging tool (later transformed into expression engine), rather than WordPress.

Over the years NeB survived three hardware-upgrades of ‘the Matrix’ (the webserver hosting it), more themes than I care to remember, and a couple of dramatic closure announcements…

But then we’re still here, soldiering on, still uncertain whether there’s a point to it, but grateful for tiny tokens of appreciation.

Such as this morning’s story: Chandan deemed it necessary to correct two spelling mistakes in a 2 year old Fun-math post on Weil and the Riemann hypothesis (also reposted on Neb here). Often there’s a story behind such sudden comments, and a quick check of MathOverflow revealed this answer and the comments following it.

I thank Ed Dean for linking to the Fun-post, Chandan for correcting the misspellings and Georges for the kind words. I agree with Georges that a cut&copy of a blogpost-quoted text does not require a link to that post (though it is always much appreciated). It is rewarding to see such old posts getting a second chance…

Above the Google Analytics graph of the visitors coming here via a mobile device (at most 5 on a good day…). Anticipating much more iPads around after tonights presents-session I’ve made NeB more accessible for iPods, iPhones, iPads and other mobile devices.

The first time you get here via your Mac-device of choice you’ll be given the option of saving NeB as an App. It has its own icon (lowest row middle, also the favicon of NeB) and flashy start-up screen.

Of course, the whole point trying to make NeB more readable for Mobile users you get an overview of the latest posts together with links to categories and tags and the number of comments. Sliding through you can read the post, optimized for the device.

I do hope you will use the two buttons at the end of each post, the first to share or save it and the second to leave a comment.

I wish you all a lot of mathematical (and other) fun in 2011 :: lieven.

3 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

Lists 2010 : MathOverflow bookmarks

A few MathOverflow threads I bookmarked in 2010 for various reasons.

Leave a Comment