Anda di halaman 1dari 11

Despite being surprisingly well documented in Words online Help file, the StyleRef field may be one of Words

least noticedand consequently least usedfields. sers who disco!er it "or ha!e it pointed out to them#, howe!er, almost always welcome it gratefully. $he basic Help topic, %&ield codes' StyleRef field,( pro!ides the usual succinct )nstructions, Switches, and *+amples and goes on to pro!ide more information about how the field beha!es depending on where it is inserted in the document. ,nother Help topic, %-reate a dictionary.style page header,( tells how to use two slightly different StyleRef fields to pic/ up the first and last word "or heading# on a page. ,dditional basic information on the use of StyleRef fields can be found in the %0eyond numbering( section of my article %How to set up a document with front matter numbered separately.( ,lthough this article is intended to go beyond these applications to describe some additional ways to use StyleRef fields referencing character styles, )1ll start with some quic/ tips on creating character styles and inserting StyleRef fields. )f you already /now how to do this, s/ip to 23ic/ing up part of a heading,2 %Suppressing a StyleRef field,( 2Repeating form field data in a header4footer,2 or 2-ustomi5ing table of contents entries.2

How to insert a StyleRef field


$here are two ways to insert a StyleRef field "or any other field#' 6. se the Insert | Field dialog "in Word 7889 or 7868, use Insert | Text | Quick Parts | Field...#. When you open this dialog and select the StyleRef field in the 2&ield names2 list, you will be presented with a list of all the styles currently in use in the document "see &igure 6#. :ust select the one you want to reference and clic/ ;<. )t1s that easy=

&igure 6. $he &ield dialog showing insertion of StyleRef field. 7. )nsert the field by hand. 3ress Ctrl+F9 to insert a pair of field delimiters "the things that loo/ li/e braces but can1t be entered from the /eyboard#. 0etween them, type S$>?*R*& and the e+act name of the style you want to reference, enclosed in quotation mar/s. )n the e+ample shown in &igure 6, the field would be @ S$>?*R*& 2Heading 62 A.

How to create a c aracter style


,lthough a StyleRef field is often used to pic/ up te+t formatted with a specific paragraph style "as in &igure 6#, certain tric/s can be accomplished only by using a character style. , character style is a form of direct font formatting that can combine se!eral font properties. &or e+ample, one of Word1s built.in character styles "the Hyperlin/ style# applies blue font color and underlining. )f you loo/ at the styles listed in Word1s Style dialog "or the Styles and &ormatting tas/ pane in Word 7887 or 788B#, the ones mar/ed with a are character stylesC those mar/ed with D are paragraph styles. "Word 7889 adds further comple+ity to the mar/ing, but the character styles are still recogni5able.# >ou1ll see that many of the character styles don1t really ha!e any special formatting' they1re Eust defined as 2Default 3aragraph &ont F,2 which means that they don1t add anything to the underlying font formatting e+cept a name "which can be helpful in searching for te+t so mar/ed or for changing it to a different formatting#. $he character style you want to create for the tric/s described below will be of this type. Here1s how to do it. 6. ;pen the Style dialog. )f you1re using Word 7888 or earlier, you1ll find Style on the For!at menu. )n Word 7887 or 788B, you may be able to right.clic/ and select Style" from the shortcut menu. ;therwise, display the Styles and For!attin# tas/ pane and clic/ $ew

Style, then s/ip to step B. )n Word 7889 or 7868, use the dialog launcher in the Styles group on the Ho!e tab "or the /eyboard shortcut %lt+Ctrl+S ift+S& to open the Styles window, then clic/ the $ew Style button and s/ip to step B. 7. )n the Style dialog, select 'efault Para#ra( Font and clic/ $ew" "see &igure 7#. ")f you1!e used the $ew Style button in the Styles and &ormatting tas/ pane in Word 78874788B or the Styles window in Word 788947868, you can s/ip this step.#

&igure 7. $he Style dialog. B. )n the $ew Style dialog, type a name for your style, select C aracter for the style type, and ma/e sure that 'efault Para#ra( Font is listed for the 2based on2 style "see &igure B#. Gote that the Create $ew Style fro! For!attin# dialog in Word 788947868 will loo/ considerably different from &igure B but offers much the same choices.

