10
$\begingroup$

In a notebook, when writing \[RightVector] over a variable I always end up bolding it to make it more visible. But it'd be easier if it could be set up to bold that character by default.

I haven't ventured into setting key bindings yet (just starting out), but I'm wondering if it's possible to set the combination EscvecEsc to turn on bolding, insert the appropriate symbol, then turn off bolding. If there's an even easier way, that'd be even better.

$\endgroup$

2 Answers 2

10
$\begingroup$

Yes, you can use InputAliases to style the replacements as you wish. I explained how to make auto replacements in this answer, but that was for a more specialized purpose.

As a simple example, you can do something like:

SetOptions[SelectedNotebook[], InputAliases -> 
    {"foo" -> MakeBoxes@Row[{
        Style[foo, FontColor -> Red, FontWeight -> Bold, 
            FontSlant -> Italic, FontFamily -> "Verdana"],
            \[VeryThinSpace]
        }]
    }
]

Now if you type EscfooEsc, it will show up as a bold, italic red foo.

$\endgroup$
4
  • 1
    $\begingroup$ I would also throw in a Block around foo if there's a chance of it also being a variable in the current context $\endgroup$
    – rm -rf
    Oct 11, 2012 at 19:05
  • $\begingroup$ Thanks for the answer! I'm having a bit of a problem using \[RightVector] as the text being styled though. It looks like it's the same problem with any operators as well. Do you know of any ways around that? $\endgroup$
    – Voriki
    Oct 11, 2012 at 21:21
  • $\begingroup$ @user745434 I don't know the answer off the top of my head... I can try figuring it out later, when I have some time :) $\endgroup$
    – rm -rf
    Oct 11, 2012 at 21:33
  • $\begingroup$ Thanks. I'll tinker with it as well. $\endgroup$
    – Voriki
    Oct 11, 2012 at 21:49
3
$\begingroup$

Perhaps you can use the following alias instead:

CurrentValue[EvaluationNotebook[], {InputAliases, "vec"}] = OverscriptBox[
    StyleBox["\[SelectionPlaceholder]", FontWeight->Bold],
    "\[RightVector]"
];

Then, using the following key strokes: Esc v e c Esc Tab b produces:

enter image description here

where the letter b is bolded.

$\endgroup$

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.