6

Consider the following example:

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage{mathtools}
\usepackage{xcolor}

\newcommand*\variable[1]{\textcolor{teal}{\texttt{#1}}}

\begin{document}

\begin{equation*}
  \texttt{Table[A/(A - r*X) - (1 + r)\^{}\variable{k}, \{\variable{k}, 1, 10\}]}
\end{equation*}

\end{document}

output

If I copy the code and paste it into Mathematica, the rendering of the ^ is wrong; see the following picture:

Mathematica

How do I get an output which I can paste (directly) into Mathematica without having to change ^ manually?

8

Using \string^ seems to work as expected:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.