Ask Your Question

Revision history [back]

I haven't tried this in sagetex, but it works in a Sage session:

sage: v = vector([1,2,3])
sage: latex(v)
\left(1,\,2,\,3\right)

That's not what you want, so use latex.vector_delimiters to change the parentheses to what you want:

sage: latex.vector_delimiters("[", "]^{T}")
sage: latex(v)
\left[1,\,2,\,3\right]^{T}

I haven't tried this in sagetex, but it works in a Sage session:

sage: v = vector([1,2,3])
sage: latex(v)
\left(1,\,2,\,3\right)

That's not what you want, so use latex.vector_delimiters to change the parentheses to what you want:

sage: latex.vector_delimiters("[", "]^{T}")
sage: latex(v)
\left[1,\,2,\,3\right]^{T}

I haven't tried this in sagetex, but it works in a Sage session:

sage: v = vector([1,2,3])
sage: latex(v)
\left(1,\,2,\,3\right)

That's not what you want, so use latex.vector_delimiters to change the parentheses to what you want:

sage: latex.vector_delimiters("[", "]^{T}")
"]^{\\intercal}")
sage: latex(v)
\left[1,\,2,\,3\right]^{T}
\left[1,\,2,\,3\right]^{\intercal}

I haven't tried this in sagetex, but it works in a Sage session:

sage: v = vector([1,2,3])
sage: latex(v)
\left(1,\,2,\,3\right)

That's not what you want, so use latex.vector_delimiters to change the parentheses to what you want:

sage: latex.vector_delimiters("[", "]^{\\intercal}")
sage: latex(v)
\left[1,\,2,\,3\right]^{\intercal}

Edit: An alternative is to modify your sagetex.sty file: change the line

\newcommand{\sage}[1]{\ST@sage{latex(#1)}}

to

\newcommand{\sage}[1]{\ST@sage{my_print(#1)}}

Or maybe better, create an .sty file with this change, with a new name and use that instead of sagetex.sty.

Then the first thing in your LaTeX file (after "\begin{document}") should be

\begin{sagesilent}
def my_print(v):
    if isinstance(v, sage.modules.free_module_element.FreeModuleElement):
        return matrix(v)._latex_() + r'^\intercal'
    else:
        return latex(v)
\end{sagesilent}

Then you can customize the output for each class, however you want.