How to create a character with a bar over it

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

How to create a character with a bar over it

Post by Rudi »

I learned something new (and interesting) recently about Word. I guess its one of these "secret" tips that is not used regularly, but pretty useful if needed. Its to do with combining two characters together to produce a new character. Typically used in "bar" characters and possible other mathematical symbols.

There are a number of reasons for putting a “line,” “bar,” or “hyphen” over a character. One is to indicate a long sound in grammatical terms. Another frequent reason is for the “x bar” character is used to indicate the arithmetic mean in mathematics and statistics, to indicate shorthand characters such as c with a line over it (shorthand for “with”), and for certain medical symbols.

The quickest way to create this special character is by doing the following:
1. Make sure your cursor is in the correct position in the document
2. Press Ctrl+F9 to insert the field delimiters (the characters that look like braces but cannot be typed from the keyboard)
3. Type the text (indicated below) between these braces:
• EQ \O(x,ˉ) to produce the X-Bar --- OR --- aother example: EQ \(0,/) to produce a zero with line through it!

The bar character can be inserted from the symbols dialog.
You do not have the required permissions to view the files attached to this post.
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.

User avatar
HansV
Administrator
Posts: 78487
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: How to create a character with a bar over it

Post by HansV »

Don't forget step 4:

4. Press F9 to hide the field code and to update the result.
Best wishes,
Hans

User avatar
macropod
4StarLounger
Posts: 508
Joined: 17 Dec 2010, 03:14

Re: How to create a character with a bar over it

Post by macropod »

Hi Rudi,

What you're dexcribing is typically called a macron.

Perhaps the simplest method for upper-case macrons is to type the character requiring the macron (eg X), then type 0305, so you end up with X0305, then select the 0305 and press Alt-X. For lower-case characters (eg i), you can use 0304. For double bars over a character, you can use 033F (note that the gap between the double lines may be indistinct over capitals).

As for the field-based approach, here are two more variations on the theme:
• {EQ \x\to(a)}.
• {EQ \s\up6(\f(,a))}.
In each example, replace the ‘a’ in the field with the desired character(s).
Compared to the other field-based solutions (including your's), the last one above has the advantage of retaining the character sizes without increasing the line height. The ‘6’ in the formula controls the bar height.

The following macro implements the last of the above examples for a selected string:

Code: Select all

Sub Macron()
Dim StrTxt As String
ActiveWindow.View.ShowFieldCodes = True
With Selection
  StrTxt = .Text
  .Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, _
    PreserveFormatting:=False, Text:="EQ \s\up6(\f(," & StrTxt & "))"
  .MoveLeft wdCharacter, 2
  .Delete
  .Fields.Update
End With
ActiveWindow.View.ShowFieldCodes = False
End Sub
Note: The field contents must fit on one line. If there's a word-wrap in the selected range, the field will force all of it onto the one line and, if the string spans more than one line, the field will display 'Error!'.
Last edited by macropod on 11 Dec 2012, 09:46, edited 1 time in total.
Paul Edstein
[Fmr MS MVP - Word]

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: How to create a character with a bar over it

Post by Rudi »

That is an interesting variation using the 0305 and ALT keys Paul. Thanks for this VERY insightful post. Personally I will not need to control this to the extent you provide, but it is surely useful to anyone who needs to delve into this for their purposes. As for me, this is a very interesting learning curve...discovering things about Word I have never known. Many TX :)

BTW:
- Thanks for that macro to assist in setting up these fields...
- Do you have a website of your own where you delve into these word fields in more detail (or an MVP website to recommend that deals in this)? I do recall posts from years back in WOPR where you shared your knowledge on Word fields. TX.
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.

User avatar
macropod
4StarLounger
Posts: 508
Joined: 17 Dec 2010, 03:14

Re: How to create a character with a bar over it

Post by macropod »

I don't have a website of my own. My Word tutorials are:
Microsoft Word Date Calculation Tutorial, available at:
http://lounge.windowssecrets.com/index. ... pic=249902
or
http://www.gmayor.com/downloads.htm#Third_party

Microsoft Word Field Maths Tutorial, at:
http://windowssecrets.com/forums/showth ... post320143
or
http://www.gmayor.com/downloads.htm#Third_party

Microsoft Word Catalogue/Directory Mailmerge Tutorial at:
http://lounge.windowssecrets.com/index. ... pic=731107
or
http://www.gmayor.com/Zips/Catalogue%20Mailmerge.zip
The tutorial covers everything from list creation to the insertion & calculation of values in multi-record tables in letters. Do read the tutorial before trying to use the mailmerge document included with it. For some worked examples, see the attachment to the posts at:
http://www.msofficeforums.com/mail-merg ... #post23345
http://www.msofficeforums.com/mail-merg ... #post30327

You may also be interested in macros for Field Code Conversions:
To Text -http://www.gmayor.com/export_field.htm#FieldToText
From Text: http://www.gmayor.com/export_field.htm#TextToField
and field constructions and macro to implement relative paths in Word:
http://windowssecrets.com/forums/showth ... post584769
Last edited by macropod on 12 Dec 2012, 23:12, edited 1 time in total.
Paul Edstein
[Fmr MS MVP - Word]

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: How to create a character with a bar over it

Post by Rudi »

Over and beyond!!! This will certainly keep me busy over the holiday season.
TX for your efforts.
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.