Some Misc Notes

TikZ

You can use TikZ to draw diagrams using LaTeX-like commands. Note that “PGF” (portable graphics format) and TikZ are both part of the same project; the readme says that PGF is the TeX macro package and TikZ is the user-friendly syntax layer.

My goal here is to use TikZ to create a png file.

Prereqs

You’ll need to have graphicsmagick installed in order to convert the pdf (generated by pdflatex) to png.

apt install graphicsmagick

Install

apt install texlive-pictures      # this gets you tikz
apt install texlive-latex-extra   # this gets you standalone (LaTeX cls)

Hello World

Create a foo.tex file:

\documentclass[border=0.5cm]{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\draw (0,0) -- (4,2);
\end{tikzpicture}
\end{document}

Process it:

pdflatex foo.tex  # creates foo.pdf
gm convert -density 300 foo.pdf foo.png

(See also the docs on gm convert. If you leave out the -density 300, resulting image will be smaller.)

And view the resulting png. You should see a diagonal line:

diag line

Links