Cairolatex

The cairolatex terminal device generates encapsulated PostScript (*.eps), PDF, or PNG output using the cairo and pango support libraries and uses LaTeX for text output using the same routines as the epslatex terminal.

Syntax:

     set terminal cairolatex
                    {eps | pdf | png}
                    {standalone | input}
                    {blacktext | colortext | colourtext}
                    {header <header> | noheader}
                    {mono|color}
                    {{no}transparent} {{no}crop} {background <rgbcolor>}
                    {font <font>} {fontscale <scale>}
                    {linewidth <lw>} {rounded|butt|square} {dashlength <dl>}
                    {size <XX>{unit},<YY>{unit}}
                    {resolution <dpi>}

The cairolatex terminal prints a plot like terminal epscairo or terminal pdfcairo but transfers the texts to LaTeX instead of including them in the graph. For reference of options not explained here see pdfcairo (p. [*]).

eps, pdf, or png select the type of graphics output. Use eps with latex/dvips and pdf for pdflatex. If your plot has a huge number of points use png to keep the filesize down. When using the png option, the terminal accepts an extra option resolution to control the pixel density of the resulting PNG. The argument of resolution is an integer with the implied unit of DPI.

blacktext forces all text to be written in black even in color mode;

The cairolatex driver offers a special way of controlling text positioning: (a) If any text string begins with '{', you also need to include a '}' at the end of the text, and the whole text will be centered both horizontally and vertically by LaTeX. (b) If the text string begins with '[', you need to continue it with: a position specification (up to two out of t,b,l,r,c), ']{', the text itself, and finally, '}'. The text itself may be anything LaTeX can typeset as an LR-box. 2#2rule{}{}'s may help for best positioning. See also the documentation for the pslatex (p. [*]) terminal driver. To create multiline labels, use 2#2shortstack, for example

  set ylabel '[r]{\shortstack{first line \\ second line}}'

The back option of set label commands is handled slightly different than in other terminals. Labels using 'back' are printed behind all other elements of the plot while labels using 'front' are printed above everything else.

The driver produces two different files, one for the eps, pdf, or png part of the figure and one for the LaTeX part. The name of the LaTeX file is taken from the set output command. The name of the eps/pdf/png file is derived by replacing the file extension (normally '.tex') with '.eps'/'.pdf'/'.png' instead. There is no LaTeX output if no output file is given! Remember to close the output file before next plot unless in multiplot mode.

In your LaTeX documents use '2#2input{filename}' to include the figure. The '.eps'/'.pdf'/'.png' file is included by the command 2#2includegraphics{...}, so you must also include 2#2usepackage{graphicx} in the LaTeX preamble. If you want to use coloured text (option colourtext) you also have to include 2#2usepackage{color} in the LaTeX preamble.

The behaviour concerning font selection depends on the header mode. In all cases, the given font size is used for the calculation of proper spacing. When not using the standalone mode the actual LaTeX font and font size at the point of inclusion is taken, so use LaTeX commands for changing fonts. If you use e.g. 12pt as font size for your LaTeX document, use '", 12"' as options. The font name is ignored. If using standalone the given font and font size are used, see below for a detailed description.

If text is printed coloured is controlled by the TeX booleans 2#2ifGPcolor and 2#2ifGPblacktext. Only if 2#2ifGPcolor is true and 2#2ifGPblacktext is false, text is printed coloured. You may either change them in the generated TeX file or provide them globally in your TeX file, for example by using

  \newif\ifGPblacktext
  \GPblacktexttrue
in the preamble of your document. The local assignment is only done if no global value is given.

When using the cairolatex terminal give the name of the TeX file in the set output command including the file extension (normally ".tex"). The graph filename is generated by replacing the extension.

If using the standalone mode a complete LaTeX header is added to the LaTeX file; and "-inc" is added to the filename of the gaph file. The standalone mode generates a TeX file that produces output with the correct size when using dvips, pdfTeX, or VTeX. The default, input, generates a file that has to be included into a LaTeX document using the 2#2input command.

If a font other than "" or "default" is given it is interpreted as LaTeX font name. It contains up to three parts, separated by a comma: 'fontname,fontseries,fontshape'. If the default fontshape or fontseries are requested, they can be omitted. Thus, the real syntax for the fontname is '{fontname}{,fontseries}{,fontshape}'. The naming convention for all parts is given by the LaTeX font scheme. The fontname is 3 to 4 characters long and is built as follows: One character for the font vendor, two characters for the name of the font, and optionally one additional character for special fonts, e.g., 'j' for fonts with old-style numerals or 'x' for expert fonts. The names of many fonts is described in http://www.tug.org/fontname/fontname.pdfhttp://www.tug.org/fontname/fontname.pdf

For example, 'cmr' stands for Computer Modern Roman, 'ptm' for Times-Roman, and 'phv' for Helvetica. The font series denotes the thickness of the glyphs, in most cases 'm' for normal ("medium") and 'bx' or 'b' for bold fonts. The font shape is 'n' for upright, 'it' for italics, 'sl' for slanted, or 'sc' for small caps, in general. Some fonts may provide different font series or shapes.

Examples:

Use Times-Roman boldface (with the same shape as in the surrounding text):

     set terminal cairolatex font 'ptm,bx'
Use Helvetica, boldface, italics:
     set terminal cairolatex font 'phv,bx,it'
Continue to use the surrounding font in slanted shape:
     set terminal cairolatex font ',,sl'
Use small capitals:
     set terminal cairolatex font ',,sc'

By this method, only text fonts are changed. If you also want to change the math fonts you have to use the "gnuplot.cfg" file or the header option, described below.

In standalone mode, the font size is taken from the given font size in the set terminal command. To be able to use a specified font size, a file "size4#4size5#5.clo" has to reside in the LaTeX search path. By default, 10pt, 11pt, and 12pt are supported. If the package "extsizes" is installed, 8pt, 9pt, 14pt, 17pt, and 20pt are added.

The header option takes a string as argument. This string is written into the generated LaTeX file. If using the standalone mode, it is written into the preamble, directly before the 2#2begin{document} command. In the input mode, it is placed directly after the 2#2begingroup command to ensure that all settings are local to the plot.

Examples:

Use T1 fontencoding, change the text and math font to Times-Roman as well as the sans-serif font to Helvetica:

   set terminal cairolatex standalone header \
   "\\usepackage[T1]{fontenc}\n\\usepackage{mathptmx}\n\\usepackage{helvet}"
Use a boldface font in the plot, not influencing the text outside the plot:
   set terminal cairolatex input header "\\bfseries"

If the file "gnuplot.cfg" is found by LaTeX it is input in the preamble the LaTeX document, when using standalone mode. It can be used for further settings, e.g., changing the document font to Times-Roman, Helvetica, and Courier, including math fonts (handled by "mathptmx.sty"):

     \usepackage{mathptmx}
     \usepackage[scaled=0.92]{helvet}
     \usepackage{courier}
The file "gnuplot.cfg" is loaded before the header information given by the header command. Thus, you can use header to overwrite some of settings performed using "gnuplot.cfg"