-
-
Save holazt/4ee5f4bfe7d480232f208086a7a3ae44 to your computer and use it in GitHub Desktop.
Read LaTeX source from standard input, render to PNG and move to clipboard. Paste nice equations anywhere.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
tmpdir="$(mktemp -d)" | |
texfile="$tmpdir/tmp.tex" | |
echo "\documentclass[varwidth]{standalone} | |
\usepackage{amsmath,amsfonts,amssymb,amsthm} | |
\usepackage{color} | |
\usepackage[utf8]{inputenc} | |
\begin{document} | |
" > "$texfile" | |
cat >> "$texfile" | |
echo "\end{document}" >> "$texfile" | |
pdflatex -output-directory "$tmpdir" tmp.tex | |
pdftocairo -r 600 -png -transp -singlefile "$tmpdir/tmp.pdf" "$tmpdir/tmp" | |
xclip -selection clipboard -t image/png -i "$tmpdir/tmp.png" | |
rm -r "$tmpdir" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment