In some of my plots the curve description in the legend is too long, making the legend going over the plot, even if the legend is placed as far away as possible. Therefore I want to have multiple lines in the legend, but

\addlegendentry{a\\ b} 

results in an error. Is there another way to do that?

  • Could you provide a MWE, please ? – flav Nov 26 '15 at 10:22
  • @flav: Is it still needed? – arc_lupus Nov 26 '15 at 10:36

By default, TikZ nodes do not allow line breaks, but if you add the align=<left/right/center> key you can use \\. Hence, you can modify the legend style as below.


      legend style={cells={align=left}}
    \addplot {rnd};
  • Yes, that solves the problem! – arc_lupus Nov 26 '15 at 10:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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