Tag Archives: LaTeX

Convert LaTeX to any output format easily

I use LaTeX to take notes, record TODO lists, the shopping and everything in between.

Oftentimes, I’ll need to copy my notes to somewhere: a wiki, this blog, or to put in an email. It’s at this point I need to quickly convert to my target format.

So, to satisfy the above, I wrote a wrapper script that takes a file name and corresponding target format for output (according to Pandoc):

#!/bin/bash
if [ $# -lt 2 ]; then
echo "Please provide a filename and output format compatible with pandoc"
exit 1
fi
pandoc -f latex -t $2 $1

Very simple. Like I said, take a file name and the pandoc output format and then pass it all to pandoc to convert the LaTeX original to a format of my choosing. Very handy!

LaTeX: coloured boxes with rounded edges

At the moment, I spend a fair amount of time documenting process, code, instructions, whatever; all in LaTeX. I love it.

At some point vanity seeps in. I like to tweak the visual elements here-and-there in order to have a more professional and visually appealing document.

In this particular instance I had exhausted my \subsubparagraphs and having played with various alternatives I decided I wanted a coloured box: much like you see in books for “tip” sections or asides. So I searched and searched the web and it transpires that the best route to follow is through the murky, uncharted (at least for me) depths of tikz! Thankfully it wasn’t that difficult, and I now get a lovely rounded, grey box!

Make sure you’ve got a \usepackage{tikz} and bear in mind this is using \documentclass{article}. Your mileage may vary!


begin{tikzpicture}
\node[fill=gray,rounded corners=5pt,text width=6in] {
This is a "tip" box or similar, that gets nice rounded edges; like you'd see in a real book!
};
\end{tikzpicture}

Basic LaTeX example

As part of my aspirations to become the best possible programmer I can be and as part of bringing new skills into my repertoire, I ventured into the land of LaTeX for documenting. Instead of writing in some made-up plain text format every time I write something down, I decided it would be sensible to use a proven interim format that’ll allow me to convert — easily, mind — into whatever format might be needed: markdown, HTML or wiki, for example.

So in steps LaTeX. On a murky Monday morning at my new job, I fire up gVim and find an example on the web. Two hours later I have documented the basics of the framework I’m coding for and can produce it in whatever format I need (and neatly, too). Suffice to say I’m hooked.

The hacker in me says “so you need a quick and easy way of producing skeleton LaTeX documents at the touch of a button or two”. In steps BaSH: I just echo this basic LaTeX document to stdout and be done with it:
\documentclass{article}
\usepackage{hyperref}
\begin{document}
\author{Alex Collins}
\title{}
\maketitle{}
\begin{abstract}
\end{abstract}
\section{Enter Section Name}
\end{document}

Now I’m always ready to go when needing the power and simplicity of LaTeX without having to remember the barebones.