In Word, how can I place a bar above a letter to show a mean?

J

johnc1476

Typing a statistical formula, I want to show the mean of x as x with a bar
across the top. Is there a way to do that? Is there a way that does not
require the Equation Editor?
 
P

Peter T. Daniels

That article _still_ doesn't show the simplest way to do it, which is
to type the Combining Diacritic "Overline" character, which is Unicode
0305. Place the cursor after the letter you want to have the overbar
on, and type 0305 Alt-X. You can also assign a keyboard shortcut to
this character by locating it in the Insert Symbol panel (under
"Combining Diacritical Marks").

Suzanne has posted a more recent version of that article that does
include this information.
 
G

Graham Mayor

Suzanne is away on holiday - where did she post the more up to date version?
This one is on her web site.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
P

Peter T. Daniels

I don't know -- two or three times ago that this question came up, she
added a posting to the thread with the new url. It may be Word2007-
specific for the other methods.
 
P

Pesach Shelnitz

Hi,

I have had no success in my attempts to use Unicode 0305 to add an overbar
to x, but I have been doing this successfully for some time according to
Suzanne's method with an EQ field and Unicode AF. I have even written a macro
to automate the process. To use it, simply type the letter that you want to
have an overbar and run the following macro.

Sub Overbar()
Dim myField As Field
Dim myChar As String

With Selection
.MoveStart Unit:=wdCharacter, Count:=-1
myChar = .Text
.Delete
Set myField = ActiveDocument.Fields.Add(Range:=.Range, _
Type:=wdFieldEmpty, PreserveFormatting:=False)
myField.Code.Text = "EQ \o(" & myChar & "," & ChrW(&HAF) & ")"
myField.ShowCodes = False
.MoveRight Unit:=wdCharacter, Count:=1
End With
End Sub

The macro has another advantage. It does not introduce any extra spaces in
the field code that can mess up the alignment.
 
G

Greg Maxey

Peasach,

A similiar macro is available in my
http://gregmaxey.mvps.org/Banner_Text.htm that can easily be adapted to
overbar.

Public Sub Overbarr()
Dim Expr As String
Expr = InputBox("Enter the text to overbarr:", "Apply overbar")
If Expr <> "" Then
ActiveDocument.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty,
Text:="EQ \x\to(" & Expr & ")", PreserveFormatting:=False
End If
End Sub
 
P

Peter T. Daniels

Hi,

I have had no success in my attempts to use Unicode 0305 to add an overbar
to x,

What does that mean? What happens when you type 0305 Alt-X, or when
you choose it from Insert Symbol? If you're in a font that doesn't
have the character, Word will insert it from some font that does (such
as TNR or Tahoma).
 
P

Pesach Shelnitz

Hi Peter,

The OP referred to adding an overbar or macron to the letter x. When I type
x and then 0305 as you suggested, I have x0305 with my cursor after the 5. In
this case when I press Alt+X, nothing happens. If I insert a space after the
x, Alt+X does convert the number into an overbar, but the two characters do
not align properly even when I remove the space between them.

Pesach
 
G

Greg Maxey

Pesach,

For what it is worth, I can't get it to work either and see the same
behavior that you see. Even if I could, I would hardly classify it the
"simplest" way.
 
P

Peter T. Daniels

Typing is simpler than composing a macro. And assigning a keyboard
shortcut to a character you're going to use a lot is simpler than
composing a macro.

It's bizarre. It works with some letters -- S, V -- and not others.
I've never before encountered a Combining Diacritical Mark that was
picky that way.
 
G

Greg Maxey

As it is now bizarre and it doesn't work I suppose you still thinks it's
simplier?
 
G

Greg Maxey

Peter,

Conceding that it could be far more difficult if not impossible for you, the
following macro took less than two minutes to compose and stick on the Quick
Access Toolbar:

Public Sub Overbar()
Dim Expr As String
Dim oFld As Field
Expr = InputBox("Enter the text to overbar:", "Apply overbar")
If Expr <> "" Then
Set oFld = ActiveDocument.Fields.Add(Range:=Selection.Range, _
Type:=wdFieldEmpty, _
Text:="EQ \x\to(" & Expr & ")", PreserveFormatting:=False)
With oFld
.Code.Text = Trim(oFld.Code.Text)
.ShowCodes = False
End With
Set oFld = Nothing
End If
End Sub

I could spend the rest of the afternoon testing it, but so far it has worked
every time and it hasn't shown any bizarre behaviour.

