Word Hacks [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Word Hacks [Electronic resources] - نسخه متنی

Andrew Savikas

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید







Hack 22 Make More Flexible Captions

Word offers a built-in captions feature, but it
allows you to use a heading style only for the chapter number. This
hack shows you how to expand your options.

If you ask Word to include the chapter
number in a caption, you must specify
the heading level. But what if you use a style other than one of the
built-in heading styles to number your chapters? By using two kinds
of fields, you can have your captions use any style you like as the
base for the chapter number. The following example shows you how to
create a figure caption that gets its chapter number from a custom
paragraph style named
"ChapterLabel."

Put your cursor where you want to place the caption. Next, type the
word "Figure," followed by a space.
Select InsertField and insert a STYLEREF
field pointing to the ChapterLabel paragraph style, as shown in Figure 3-36.


The ChapterLabel paragraph style (or any other style you specify)
must exist within the document for this hack to work, and it must
also actually be in use within the document.


Figure 3-36. Creating a caption using a STYLEREF field

Click the OK button to insert the field in your document. If
you've turned on the option to make field codes
always visible (ToolsOptionsView), the field will
look like Figure 3-37. If you don't
see the field code, select the text you just inserted, then
right-click and choose Toggle Field Codes.


Figure 3-37. A STYLEREF field, one of the building blocks for a caption

Immediately after the field, put in a hyphen. Then select
InsertField and insert a SEQ field. Use
"Figure" as the identifier, as
shown in Figure 3-38.


Figure 3-38. Adding a SEQ field to a caption to increment the numbering

With these fields in the document, your caption should now look like
Figure 3-39. The figure shows two captions: the
first shows the field results and the second shows the field codes.


Figure 3-39. The field results (top) and the field codes used to produce the results (bottom)

Finish the caption label with a period, and you can now type the
caption text.


In the next section, you will learn how to create captions like this
with a macro, but in a pinch you can always copy and paste to create
additional captions.

Though the syntax used is slightly different, Word's
built-in captions feature also uses a combination of
STYLEREF and SEQ fields, as
shown in Figure 3-40. In this case, the captions are
set to get the chapter number from the Heading 1 style.


Figure 3-40. Word's caption feature also uses a combination of STYLEREF and SEQ fields


3.10.1 Automating the Captions


Obviously, a macro would help
you
insert captions much faster. The following example comes from the
macros used to insert the captions for this book:

Sub InsertFigureCaption( )
Dim bIsParagraphEmpty As Boolean
With Selection
.Expand wdParagraph
If .Characters.Count = 1 Then bIsParagraphEmpty = True
.Collapse wdCollapseStart
.Style = "Caption"
.InsertBefore "Figure "
.Collapse wdCollapseEnd
.Fields.Add _
Range:=Selection.Range, _
Type:=wdFieldStyleRef, _
Text:="ChapterLabel", _
PreserveFormatting:=True
.Collapse wdCollapseEnd
.InsertAfter "-"
.Collapse wdCollapseEnd
.Fields.Add _
Range:=Selection.Range, _
Type:=wdFieldSequence, _
Text:="Figure", _
PreserveFormatting:=True
.InsertAfter ". "
.Collapse wdCollapseEnd
If bIsParagraphEmpty = True Then
.InsertAfter "Caption Text Goes Here"
Else
.Expand wdParagraph
End If
End With
End Sub

If the paragraph already contains text when you run this macro, it
prefaces the text with a caption label. If no text exists, it inserts
some dummy text for you to replace later.


/ 162