I have a simple task, which I couldn't find a solution for so far.
I have a plot with 3 legend entries, 2 short ones, and a long one. I can use legend columns=2, to get a two-column legend but it looks like this:
aaaa ________________ bbbb
ccccccccccccccccccccc
What I like to have is:
aaaa ________ bbbb
ccccccccccccccccccccccccc
(I put the "_" for white space )
So, something like a multicolumn for a table used in a legend. Do you have any idea how to do that?
Thanks, Axel
Added at 12.04.21:
Sorry for not adding the mentioned minimal example: I prepared it as follows:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{tikz}
\usetikzlibrary{decorations, shapes, calc, backgrounds, shadings, arrows.meta, trees, positioning}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[%
width=.7\textwidth,
scale only axis,
clip = false,
legend columns=2,
legend style={ at={(axis cs:1.5,1.2)},
/tikz/column 2/.style={
column sep=5pt},
anchor=south},
]
\addlegendimage{area legend,fill=red, opacity = 0.5}
\addlegendimage{area legend,fill=gray, opacity = 0.5}
\addlegendimage{area legend,fill=green, opacity = 0.5}
\addplot[area legend, draw=black, fill=gray, fill opacity=0.5, forget plot]
table[row sep=crcr] {%
x y\\
1 0\\
2 0\\
2 1\\
1 1\\
}--cycle;
\node[align=center]
at (axis cs:1.5,0.5) {a};
\addplot[area legend, draw=black, fill=red, fill opacity=0.5, forget plot]
table[row sep=crcr] {%
x y\\
0 0\\
1 0\\
1 1\\
0 1\\
}--cycle;
\node[align=center]
at (axis cs:0.5,0.5) {b};
\addplot[area legend, draw=black, fill=green, fill opacity=0.5, forget plot]
table[row sep=crcr] {%
x y\\
2 0\\
3 0\\
3 1\\
2 1\\
}--cycle;
\node[align=center]
at (axis cs:2.5,0.5) {c};
\legend{short text 1, short text 2, looooooooooooooooooooooooooooooooooooooooog text};
\end{axis}
\end{tikzpicture}
\caption{Caption}
\label{fig:my_label}
\end{figure}
\end{document}

legendentriesthis answer (https://tex.stackexchange.com/questions/488793/pgfplots-legend-with-multiple-columns-and-rows-different-entry-widths?rq=1) could be helpful. – Excelsior Apr 10 '21 at 18:27\documentclass{...}and ending with\end{document}. – Rmano Apr 10 '21 at 18:34