Is typing out some arcane unicode character sequence and assigning a
keyboard short cut for every possilble keyboard character, or phase in the
English language for that matter, that you may use a lot really so much
simplier?

I think not.
 
P

Peter T. Daniels

I never suggested there was anything wrong with using the Overstrike
field (that's what I did yesterday to put a tilde through the middle
of several phonetic characters in transcribing Arabic, because the
Combining Diacritic Tilde was not positioned properly); but where the
combining diacritic exists, it certainly is easier to open Insert
Symbol and click it. (I don't type the Unicod code myself, but some
people are overwhelmed by the amount of choice provided by Insert
Symbol.) I learned to use the Overstrike filed from the Appendix on
Fields that was included in the MANUAL THAT CAME WITH WORD 5.0 FOR
MAC.

And since I use several score of letters with diacritics regularly, it
most certainly is far more convenient to assign a keyboard shortcut to
each one of them (using a rational system, of course).

For instance, Ctrl-Alt-P is the trigger, and Hyphen gets me macrons or
underbars; v gets me hacheks; u gets me breves; period gets me
underdots; Ctrl-P and period gets me overdots (they're used much less
commonly than underdots); etc. The four groups Latin and Extensions
cover just about every variety of roman letter that's used in any
language of the world, and my keyboard shortcuts cover everything I
need. (For Vietnamese, I use the Vietnamese keyboard.)

It is of course "impossible" for me to create a macro, because I don't
have any idea how to find instructions in creating a macro. I once got
a remaindered "Word2000 Developer's Handbook" that seems to cover the
topic; it's even fatter than the accompanying aftermarket book on
using Word that deals with every command Word has.

For instance, I always wonder what "Dim" means, since it appears so
often in macro codes.
 
P

Peter T. Daniels

Me, I use macron (for the few characters that don't have precomposed
macronned counterparts) and have had no difficulty.
 
P

Peter T. Daniels

The macro I use does not use the overstrike field.  Is uses the EQ field
with the \x "box" switch.  What is an overstrike field anyway?

\O

(Haven't you ever looked into the "Options" button in the Fields
dialog?)

It's rather simpler than the elaborate expression in your line "Text."
Do you really always wonder what Dim means?

Try:http://lmgtfy.com/?q=What+is+dim?

Why? It won't make any sense without a whole congeries of other
terminology.

And presumably that would give me a large number of dictionary entries
for the English word meaning 'not brightly lit'.
 
G

Greg Maxey

Pesach,

If I may suggest an alteration. This will overbar an entire string of text
rather than just one character:

Sub Overbar()
Dim myField As Field
Dim pStr As String
Dim pStrBar
Dim i As Long
With Selection
pStr = .Text
For i = 1 To .Range.Characters.Count
pStrBar = pStrBar & ChrW(&HAF)
Next i
.Delete
Set myField = ActiveDocument.Fields.Add(Range:=.Range, _
Type:=wdFieldEmpty, PreserveFormatting:=False)
myField.Code.Text = "EQ \o(" & pStr & "," & pStrBar & ")"
myField.Code.Text = Trim(myField.Code.Text)
myField.ShowCodes = False
End With
End Sub
 
S

Stefan Blom

In Word terminology, "\o" in this case is a switch.

--
Stefan Blom
Microsoft Word MVP


_____________________________
The macro I use does not use the overstrike field. Is uses the EQ field
with the \x "box" switch. What is an overstrike field anyway?

\O

(Haven't you ever looked into the "Options" button in the Fields
dialog?)
 
S

Suzanne S. Barnhill

The article at http://sbarnhill.mvps.org/WordFAQs/CombineCharacters.htm does
mention combining diacritics, but, as the remainder of this thread shows,
they can be unpredictable. Whenever I've tried them, it seems they don't
combine very neatly.

Note that http://sbarnhill.mvps.org/WordFAQs/CombineCharacters.htm is not
meant to be a "more recent version" of the overbar article but a supplement
to it.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

That article _still_ doesn't show the simplest way to do it, which is
to type the Combining Diacritic "Overline" character, which is Unicode
0305. Place the cursor after the letter you want to have the overbar
on, and type 0305 Alt-X. You can also assign a keyboard shortcut to
this character by locating it in the Insert Symbol panel (under
"Combining Diacritical Marks").

Suzanne has posted a more recent version of that article that does
include this information.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top