2

Quick and maybe easy question, did some research on my own but didn't lead anywhere... Is there a way to use a split or multline environment inside a pgfplot label? Maybe ditching the label altogether and replacing it with a minipage tikz node?

filippo
  • 598

1 Answers1

3

Use aligned, gathered or multlined. The latter requires mathtools, thw two former are also in plain amsmath. These can be used in inline math.

enter image description here

\documentclass[border=5mm]{standalone}
\usepackage{pgfplots,mathtools}
\pgfplotsset{compat=1.12}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xlabel={$\begin{aligned}a &= b \\ &= c\end{aligned}$},
ylabel={$\begin{multlined}a + b + c\\ + d + e + f\end{multlined}$}]
\end{axis}
\end{tikzpicture}
\end{document}

That said, if you add xlabel style={text width=7cm} you can also use align and similar directly. By putting a minipage in the xlabel you don't need to set the text width. E.g.

xlabel={%
\begin{minipage}{7cm}
\begin{align}
a &= b \\
  &= c
\end{align}
\end{minipage}}

The result is kind of ridiculous of course.

enter image description here

\documentclass[border=5mm]{standalone}
\usepackage{pgfplots,mathtools}
\pgfplotsset{compat=1.12}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xlabel style={text width=7cm,yshift=\abovedisplayskip},
xlabel={%
\begin{align}
a &= b \\
  &= c
\end{align}
}]
\end{axis}
\end{tikzpicture}
\end{document}
Torbjørn T.
  • 206,688