Questions about using Interlinearize macro to generate tables

9 views
Skip to first unread message

Zhencao Zhong

unread,
Aug 5, 2020, 11:36:47 PM8/5/20
to Shoebox/Toolbox Field Linguist's Toolbox
Dear All,
I am working on a project using Toolbox to generate the interlinearized text for Uyghur language. The current interlinearize macro works perfectly fine on generate the text from Toolbox into tables. But it cannot do the small caps automatically. So I tried to write a simple macro to do this and the code was copied below.
                     Sub setStringsSmallCaps()
                     Call setKeyWordSmallCaps("(-1sg)>")
                     Call setKeyWordSmallCaps("(-2sg)>")
                     Call setKeyWordSmallCaps("(-3sg)>")
                     End Sub

                     Sub setKeyWordSmallCaps(styKeyWord As String)
                         Selection.HomeKey wdStory
                         Selection.Find.ClearFormatting
                         Selection.Find.Replacement.ClearFormatting
                         With Selection.Find
                             .Text = styKeyWord
                             .Forward = True
                             .Wrap = wdFindContinue
                             .MatchCase = False
                             .MatchByte = True
                             .MatchWildcards = True
                             .MatchWholeWord = False
                             .MatchFuzzy = False
                             .Replacement.Text = ""
                         End With
                         With Selection.Find.Replacement.Font
                             .SmallCaps = True
                         End With
                         Selection.Find.Execute Replace:=wdReplaceAll
                     End Sub
However, if the content is changed into smallcaps, the table wouldn't autofit it and the outcome will be like the photo below shows.
1596684078980.jpg
Of course I can manually change the table, but it can be really exhausting when it comes to a huge amount of data. I'm currently working on my dissertation with this and I am really desperate for a good solution since I know nothing about the VB programming.
Your help will be highly appreciated.
Zhencao

ToolBox Support

unread,
Aug 6, 2020, 11:08:07 AM8/6/20
to shoeboxtoolbox-fiel...@googlegroups.com
Thank you for this report. I will do some experiments with VB macros and
hopefully find a way to do this.
-- Toolbox support

--
You received this message because you are subscribed to the Google Groups "Shoebox/Toolbox Field Linguist's Toolbox" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shoeboxtoolbox-field-ling...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shoeboxtoolbox-field-linguists-toolbox/def18771-14b5-4e29-adc2-f7e56ff0f680n%40googlegroups.com.

ToolBox Support

unread,
Aug 6, 2020, 4:07:29 PM8/6/20
to shoeboxtoolbox-fiel...@googlegroups.com
Like you, I hadn't realized that small caps were wider than regular lower-case letters. A disappointing surprise.

Before trying any actual macro modifications, I experimented a bit with the data. My "Third" and "Fourth" experiments both produced successes. The Fourth is the best general solution.

First, as I'm sure you discovered, your macro does have to be run after the Interlinear macro, since assigning the character style un-does the small caps.

Second, I experimented with the SpaceBetweenWords option. This apparently only increases the space between columns, not the functional size of the boxes. So this also didn't help. 

Third, I tried reducing the point-size as well as doing the small caps. This worked. My initial data had a default size of 11 pt. I found that changing the point-size to 9.5 was adequate. 
image.png
(As you can see, I just selected the whole line and made it small caps and 9.5, so "together" was changed also.)

Fourth, I discovered another interesting and probably better solution. I noticed that together expanded the cell, just as we had expected Word would do. But the 3-gen and go-pst.1st both wrapped the data at the hyphens. When I did a Replace All of the ordinary hyphens with non-breaking hyphens, then the cells expanded instead of wrapping the data.
image.png
You can see that the N of 3-GEN sticks out beyond u-nin in this example, whereas it doesn't in the previous example. And in general, the above is wider.

So, probably the best solution is to add to your macro another Replace process for the hyphens. You will probably want to limit it to the style of the gloss line (ExampleGe) rather than turn it loose on all hyphens anywhere. I think it would have to be a separate Replace process from the small caps, though you could incorporate it into the same macro.

You seem to be pretty capable in the macro and Replace-All areas, but if you want any further help with the Replace only in a style or any such, just let me know.

Toolbox Support

Victor Zhong

unread,
Aug 6, 2020, 11:04:55 PM8/6/20
to shoeboxtoolbox-fiel...@googlegroups.com
Thank you for the solution here. I think I will use the non-breaking hyphen to manage it.

However, as you have mentioned, the Replace action may cause the whole text got replaced unless it is limited to the glossing line and the smallcaps replacement have to be placed after the interlinearising. And when the interlinearising was done, it is not able to limit the FindAndReplace to the lines beginning with \ge anymore as the interlinearising had deleted the \ge already. It might not be a big issue, but I think it’s better to report it here.

Thank you again for your wonderful solution to my problem. It really helps a lot.

Kind regards,
Zhencao

On Aug 7, 2020, at 04:07, ToolBox Support <too...@sil.org> wrote:

Like you, I hadn't realized that small caps were wider than regular lower-case letters. A disappointing surprise.

