4
$\begingroup$

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]
Abs[vecX - vecX'] // TraditionalForm

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}}
$\endgroup$
0

1 Answer 1

1
$\begingroup$

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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