&igure B. $he Gew Style dialog. H. -lic/ ;<. >ou1re done= $o apply this style, select "highlight# the desired te+t and then select the style from the Style dropdown list on the For!attin# toolbar or from the Styles and For!attin# tas/ pane in Word 78874788B or the Styles pane in Word 788947868. ")f you use a style frequently, you may want to assign a /eyboard shortcut for it.#

$ote) If you are creatin# t is style in a docu!ent rat er t an in a te!(late* you can c eck t e +%dd to te!(late+ ,ox in t e $ew Style dialo# to sa-e t e style to t e te!(late so t at it will ,e a-aila,le in any new docu!ent ,ased on t at te!(late. In .ord /0012/030* you can select t e radio ,utton la,eled +$ew docu!ents ,ased on t is te!(late+ to acco!(lis t e sa!e t in#. Pickin# u( (art of a eadin#
;ne of the most common uses of StyleRef fields is to pic/ up chapter titles in the headers "%running heads(# of boo/s and other long documents. )f Heading 6 is used for the chapter title, this is accomplished by putting a @ S$>?*R*& 2Heading 62 A field in the Header, ;dd 3age Header, and4or *!en 3age Header.

0ut what if your chapter title is !ery long or contains line brea/sI )ncluding the entire title will affect the formatting of the header, creating results that are at best unattracti!e "see &igure H#. )f you are the author of the document, you may find it e+pedient to shorten the title itself, but if you ha!e no control o!er the title te+t, heres the wor/around.

&igure H. $he result of using a StyleRef field in the document header to pic/ up a heading that is too long and contains a line brea/. 6. -reate a character style called, say, %Short $itle.( 0ase it on the Default 3aragraph &ont with no other attributes. $hat is, the Short $itle style does not affect the appearance of your heading at allC it Eust o!erlays the paragraph style in!isibly. ")n the figures, the Short $itle style has been gi!en a red font color for illustration purposes.# 7. Gow use the field @ S$>?*R*& 2Short $itle2 A in your header. B. ,pply the Short $itle style to the portion of your heading that you want to appear in your running head "see &igure J#.

&igure J. $he result of using a StyleRef field in the document header to pic/ up a character style applied to part of the heading.

Ca-eats
6. >ou will need to apply the character style to every chapter title, e!en the ones you want included in their entirety. 7. ,lthough it is useful to ha!e nonprinting characters displayed when you are doing this, be aware that, e!en if you carefully select e!erything except the paragraph mar/ "D#, Word will still apply the style to the entire paragraph. $his means that there will be an unwanted paragraph brea/ in the header. &or titles where you ha!e selected the entire title or the last few words of the title, you will ha!e to go bac/ and select Eust the paragraph mar/ and press Ctrl+S(ace,ar to remo!e the character style. $his applies to line ,reaks as well' if you ha!e a two.line heading, bro/en with a line brea/ "S ift+4nter# and want to apply your character style to Eust the second line, no matter how carefully you apply the style to Eust the te+t, carefully omitting the line brea/ and paragraph brea/, you may find that Word

2helpfully2 applies the style to both, and you will ha!e to go bac/ and remo!e it "Ctrl+S(ace,ar#. B. $he StyleRef field "absent any switches# will pic/ up only the first occurrence of the style on the page "see &igure K#. $his means that you cant pic/ up noncontiguous parts of the title' you ha!e to select a continuous phrase to be repeated in the header.

&igure K. )llustrates that a StyleRef field will pic/ up only the first te+t formatted with the referenced style. H. $he character style can be applied only to some or all of the e+isting title. )t might occur to you that you could fa/e this by inserting some Hidden te+t in the e+isting title "see &igures 9 and L#. nfortunately "and maddeningly#, the Hidden property is the only direct font formatting that the StyleRef field does pic/ up. $his is a limitation of the StyleRef field as opposed to typing directly in the header' you can apply a font format to the StyleRef field itself "that is, you can, for e+ample, ma/e all of this portion of the header italic#, but the StyleRef field wont reflect direct font formatting in your heading "if, for e+ample, you ha!e italici5ed one or a few words#. &igure M illustrates this concept.

