Installing LaTeX
Visit The LaTeX project or install texlive:
sudo aptitude install texlive-latex-recommended texlive-pictures texlive-latex-extra
Tikz
Visit Examples for Tikz.
Examples
Convert tikz into images
A LaTeX file that uses tikz aimedto export images should look like this:
\documentclass[landscape,10pt]{article}
\usepackage[latin1]{inputenc}
\usepackage{ae}
\usepackage{amssymb}
\usepackage{url}
\usepackage{xspace}
\usepackage{tikz}
\usetikzlibrary{mindmap,trees}
\usetikzlibrary{shapes}
% set up externalization
\usetikzlibrary{external}
\tikzset{external/system call={latex \tikzexternalcheckshellescape -halt-on-error
-interaction=batchmode -jobname "\image" "\texsource";
dvips -o "\image".ps "\image".dvi;
ps2eps "\image.ps"}}
\tikzexternalize
\begin{document}
\tikzstyle{root concept}+=[concept color=red!60]
\begin{tikzpicture}
\end{tikzpicture}
\end{document}
Here is an example to construct a mindmap.
The script to compile this is as follows:
#!/bin/bash
# We have to make it an executable file by changing the permissions.
# chmod u+x compile-latex.sh
latex -shell-escape $1".tex" &
latex -shell-escape $1".tex" &
latex -shell-escape $1".tex" &
dvips $1".dvi" &
ps2pdf $1".ps"
Once a ps-file is generated, it can be converted into an eps-file:
ps2epsi source-figure0.ps target-figure0.eps
The eps-file can then be converted into a rasterized image file using Ghostscript
gs -dSAFER -dBATCH -dNOPAUSE -dEPSCrop -r600 -sDEVICE=pngalpha -sOutputFile=outputfile.png inputfile.eps
Bash script
This script is for compiling a latex file:
#!/bin/bash
# We have to make it an executable file by changing the permissions.
# chmod u+x compile-latex.sh
latex $1".tex" &
latex $1".tex" &
latex $1".tex" &
dvips $1".dvi" &
Once the permission of the file has been changed (in order to make it executable):
chmod u+x compile-latex.sh
It can be run like this:
./compile-latex.sh sourcefile
(the sourcefile has to be without the '.tex' extension)
Convert pdf, ps into images
Use ImageMagick, by installing:
sudo aptitude install imagemagick
Or alternatively (chosen method), use
ps2epsi filename.ps filename.eps
gs -dSAFER -dBATCH -dNOPAUSE -dEPSCrop -r600 -sDEVICE=pngalpha -sOutputFile=filename.png filename.eps
Compress a pdf file
If you have many graphics in your pdf file, you may want to increase th ecompression of your file. You can do this using ghostscript in command line:
gs -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pdfwrite -dCompatibilityLevel=1.3 -dPDFSETTINGS=/screen -dEmbedAllFonts=true -dSubsetFonts=true -dColorImageDownsampleType=/Bicubic -dColorImageResolution=144 -dGrayImageDownsampleType=/Bicubic -dGrayImageResolution=144 -dMonoImageDownsampleType=/Bicubic -dMonoImageResolution=144 -sOutputFile=small-output-file.pdf large-input-file.pdf