Bug/Issue Report: See here.
- I want to have an additional multi-line custom entry in the legend (
\addlegendentry). - Therefore, I follow Add custom entry into legend in pgfplot.
- I also want the legend to be left-aligned.
- Somehow, I need both (seemingly redundant) following lines to make it work:
legend style = {
cells = {align = left}, % When commented out then error occurs
},
legend cell align = {left},
- If I remove
cells = {align = left},the I get an error. - If I remove
legend cell align = {left},then the alignment is centered. - Can you recreate the problem? Is this a bug that I should report?
\documentclass[12pt,letterpaper,landscape]{article}
\usepackage{mathtools}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
legend style = {
cells = {align = left}, % When commented out then error occurs
},
legend cell align = {left},
]
% Plot A
\addplot{x^2 - x + 4};
\addlegendentry{$T_\text{R, I}$}
% ---
% https://tex.stackexchange.com/questions/204395/
\addlegendimage{empty legend}
\addlegendentry{
Line 1\
Line 2
}
\end{axis}
\end{tikzpicture}
\end{document}
Error Message
Missing } inserted. <inserted text> } l.27 \end{axis}


leftis equivalent tolegend style={cells={anchor=west}}" - from the manual. Does it work for you if you dolegend style = {cells = {align = left, anchor=west}}and removelegend cell align=left. – Torbjørn T. Mar 07 '22 at 23:21alignturns the node into a tabular; that is, the text inside the node is treated like a tabular. You don't see the effect sinceLine 1andLine 2are the same width.anchor=westaligns the entire node (tabular) inside the tikzpicture. – John Kormylo Mar 08 '22 at 18:34