Giter Club home page Giter Club logo

tikz2pdf's Introduction

tikz2pdf

TikZ is for print what D3 is for web. If you are unfamiliar with this nifty LaTeX package, then this gallery of examples will convince you to use TikZ for your next publication.

tikz2pdf is a command-line tool to aid you in creating beautiful figures. It's written in Python and (only) requires a working TeX system.

Basic Usage

Let's say we have a file named hello.tikz, which contains the following:

\begin{tikzpicture}
	\node[circle, draw=blue, dashed, thick, rotate=30, font=\Large] {Hello World!};
\end{tikzpicture}

Run tikz2pdf hello.tikz from the command-line in order to compile this into a PDF file named hello.pdf.

You can convert this PDF to PNG with ImageMagick:

convert -flatten -density 96 -quality 1000 hello.pdf hello.png

to get the following image:

Hello World!

Templates

Templates are useful for when you have many figures that need the same styling (i.e., LaTeX preamble). The following is the minimal template that is used when no template is specified:

\documentclass{article}
\usepackage{tikz}
\pagestyle{empty}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment[]{tikzpicture}
\PreviewEnvironment[]{tabular}
\begin{document}
%tikz2pdf-tikz
\end{document}

The string %tikz2pdf-tikz is replaced with the actual TikZ code. If the TikZ file contains "\documentclass" it is treated as a self-contained document and no template is used. So, the file examples/swan-wave-model.tex, which illustrates the SWAN wave model, can be directly converted to a PDF file:

tikz2pdf swan-wave-model.tex
convert -flatten -density 96 -quality 1000 swan-wave-model.pdf swan-wave-model.png

SWAN Model

Command-line options

From tikz2pdf --help:

positional arguments:
  TIKZ                  TikZ file(s)

optional arguments:
  -h, --help            show this help message and exit
  -b BIN, --bin BIN     binary to use for compiling (default: pdflatex)
  -d, --debug           print debug information
  -e, --edit            open TikZ file in default editor
  -i, --interactive     start interactive session (same as -evw)
  -c INCLUDE_DIR, --include-dir INCLUDE_DIR
                        additional directory to add to TEXINPUTS
  -n N, --number N      number of iterations to compile (default: 1)
  -o [PDF [PDF ...]], --output [PDF [PDF ...]]
                        output PDF file or directory (with trailing slash)
  -p, --pdflatex        use pdflatex as compiler
  -q, --quiet           suppress compiler output
  -t TEX, --template TEX
                        LaTeX file to use as template
  -v, --view            open PDF file in default viewer
  -w, --watch           recompile when TikZ file or template has changed
  -x, --xelatex         use xelatex as compiler

Configuration

tikz2pdf can also be configured by setting the following arguments in certain files: tikz2pdf-bin, tikz2pdf-include-directory, tikz2pdf-number, tikz2pdf-output, tikz2pdf-template, tikz2pdf-xelatex, tikz2pdf-pdflatex, and tikz2pdf-preview. See the previous section for their meanings.

These arguments can be set in a file called .tikz2pdf, which may be located in following directories (from low to high precedence): the home directory, the directory in which the TikZ file is, and the current working directory. Moreover, the TikZ file itself can also contain these arguments. The command-line has the highest precedence. So if, for example, ~/.tikz2pdf contains:

tikz2pdf-xelatex
tikz2pdf-number 2

Then all TikZ figures are by default compiled twice by XeLaTeX, unless these settings are overridden in .tikz2pdf files with higher precedence or in the command-line.

License

BSD

tikz2pdf's People

Contributors

shaharz avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

rvf0068

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.