4
$\begingroup$

I am trying to draw an arrow, and put two labels next to it, and the labels, namely e_2, and a(e_2) should be in latex format.

This is my try but it does not work.

Thank you.

p = Graphics[Arrow[ {{1, 1}, {1.5, 1}}]];

l1 = Graphics[Text[e_ 2, {1.5, 0.95}]]; 

l2 = Graphics[Text[a (e_ 2), {1.3, 0.95}]];

Show[p, l1, l2]
$\endgroup$
3
  • 3
    $\begingroup$ Take a look at the MaTeX package by @Szabolcs $\endgroup$
    – Lukas Lang
    Aug 8 at 15:14
  • $\begingroup$ I prefer the MaTeX package, but control-4 worked for me inside Text/Inset. MaTeX looks better. But when I tried it on the OP's example, the FE is stuck and the wheel of death is spinning....MaTeX has never done that to me. $\endgroup$
    – Michael E2
    Aug 8 at 16:24
  • $\begingroup$ Turns out the problem was that the variable a is evaluated when the graphics are typeset (see my answer below). What hung the FE was that the value of a was an array with something like a million elements. $\endgroup$
    – Michael E2
    Aug 8 at 17:09

2 Answers 2

5
$\begingroup$

CTRL-4 (inline TeX input) works, although I prefer the actual TeX typesetting of MaTeX. I entered the TeX code e_2 and a(e_2) into l1 and l2 respectively after typing CTRL-4:

However, somehow some of it gets evaluated (is that a bug??):

Wrapping the inline cell with HoldForm fixes the problem:

$\endgroup$
2
$\begingroup$

Taking the comment into consideration -many thanks to @Lukas Lang

hh = a[Subscript[e, 2]];
p = Graphics[Arrow[{{1, 1}, {1.5, 1}}]];
l1 = Graphics[Text[Subscript[e, 2], {1.5, 0.95}]];
l2 = Graphics[Text[hh, {1.3, 0.95}]];
Show[p, l1, l2]

stack1

$\endgroup$
2
  • 1
    $\begingroup$ I don't see how the Format line is necessary? Can't you just write a[Subscript[e,2]] in the second line? $\endgroup$
    – Lukas Lang
    Aug 8 at 16:00
  • $\begingroup$ @LukasLang, you are right. Thanks for spotting it. As I was trying things, I forgot to try the simplest one :) $\endgroup$
    – bmf
    Aug 8 at 16:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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