Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

up vote 8 down vote accepted

Using \string^ seems to work as expected:

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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