Skip to content

Instantly share code, notes, and snippets.

@mmha
Created September 13, 2016 22:06
Show Gist options
  • Save mmha/20b489ebdec0b72d65f5b94c6a5626a7 to your computer and use it in GitHub Desktop.
Save mmha/20b489ebdec0b72d65f5b94c6a5626a7 to your computer and use it in GitHub Desktop.
Render Latex and copy the image into the clipboard
#!/bin/sh
TEMPDIR=`mktemp -d --tmpdir=/tmp`
CURDIR=`pwd`
cd $TEMPDIR
echo "\documentclass[convert]{standalone}\begin{document}" > src.tex
echo $1 >> src.tex
echo "\end{document}" >> src.tex
pdflatex -shell-escape src.tex > /dev/null
cat src.png | xclip -selection c -t image/png
cd $CURDIR
rm -rf $TEMPDIR
# Usage: ./formula.sh "\(\frac{1}{2 \cdot \pi}\)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment