Thursday, February 16, 2017

Blogging from Overleaf

Using Overleaf as a blogging client

I use Overleaf for all my writing and presentations. I’d like to use Overleaf for blogging as well. I usually write my blog like posts in Medium but Medium cannot yet show posts that contain tables, figures, and citations. So, I was looking for a workflow that might be useful for bringing in the power of Overleaf and blogging where one can customize the appearance of the paper and share in an html format.
I suppose one can go in a number of directions. From the simple to a little more complex,
  • I can convert a LaTeXdocument I’d write in Overleaf to HTML and email the document to a Blogger or Wordpress site. That might be the easiest?
  • If I want a little more flexibility in terms of how I want the site to appear and tweak things, I can use Github to use Github pages to push and serve my article as a static file that people can read
  • An alternative way is to use static site generators and a web hosted solution such as Surge or Netlify to serve the paper.

Publishing an Overleaf Article as a blog post through Wordpress or Blogger

For this, you need the following:
  • An Overleaf Account (Free, you get 1 GB free space)
  • A Blogger or Wordpress Account.
  • An installation of Pandoc
  • An installation of Git
  • An Email Client
Here is a workflow for using Overleaf with blogger to set up blogging.
Go to blogger, set up an account if you do not have one, or select a blog where you want to work. Then set up your account so that you can email files to blogger directly and get published instantly. Here is a screenshot:

Configure blogger to set up your email address


Once you have set it up, you can write your post in Overleaf. Write posts in the LaTeXmarkup. In the main.tex file, input the file. Then, use git to clone the Overleaf article repository to your local repository.
git clone URL
Now you use Pandoc to generate the html from the LaTeXdocument, and the code is
pandoc -f latex -t html â€"filter pandoc-citeproc â€"bibliography sample.bib -o post1.html main.tex

Explanation of this code

  • pandoc is for invoking the pandoc programme
  • -f and -t are from and to, so from latex to html
  • filter: use it if you’d like to use a bibliography file and references, in this case the file name is sample.bib
  • -o is for output and give it a file name, in this case post1.html
  • main.tex is the name of the file that gets converted
In your blogging folder it will generate a file titled post1.html. If the image files, the bibliography files and the html files are then emailed to your blogger email address this will show up.

Issues

While this gives a quick workable solution for posts with few images, if you have to include a large number of images, this might work but quite cumbersome. An alternative approach would be to keep the images in the Web and use markdown to write your posts. This is where creating Jekyll sites powered by Jekyll-Pandoc and serving with Surge becomes quite a useful option, a topic I will turn to next.

No comments: