4
$\begingroup$

I am trying to insert an \hbar into the Front End's interface. texinput

but the hbar is missing:

result

I've tried to use character codes and pasting the FrontEnd's [HBar] in directly. Neither work.

Does anyone know how to get the \hbar symbol?

This is related to this thread which says that some missing symbols have been fixed in 13. I am running 13, but I still get a missing symbol.

$\endgroup$
2
  • 1
    $\begingroup$ Looks like a bug. TeXForm[\[HBar]] results correctly in \hbar, but ToExpression["\\hbar", TeXForm] gives \[Null]. I am using 13.3.0 for Microsoft Windows (64-bit) (June 3, 2023). $\endgroup$ Commented Oct 15, 2023 at 17:14
  • $\begingroup$ Thanks @Domen, Thought so. Bummer. $\endgroup$ Commented Oct 15, 2023 at 19:26

2 Answers 2

2
$\begingroup$

Try this alternative

 ToExpression["\\hslash",TeXForm] 

enter image description here

Not much difference from $\Huge{\hbar}$ and some seem to prefer the first one.

$\endgroup$
1
  • $\begingroup$ I’m happy with this workaround. Thanks @Nasser. $\endgroup$ Commented Oct 16, 2023 at 1:03
4
$\begingroup$

It looks like some of the characters can only be exported to $\TeX$, but not imported. TeXForm[\[HBar]] results correctly in \hbar, but ToExpression["\\hbar", TeXForm] gives \[Null].

Let's try finding other characters that have the same problem. Because some characters work as unary or binary operators, we will also try importing them as $\alpha \; \square \; \beta$.

$Version (* 13.3.0 for Microsoft Windows (64-bit) (June 3, 2023) *) Grid[#~Join~{TeXForm[#[[1]]], Quiet@ToExpression[ToString[TeXForm[#[[1]]]], TeXForm, HoldForm], Quiet@ToExpression[ "$\\alpha " ~~ ToString[TeXForm[#[[1]]]] ~~ " \\beta$", TeXForm, HoldForm]} & /@ Select[Table[{#, ToString[FullForm[#]]} &[FromCharacterCode[i]], {i, 65535}], StringMatchQ[#[[2]], "\"\\[" ~~ __] &], Frame -> All] 

enter image description here enter image description here enter image description here enter image description here

We see that quite a few characters can be exported but not imported.

$\endgroup$
4
  • $\begingroup$ Nice spelunking @Domen! $\endgroup$ Commented Oct 16, 2023 at 1:02
  • 1
    $\begingroup$ Very surprised to see \int is missing… isn’t this the first thing people usually do with LaTeX? $\endgroup$ Commented Oct 16, 2023 at 1:07
  • 1
    $\begingroup$ @CraigCarter "int" works. But need full expression, like this as an example ToExpression["\\int{x \,dx}",TeXForm,HoldForm] which gives !Mathematica graphics But if you do "\\int" on its own, it will fail ofcourse as it is not complete expression for Mathematica. !Mathematica graphics $\endgroup$ Commented Oct 16, 2023 at 6:58
  • $\begingroup$ @CraigCarter, my analysis is not thorough enough – I've just tried to import the $\TeX$ character on its own, and as a binary operator. Some characters, however, require some other syntax to be properly parsed. $\endgroup$ Commented Oct 16, 2023 at 7:00

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.