Backslashes, i.e. \
, must be escaped in Mathematica strings.
This is incorrect syntax:
"\xyz"
The correct syntax is
"\\xyz"
Unfortunately, Mathematica tries to be "user-friendly" and when using the notebook interface, it accepts "\xyz"
without complaint. (If using the terminal, it at least shows a warning.) This creates the false impression that it's fine to do this. It's not. Sequences like \r
(which you used), \b
, \f
, \n
, etc. have special meanings. New escape sequences may also be added in the future, breaking code like "\xyz"
.
Thus: always, always escape backslashes in strings!.
str = "\\frac{s + k_{12} + k_{02}}{V_1 \\left[ s^2 + s \\left( k_{12} + k_{02} + k_{21} + k_{01} \\right) + \\left( k_{21} \\, k_{02} + k_{01} \\, k_{12} + k_{01} \\, k_{02} \\right) \\right] }";
ToExpression[str, TeXForm]

\
be a double\\
? (You can evaluate the string by itself to see the problem.) $\endgroup$\
as escape character for\
(and also for"
) when you manipulate strings in Mathematica, exactly as you did in"\\frac{...}"
. $\endgroup$