So I am trying to follow this this link to break up the text in two lines. Here is my code:
\documentclass[12pt]{article}
\usepackage{float}
\usepackage[margin=1in]{geometry}
\usepackage{tikz}
\usetikzlibrary{shapes, arrows.meta, automata, calc}
\begin{document}
\begin{figure}[H]\centering
\begin{tikzpicture}[node distance=2cm, >= Stealth, auto, shorten >= 1pt]
\node[state](L){$L$};
\node[state] at ($(L)+(60:4cm + 2.5em)$)(M) {$M$};
\node[state] at ($(M)+(-60:4cm+ 2.5em)$)(H) {$H$};
\path[->](L) edge node [sloped, above] {$S$ \newline $R\left(L, S, M\right) = -1$} (M);
\end{tikzpicture}
\end{figure}
\end{document}
Output:
I tried the \\ command, but I get an error. How to fix it and make sure that the text gets broken up in two lines?



\path[->](L) edge node [sloped, above, align=center] {$S$\\ $R\left(L, S, M\right) = -1$} (M);– Zarko May 28 '20 at 18:38\newline, nothing happened. How come? – Superman May 28 '20 at 18:41align=center. – May 28 '20 at 18:42