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 know how to create a legend in a pgfplots plot. See

Legend in tikzpicture


Using a pgfplots-style legend in a plain-old tikzpicture.

But I do not know how I can create a legend with two columns.

share|improve this question
Have you tried using \multicols environment inside your legend code? – Thanos Nov 3 '12 at 10:00
No, because I actually don't understand the code of the definition of the legend environment. – Jana Nov 3 '12 at 10:09
Try to enclose your \addlegendimages in a \multicols environment like \begin{multicols}{2} \addlegendimage \addlegendimage \addlegendimage \end{multicols} – Thanos Nov 3 '12 at 10:17
I can not get it to compile. – Jana Nov 3 '12 at 10:28
up vote 28 down vote accepted

Simply set the key legend columns=2.

Depending on what you need, you might also be interested in transpose legend and/or reverse legend.


in order to customize the legend's appearance, you can use legend style={<option list>} where <option list> can be any option which applies to a PGF \matrix. All these options can be found in the PGF manual. The one which is necessary here is the column sep key. We have to restrict it to the second column (unless we also want to customize the column separation between images and text).

Here is an example:



        legend columns=2, 
        legend style={
                    % the /tikz/ prefix is necessary here...
                    % otherwise, it might end-up with `/pgfplots/column 2`
                    % which is not what we want. compare pgfmanual.pdf
            /tikz/column 2/.style={
                column sep=5pt,
        \addplot {x};
        \addplot {x+4};


enter image description here

share|improve this answer
Is there a way to increase the space between the columns? Now the image of the 2nd column starts without space directly after the description of the item in the first column. – Jana Nov 3 '12 at 11:27
See my edit. It might better to add a further question in the future (will simplify searches for the follow-up question). – Christian Feuersänger Nov 3 '12 at 11:54

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.