Question: How do I prevent the disappearance of backslash?

Consider the following:

MyTableElement1 := proc(L::list(nonnegint))
  ## L will have only two elements
  local M, x, y;
  M:=L;
  x:=convert(M[1],string);
  y:=convert(M[2],string);

  return cat("\\begin{tabular}{c} ",x," \\\\ ",y," \\end{tabular}")

end;

MyTableElement1([2,3]);

will output

"\begin{tabular}{c} 2 \\ 3 \end{tabular}"

as desired. However, if one inserts an \hline into the table,

MyTableElement2 := proc(L::list(nonnegint))
  ## L will have only two elements
  local M, x, y;
  M:=L;
  x:=convert(M[1],string);
  y:=convert(M[2],string);

  return cat("\\begin{tabular}{c} ",x," \\\\ \\hline ",y," \\end{tabular}")

end;

will output

"\begin{tabular}{c} 2 \\ \hline 3 \end{tabular}"

again as desired. However, if I copy and paste this int a document, I get

"\begin{tabular}{c} 2 \\ hline 3 \end{tabular}".

Note that \hline is now just hline. Putting "\\\\" in front of the hline outputs

"\begin{tabular}{c} 2 \\ \\hline 3 \end{tabular}",

but this does not compile properly. How can I get a proper \hline command to appear in the table? Thank uou for your consideration.

Please Wait...