# overriding the format of 'copy-as' latex?

In the answer to Bold face formatting for vectors instead of overarrows like latex \mathbf{}? was a nice method of specifying the visual display for a variable, so that I can do something like the following to generate display output for vectors in the way that I want it:

Clear[vecX]
Format[boldVector[v_]] := Style[HoldForm[v], FontFamily -> "Arial Black"]
vecX := boldVector[x]


Is there a way to specify how text in copy-as Latex should appear? For example, if I could do copy-as latex and have vecX above show up as \vecX, then I can have my latex macros deal with the formatting in that context:

\newcommand{\vecX}[0]{\mathbf{x}}

-

I don't know of a way to do this automatically on Copy as LaTeX. I also do not know enough about LaTeX to know the right way to make changes.

I should point out that vecX no longer appears in the output of Abs[vecX - vecX'] // TraditionalForm therefore you must base your output on boldVector[x] and not vecX, unless you want to work with a held expression, which I imagine you do not.

The best I can recommend is using your own convert-to-LaTeX function something like this:

myTeX =
StringReplace[
ToString @ TeXForm[# /. boldVector -> bvTeX],
"text{bvTeX}" :> "EXAMPLE"
] &;

Abs[vecX - vecX'] // myTeX

\left|\EXAMPLE(x)-\EXAMPLE(x)'\right|


I am sure this is gibberish. I simply want to show how this may be approached.

-
I wonder if TeXForm can be extended (maybe with Format, which is assignable) ... –  Szabolcs Feb 24 '12 at 22:02
@Szabolcs I wonder too, because I don't know how. –  Mr.Wizard Feb 24 '12 at 22:10