Created
August 12, 2019 18:56
-
-
Save psaikko/1315f11b5c6bc1abefe7b20acfeb71b8 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