&igure 9. Shows that a StyleRef field will not pic/ up Hidden te+t.

&igure L. $he te+t shown in &igure H, with field codes displayed to illustrate that the StyleRef field is present but not displaying anything, not e!en as Hidden te+t.

&igure M. Gote that the StyleRef field does not pic/ up the italics applied to King Lear. J. >ou may wonder what happens if you still need a line brea/ in your !ery long title and the part you want to include in the header includes the line brea/. Well, if you actually use a line brea/ in the title, then there will be a line brea/ in the header. 0ut there is a way around using a line brea/. ,s an e+ample, ta/e the !ery long title in &igure 6' %, -hapter $itle $hat )s $oo ?ong to &it -omfortably in the Header.( )nstead of inserting a line brea/ after %?ong,( replace the spaces between all the following words with nonbrea/ing spaces "Ctrl+S ift+S(ace#. $his will force the entire bloc/ of te+t "%to &it -omfortably in the Header(# to the ne+t line without requiring a line brea/. >ou may then, if you li/e, apply the Short $itle style to, say, %, -hapter $itle $hat )s $oo ?ong to &it( "see &igure 68#.

&igure 68. StyleRef field pic/ing up te+t that appears to ha!e a line brea/. ;f course, you can also force the heading to wrap by applying a right indent as required, and this may be preferable if you are also creating a table of contents, as the nonbrea/ing spaces might cause lines in the $;- to wrap short of where you want them to. $ote) $he figures in this article are not meant to represent actual documents. Gaturally, in a real boo/ or manuscript, there would not be a running head on the first page of a chapter "see below for one way to accomplish that#. &or purposes of illustration using a single screen shot, the %chapter title( and header appear on the same page. Noreo!er, default paragraph styles ha!e been usedC no effort has been made to appro+imate the loo/ of a real boo/.

