TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to place a lot of pictures and plots in a long document. By now, I am using figure-environment with center-environment, but the tikz-axis-plots didn't align well with included eps-pictures or tikz-pictures. I read PGFplot to occupy full \linewidth, and aligned y=axis across tikzpicture and the pgfplot-Manual (regarding alignment), and found out, that I can use ylabel style={overlay} and yticklabel style={overlay}.

To be precise, the situation is better, but images are still not aligned well. I want the left and right border of the grid to be exacly above the other boxes. See my example for illustration.

Thanks in advance.

    \documentclass{scrartcl} % Dokumentenklasse
    \usepackage[decimalsymbol=comma]{siunitx} % SI-Einheiten einheitlich setzen

    \usepackage{pgfplots,pgfmath} % Import der Plots aus Matlab
    \usepackage{tikz} % Import der Plots aus Matlab
    \usetikzlibrary{plotmarks} % Import der Plots aus Matlab
    \newlength\fheight % Plots aus Matlab immer gleich gross
    \newlength\fwidth % Plots aus Matlab immer gleich gross
    \setlength\fheight{6cm} % Plots aus Matlab immer gleich gross
    \setlength\fwidth{8cm} % Plots aus Matlab immer gleich gross
    \pgfplotsset{ % Komma statt Punkt als Dezimaltrennzeichen
      x tick label style={/pgf/number format/use comma},
      y tick label style={/pgf/number format/use comma}}


    scale only axis,
    xmin=0, xmax=15,
    ymin=0, ymax=200,
    ylabel style={overlay},
    yticklabel style={overlay},

    \addplot [
    only marks,
    mark options={solid,fill=green}
      \caption{Axis example}

    \begin{tikzpicture}[even odd rule,rounded corners=2pt,x=10pt,y=10pt]
    \filldraw[fill=green] (0,0) rectangle (\fwidth,\fheight);
      \caption{Size of the pictures}

share|improve this question
up vote 4 down vote accepted

What you are seeing the bounding box of the leftmost x (!) tick label: it shifts your axis to the right.

A possible solution is to use xticklabel style={overlay} as well.

However, my advice is to use

\begin{tikzpicture}[trim axis left, trim axis right]

which configures TikZ to 1. assume a following axis and 2. to skip everything left of that axis and right of that axis when it computes bounding boxes.

This approach is fairly new, and recent versions of pgfplots provide more documentation. The approach will automatically solve this kind of alignment problems (it even works together with image externalization).

share|improve this answer
Hello Christian, thank you very much for your answer. I found out, that my pgf-Version was outdated (tex.stackexchange.com/questions/15402/…). But with wiki.ubuntuusers.de/LATEX#Manuelle-Installation I was able to install the necessary files. – Lukas Aug 23 '11 at 6:20
Sounds good. If you believe that the answer solves your question, you can mark it as "answered" to close the thread. – Christian Feuersänger Aug 23 '11 at 17:07
Yes, the question is answered very well. The question can be marked as "answered" by someone who has the privilege. – Lukas Aug 31 '11 at 11:31

Your Answer


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.