Converting Latex to Markdown

I’m applying for a job, which requires me to submit a plain text version of my resumé. As I maintain my CV as a latex document, I wanted to find a simple way to convert it to Markdown format so that it will look good when cut/paste into the web browser.

I use pandoc all the time for document conversion, but I found that because of some heavy layout tweaks to make my CV look good (I’m not using a style file), the markdown produced using

pandoc cv.tex -o cv.md

is pretty gross.

After a bit of googling, I found out about the htlatex utility (found here, and it’s included with TexLive), and which does a fantastic job at converting Latex to HTML:

htlatex cv.tex "xhtml, mathml, charset=utf-8" " -cunihtf -utf8"

Then, use pandoc to convert from HTML to Markdown with:

pandoc cv.html -o cv.md

This leaves a few small things to clean up with further scripting (such as stray /s), but altogether a nice looking Markdown file.

Advertisements

2 thoughts on “Converting Latex to Markdown

  1. clarkrichards Post author

    Note: the stray “\”s can be taken care of with our good friend sed, by doing something like:

    sed 's/\\//g' cv.md > cv_final.md
    

    I use a Makefile to run the commands, for which I specify a target like:

    html:
        htlatex cv.tex "xhtml, mathml, charset=utf-8" " -cunihtf -utf8"
    
    md:
        make html
        pandoc cv.html -o cv.md
        sed 's/\\//g' cv.md > cv_final.md
    
    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s