Su((ressin# a StyleRef field


,s we ha!e seen abo!e "-a!eat OH#, Hidden formatting is the only font formatting that a StyleRef field pic/s up. >ou can use this to your ad!antage, howe!er, in combination with the default beha!ior of StyleRef fields' 6. ;n any gi!en page, a StyleRef field in a header or footer will pic/ up the first te+t on the page that is formatted with the referenced style. 7. )f there is no te+t on the page formatted with that style, it will loo/ for the last pre!ious te+t

in that style. What this means for you is that if you ha!e a heading on one page that you want pic/ed up in the headers on subsequent pages but not on the page where it appears, you can accomplish this in one of two ways' 6. >ou can precede the heading with an empty, Hidden paragraph in the same style. ;n the first page, Word will pic/ up the empty paragraph "it doesnt actually ha!e to be Hidden as long as its empty, but it will need to be Hidden if you dont want it to ta/e up space#. $his will wor/ for either paragraph or character styles. 7. >ou can include some Hidden te+t at the beginning of the heading and apply the referenced style to it. $his will require a character style applied carefully. ,s we saw in -a!eat OB abo!e, Word will pic/ up only the first portion of te+t formatted with the character style, so you will need to insert at least two characters, format both as Hidden, and format the first with your referenced style. $hen format the rest of the paragraph with the character style. $ote) 0e careful not to include the final paragraph mar/ in the character styleC see -a!eat O7 abo!e. I!(ortant $ote) ,s noted in "6# abo!e, an empty paragraph in the referenced style will be pic/ed up by the StyleRef field. )f you e!er e+perience problems with missing te+t in a header or footer that contains a StyleRef field, loo/ for these empty paragraphs. )t is helpful to display nonprinting characters, and you can also use the Find dialog to search for the referenced style. ;ne place you may not thin/ to loo/ is in tables' /eep in mind that the end.of.cell mar/er "P# functions the same as a paragraph mar/. )f there is a paragraph brea/ before the end of the cell, then an empty paragraph has been created.

Re(eatin# for! field data in a eader2footer


-reators of protected forms often want the data entered into one form field to be repeated in se!eral other places on the form. $he usual way to do this is to use a R*& field to cross.reference the built. in boo/mar/ of the form field. $his wor/s well in the document body, but R*& fields in the header or footer of a protected form do not update automatically, so this solution does not wor/ well for inserting data in a header or footer. >ou can, howe!er, do this easily with a StyleRef field. 6. ,gain, create a character style. >ou can gi!e it the same name as the boo/mar/ of your form field "see &igure 66#. 0ase it on the Default 3aragraph &ont with no other attributes. $hat is, the character style does not affect the appearance of your form field at allC it Eust o!erlays the paragraph style in!isibly.

&igure 66. $he $e+t &orm &ield ;ptions dialog for a form field with the boo/mar/ 2Game.2 7. ,pply the style to the form field. B. )n the header or footer, insert a StyleRef field to pic/ up the style you created "see &igure 67#.

&igure 67. StyleRef field referencing the 2Game2 character style, which has been applied to the Game te+t form field. $he beauty of the StyleRef field is that it updates automatically and instantly, as soon as data is entered in the form field "see &igure 6B#.

&igure 6B. Result of entering a name in the Game te+t form field.

Custo!i5in# ta,le of contents entries


Recently ) had a question from a user who wanted an unusual type of $;- entry. She was using

three separate paragraphs "in three distinct styles# for ,uthor, $itle, and Subtitle headings but wanted them combined in a single $;- entry with this format' %ut or) Title. Su,title ;ne way to accomplish this "though not a good one# would be to let Word build the $;- from the indi!idual headings, with one $;- entry for each author, each title, and each subtitle, and then, when editing was complete, to unlin/ the $;- and reformat it by hand. Ny suggestion, howe!er, was to use $- fields to build the table of contents. $o build a $;- based on $- fields, you must insert each field separately, using the 6ark Ta,le of Contents 4ntry dialog. $o use the dialog, you select the te+t you want in the $;- and press %lt+S ift+7, which will open the dialog with the selected te+t entered. $he dialog also allows you to select which $;the entry will appear in "if you ha!e more than one# and what $;- le!el the entry will be.

&igure 6H. $he Nar/ $able of -ontents *ntry dialog $he field code generated by the entry shown abo!e will be' 8 TC +% sa!(le eadin#+ 9f C 9l +/+ : $o generate a $;- that uses these fields "and to omit any other entries#, you must chec/ the bo+ for %$able entry fields( and clear the chec/ bo+es for %Styles( and %;utline le!els( in the Ta,le of Contents 7(tions dialog.

&igure 6J. $he $able of -ontents ;ptions dialog. )nserting $- fields is tedious at best, but it would be especially onerous for a user to type in the te+t of the three headings to be included in each $- field that would generate an entry in the %,uthor' $itle. Subtitle( format. $here must be a better way= $here is, using StyleRef fields. *+perimentation pro!ed that the following field would create the desired $;- entry based on three paragraphs in styles named ,uthor, $itle, and Subtitle "they may be either paragraph or character styles#' 8 TC +8 StyleRef +%ut or+ :) 8 StyleRef +Title+ :. 8 StyleRef +Su,title+ :+ : *ach StyleRef field, w en u(dated usin# F9, will display the te+t of the ne+t pre!ious paragraph in the gi!en style, creating a $- field that will generate a $;- entry for the three paragraphs. Noreo!er, if the $- field is sa!ed as an ,uto$e+t entry, it can be easily inserted, without editing, in each location where it is needed. $otes) , $- field containing StyleRef fields may not appear in a paragraph in any of the referenced stylesC this will generate an error message. )nsert the $- field in a body te+t paragraph after the last of the included headings. 0ecause the $;- based on the e+ample shown abo!e will be the main $;- and all entries will be le!el 6, the Qf and Ql switches may be omitted "for more on the switches used in $- fields, see Words Help topic %&ield codes' $- "$able of -ontents *ntry# field(#. $his article copyright R 788J, 788K, 788L, 7866 by Su5anne S. 0arnhill.

Anda mungkin juga menyukai