Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

When using the epslatex terminal, I always have to use the width command as well as \hspace to get the LaTeX generated key labels properly aligned. Is there any way of getting this to work automatically? For example, I just wanted to use a key with two columns, but it was impossible to get it lined up properly (the first column would always overlap with the second).

Here is an example:

    set terminal epslatex colortext color standalone "phv" 12  header "\\bfseries"  
    set output "figtmp1.tex"

    set notitle
    set nokey
    set size 1,1      

    set origin 0,0

    set xlabel "{\\Large $x$}" 
    set ylabel "{\\Large $y$}"

    ti2 = "{\\large $S^{zz}_\\sigma(L/2)$}"
    ti4 = "{\\large $S^{xx}_\\sigma$}"

    set key Left top right vertical maxrows 1

    f1(x) = x**1
    f2(x) = x**2

    plot \
    f1(x) w lp lc rgb "red" t ti2,\
    f2(x) w l lt 2 lc rgb "dark-grey" t ti4

This produces a two-column, one-line key where the line sample of f1(x) extends into the second column belonging to f2(x). Also, the spacing between the label and the corresponding line sample is much too large (this can be adjusted using width).

A related formatting problem occurs for a regular (single-column) key:

    set key Left top right

The labels appear to be centred. How do I align the labels, for example, to the left without using the LaTeX command \hspace and determining the spacing needed by trial and error?

share|improve this question
add comment

1 Answer

Remarks

I adjusted a few things, to make it work:

  • Replace all "{...}" by '...', as wrapping things in {} can break your spacing in some cases.
  • Replace double-backslashes by single ones. (This only works, when your TeX code is included in '. It won't work for ").
  • Omitting the Left in set key Left top right. Honestly, I don't know what that even does.

Implementation

#!/usr/bin/env gnuplot

set terminal epslatex colortext color standalone 'phv' 12  header '\bfseries'  
set output 'figtmp1.tex'

set key top right vertical maxrows 1
set xlabel '\Large $x$' 
set ylabel '\Large $y$'

ti2 = '\large $S^{zz}_\sigma(L/2)$'
ti4 = '\large $S^{xx}_\sigma$'

f1(x) = x**1
f2(x) = x**2

plot \
f1(x) w lp lc rgb 'red' t ti2,\
f2(x) w l lt 2 lc rgb 'dark-grey' t ti4

Output

img

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.