6
$\begingroup$

I wanted to make a notation with a double dot over a symbol in Mathematica. Searching online or in the documentation did not yield any results. However, just randomly attempting to give a second parameter to the OverDot function surprisingly did exactly what I needed:

enter image description here

I assume the red font suggests that Mathematica perceives this as a syntax mistake at some level, even though the output is as desired. Unfortunately, this does not work for three dots and more.

Is there a proper way to do this without red font appearing?

$\endgroup$
  • 1
    $\begingroup$ {Overscript[x, ".."], Overscript[x, "..."], Overscript[x, "\[Ellipsis]"]} $\endgroup$ – Bob Hanlon Apr 9 at 1:35
  • 3
    $\begingroup$ The code editor and documentation are not always completely in sync with the actual typesetting. This is only one of several examples. Ignore the code coloring. $\endgroup$ – m_goldberg Apr 9 at 2:35
  • $\begingroup$ @BobHanlon as a German speaker I perceive your Overscript[x, ".."] Umlaut to be very improperly typeset. Overscript[x, "¨"] is bad as well. They work, yes; but not for publication. Cheers! $\endgroup$ – Roman Apr 9 at 9:43
  • $\begingroup$ @Roman Why not just literally use the German character set for that? The double dot over a symbol has e.g. the meaning of a second time derivative in Physics -- which is typeset properly. $\endgroup$ – Kagaratsch Apr 9 at 12:37
  • $\begingroup$ For Umlaut characters you only get äëïöüÿ from the font set but not the others. That wasn't my point though. All I'm saying is that the size of the dots and their distance must be appropriate for the chosen font, otherwise it looks very bad for a native speaker of German, Turkish, Swedish, French, etc. If you don't care about the aesthetics, then all the given solutions work, sure. $\endgroup$ – Roman Apr 9 at 13:46
13
$\begingroup$

Use ToBoxes to find the boxes generated for OverDot[x, 2]:

OverDot[x,2] //ToBoxes

OverscriptBox["x", "¨"]

You can reproduce these boxes using Overscript:

Overscript[x, RawBoxes @ "¨"]

enter image description here

You can use the same approach for triple dots:

Overscript[x, RawBoxes @ "\[TripleDot]"]

enter image description here

For more dots, you will have to use a different mechanism to generate the dots, e.g.:

Overscript[x, Style[Row[{".",".",".","."}],FontTracking->"Condensed"]]

enter image description here

Update

You could also overload OverDot to work with the 3 and higher versions (I also included @Michael's syntax information fix):

SyntaxInformation[OverDot] = {"ArgumentsPattern" -> {_, _.}};
MakeBoxes[OverDot[a_, n_Integer?(GreaterThan[2])], StandardForm] := If[n==3,
    OverscriptBox[MakeBoxes[a], "\[TripleDot]"],
    OverscriptBox[
        MakeBoxes[a],
        ToBoxes @ Style[Row[ConstantArray[".", n]], FontTracking->"Condensed"]
    ]
]

Then:

enter image description here

$\endgroup$
8
$\begingroup$

You could fix the syntax highlighting, or ignore it. Here's a fix:

SyntaxInformation[OverDot] = {"ArgumentsPattern" -> {_, _.}};

Mathematica graphics

$\endgroup$
3
$\begingroup$

Go to the Basic math assistant palette and click on the template.

enter image description here

$\endgroup$
  • $\begingroup$ There indeed is a [DoubleDot] template, but it actually leads to an expression with the FullForm OverDot[X,2]! So the syntax is in fact intended, then I'm confused why Mathematica marks it in red font when typed in directly? $\endgroup$ – Kagaratsch Apr 9 at 1:13
  • 1
    $\begingroup$ Yes... confusing. The documentation for OverDot shows only one argument... so the $2$ is somehow treated extraneously. (Perhaps a bug report is in order.) $\endgroup$ – David G. Stork Apr 9 at 1:21

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.