I'm using pgfplots, but i want to have my legends next to the plot.
This is easy by setting legend style and anchor. But i also want the plot to be as big as possible.
So if my labels are to long, they will not fit in the document.
See following code and plot:
\documentclass[a4paper,11pt]{article}
\usepackage{pgfplots}
\pgfplotsset{grid=both,width=\linewidth}
\begin{document}
\begin{tikzpicture}
\begin{axis}[legend style={at={(1.02,1)},anchor=north west}]
\addplot {x};
\addlegendentry{long long long long long long}
\addplot {x*2};
\addlegendentry{not long}
\end{axis}
\end{tikzpicture}
\end{document}
EDIT:
I have found a solution! there is a usepackage called tikzscale which makes it possible to use includegraphics with tikz. The usepackage need to be instaled first though, which I did through MikTex package manager
Here is an example on how it works:
first you make your plots in .tikz files:
temp.tikz
\begin{tikzpicture}
\begin{axis}[legend style={at={(1.02,1)},anchor=north west}]
\addplot {x};
\addlegendentry{short short}
\addplot {x*2};
\addlegendentry{not long}
\end{axis}
\end{tikzpicture}
temp2.tikz
\begin{tikzpicture}
\begin{axis}[legend style={at={(1.02,1)},anchor=north west}]
\addplot {x};
\addlegendentry{long long long long long long}
\addplot {x*2};
\addlegendentry{not long}
\end{axis}
\end{tikzpicture}
then include them to your .tex:
\documentclass[a4paper,11pt]{article}
\usepackage{pgfplots}
\usepackage{tikzscale}
\pgfplotsset{grid=both}
\begin{document}
\includegraphics[width=\linewidth,height=10cm]{temp.tikz}
\includegraphics[width=\linewidth,height=10cm]{temp2.tikz}
\end{document}


tikzcannot buy you larger paper... – jarauh Nov 27 '15 at 19:46