Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

paste latex code into notebook text cell

Sometimes, I'd like to paste code from a latex document into a sage worksheet to follow a set of derivations step by step. Surprisingly, pasting the following text into the rich-text cell of a worksheet actually displays one of the equations in typeset form but not the other, if re-evaluated, the other is typeset but not the first and if re-evaluated again, none of the equations are typeset:

Ohm's law is commonly stated as
\begin{equation}\label{eq_I}
I = \frac{U}{R}
\end{equation}
where $I$ is the current, $U$ is the voltage and $R$ is the resistance. The easiest way of remembering Eq. \ref{eq_I} is its multiplicative form, resulting in ``URI'':

\begin{equation}\label{eq_U}
U= R I
\end{equation}

In all cases the reference "\ref{eq_I}" gives a link to "???" in worksheet after evaluation. Is there a way to make the interpretation of code snippets more persistent and manipulate it somehow? Could such code be used for cross-referencing within the worksheet?

Putting the same code in a %latex cell does not display the cross-reference, either.