1
$\begingroup$

New for Mathematica 12(?) seems to be a formatted "black board" style of the former C[1], C[2], ... constants in Mathematica 11. How do I type these with formatting at input? C[1] etc. still works, but how to write it formatted? I could not find it in the escape sequence list. TIA.

$\endgroup$
3
  • 1
    $\begingroup$ You could try typing C[1] as usual, highlight it, and then evaluate it in place with Ctrl+Shift+Enter. $\endgroup$ Aug 27, 2020 at 17:28
  • $\begingroup$ The actual box form is TemplateBox[{"i"}, "C"] so you can always copy, paste, and edit that. If you're working with formulae and are gonna send them through the FE you can do Format[Subscript[\[ConstantC], i_]] := RawBoxes@TemplateBox[{ToBoxes[i]}, "C"]; and then use that form and have it spit out the appropriate C[i] form after evaluation. You can also add MakeExpression[SubscriptBox["\[ConstantC]", i_], _] := C[ToExpression[i]] to make it a proper alias of C[i] or modify InputAliases to give you TemplateBox[{"\[Placeholder]"}, "C"]. $\endgroup$
    – b3m2a1
    Aug 27, 2020 at 17:33
  • $\begingroup$ @J.M.: That was very interesting. I did not know of the "in line" evaluation of an expression. Thank you. $\endgroup$
    – mf67
    Aug 27, 2020 at 17:39

1 Answer 1

2
$\begingroup$

You could use InputAutoReplacements so that c1 gets automatically converted:

CurrentValue[EvaluationNotebook[], {InputAutoReplacements,"c1"}] = TemplateBox[{"1"},"C"];

or you could use InputAliases so that you need to use the Esc key as usual:

CurrentValue[EvaluationNotebook[], {InputAliases,"c2"}] = TemplateBox[{"2"}, "C"];
$\endgroup$
1
  • $\begingroup$ That is so 'cool'. There is so much to discover in Mathematica, but very hard to learn (without asking on this excellent site). $\endgroup$
    – mf67
    Aug 27, 2020 at 18:55

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.