Before trying any actual macro modifications, I experimented a bit with the data. My "Third" and "Fourth" experiments both produced successes. The Fourth is the best general solution.

First, as I'm sure you discovered, your macro does have to be run after the Interlinear macro, since assigning the character style un-does the small caps.

Second, I experimented with the SpaceBetweenWords option. This apparently only increases the space between columns, not the functional size of the boxes. So this also didn't help. 

Third, I tried reducing the point-size as well as doing the small caps. This worked. My initial data had a default size of 11 pt. I found that changing the point-size to 9.5 was adequate. 
<image.png>
(As you can see, I just selected the whole line and made it small caps and 9.5, so "together" was changed also.)

Fourth, I discovered another interesting and probably better solution. I noticed that together expanded the cell, just as we had expected Word would do. But the 3-gen and go-pst.1st both wrapped the data at the hyphens. When I did a Replace All of the ordinary hyphens with non-breaking hyphens, then the cells expanded instead of wrapping the data.
<1596684078980.jpg>
Of course I can manually change the table, but it can be really exhausting when it comes to a huge amount of data. I'm currently working on my dissertation with this and I am really desperate for a good solution since I know nothing about the VB programming.
Your help will be highly appreciated.
Zhencao

-- 
You received this message because you are subscribed to the Google Groups "Shoebox/Toolbox Field Linguist's Toolbox" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shoeboxtoolbox-field-ling...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shoeboxtoolbox-field-linguists-toolbox/def18771-14b5-4e29-adc2-f7e56ff0f680n%40googlegroups.com.

-- 
You received this message because you are subscribed to a topic in the Google Groups "Shoebox/Toolbox Field Linguist's Toolbox" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/shoeboxtoolbox-field-linguists-toolbox/jQT5LtQV-n4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to shoeboxtoolbox-field-ling...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shoeboxtoolbox-field-linguists-toolbox/CAEgRS93Rr-2FEhAyFxoRR_6X%2BNu%2Br2DY3H_hK%2B56aqDMhJ4Xew%40mail.gmail.com.

ToolBox Support

unread,
Aug 7, 2020, 12:10:01 AM8/7/20
to shoeboxtoolbox-fiel...@googlegroups.com
Hi,

I just want to be sure you, and especially others reading this, know what I mean about locating the hyphen in the correct style line.

First, place your cursor in the line with the hyphens to be replaced. It appears to be the gloss line. To verify the name of the style, bring up the style list. Notice the name of the style.

find the style.png

Next, do CTRL+H in order to bring up the Replace dialog box.
Place your cursor in the "Find what" box and enter the hyphen.
Next, click on "More>>" to expand the dialog box.

Click on More.png
  
Choose "Format" and "Style"  

Choose Format then Style.png

Word will bring up a really old dialog box for finding the style. Scroll down the list until you get to the correct style for your data. (I believe this is ExampleGe, as shown.)

The find style dialog.png

Select the style and click on OK. Word will add the style to the "Find what" information.

Find in style.png

Next, place your cursor in the "Replace with" area.

Click on Special. Word will bring up a list of special things for replacement. (Note: if your cursor is still in the "Find what" area, the list will be different.)

Replace special.png
Choose the Nonbreaking hyphen. Word has special symbols for all its special replacements. Word will insert ^~ into the "Replace with" area.

Replace all.png

You are now ready to replace all the ordinary hyphens. Word will report how many it has replaced. Note that they will look the same as before.

Let me know if you have any questions.

Toolbox Support


Zhencao Zhong

unread,
Aug 7, 2020, 12:42:00 AM8/7/20
to shoeboxtoolbox-fiel...@googlegroups.com
Hi,

It is really kind of you to give such a detailed instruction of this. It is really helpful. With this everything is clear now. Thank you for you patience.

Kind regards,
Zhencao

On Aug 7, 2020, at 12:09, ToolBox Support <too...@sil.org> wrote:

Hi,

I just want to be sure you, and especially others reading this, know what I mean about locating the hyphen in the correct style line.

First, place your cursor in the line with the hyphens to be replaced. It appears to be the gloss line. To verify the name of the style, bring up the style list. Notice the name of the style.

<find the style.png>

Next, do CTRL+H in order to bring up the Replace dialog box.
Place your cursor in the "Find what" box and enter the hyphen.
Next, click on "More>>" to expand the dialog box.

<Click on More.png>
  
Choose "Format" and "Style"  

<Choose Format then Style.png>

Word will bring up a really old dialog box for finding the style. Scroll down the list until you get to the correct style for your data. (I believe this is ExampleGe, as shown.)

<The find style dialog.png>

Select the style and click on OK. Word will add the style to the "Find what" information.

<Find in style.png>

Next, place your cursor in the "Replace with" area.

Click on Special. Word will bring up a list of special things for replacement. (Note: if your cursor is still in the "Find what" area, the list will be different.)

<Replace special.png>
Choose the Nonbreaking hyphen. Word has special symbols for all its special replacements. Word will insert ^~ into the "Replace with" area.

Reply all
Reply to author
Forward
0 new messages