#1
|
|||
|
|||
Issue with figure captions (word 2010)
This is strange.
I have a bunch of figures in my document. I am creating captions for them. I select the image, click "insert caption" and follow the instructions. Sometimes when I do this, the caption appears as a line of text within the regular text flow, above the image. Sometimes when I do this, the caption appears inside a separate text box, that is isolated from the rest of the text, above the image. When I want to create a cross reference to a figure, the list of figures that appears in the "create cross reference" dialog has two sections.... the ones that are inline text appear first, and then the ones that are in text boxes. So they are out of order. Luckily this does not affect the List of Figures; the list is in the right order and does not pay attention to the two types of captions. However, the two types of captions look different in the document. the ones in the text boxes are higher up above the figure. I would like to understand why there are two types and make them all the same for consistency purposes. I have tried a few things but nothing seems to work. Does anyone have any idea why I'm getting the two types of captions and what I could do to make them all the same (I prefer the inline text type because it appears right above the figure). Thank you. Gary Beckwith Technical Writer for IBM |
#2
|
||||
|
||||
The difference in behaviour is related to the wrap format of the images. If they're in-line with text, Word is programmed to insert the captions that way too. If they're square, for example, Word is programmed to insert the captions into a textbox. IMHO, the latter is dumb, as there is no necessary connection between the caption and its image and the caption numbering becomes dependent on where the caption is anchored, and the anchor's order in the document, not on the anchor position of the image to which it relates. The treatment of inline images really isn't much better as it's all too easy to move the image without its caption.
The following macro embeds all images (i.e. Shapes & InlineShapes) in a document in tables with a row for Captions. Code:
Sub AddImageCaptionTables() Dim iShp As InlineShape, Rng As Range, Tbl As Table Dim i As Long, PicWdth As Single, VPos As Single Dim HPos As Single, VRel As Long, HRel As Long With ActiveDocument For i = 1 To .InlineShapes.Count If .InlineShapes(i).Range.Information(wdWithInTable) = False Then PicWdth = .InlineShapes(i).Width Set Rng = .InlineShapes(i).Range With Rng If .Characters.Last.Next.Text = vbCr Then .Characters.Last.Next.Text = vbNullString .InlineShapes(1).Range.Cut End With 'If you don't want a row for captioning etc, change the 2 in the next line to 1. Set Tbl = .Tables.Add(Range:=Rng, Numrows:=2, NumColumns:=1) With Tbl With .Cell(1, 1).Range.ParagraphFormat .SpaceBefore = 0 .SpaceAfter = 0 .LeftIndent = 0 .RightIndent = 0 .FirstLineIndent = 0 .KeepWithNext = True End With .Cell(1, 1).Range.Paste 'If you don't want to add captions, delete from here to 'End With' Set Rng = .Cell(2, 1).Range With Rng .Style = "Caption" .End = .End - 1 .InsertAfter vbCr .InsertCaption Label:="Figure", TitleAutoText:=" ", Title:="", _ Position:=wdCaptionPositionBelow, ExcludeLabel:=0 .Characters.First.Text = vbNullString .Paragraphs.First.Range.Characters.Last.Text = vbNullString End With .Borders(wdBorderLeft).LineStyle = wdLineStyleNone .Borders(wdBorderRight).LineStyle = wdLineStyleNone .Borders(wdBorderTop).LineStyle = wdLineStyleNone .Borders(wdBorderBottom).LineStyle = wdLineStyleNone .Borders(wdBorderHorizontal).LineStyle = wdLineStyleNone .Borders(wdBorderVertical).LineStyle = wdLineStyleNone .TopPadding = 0 .BottomPadding = 0 .LeftPadding = 0 .RightPadding = 0 .Spacing = 0 .Columns.Width = PicWdth End With End If Next While .Shapes.Count > 0 With .Shapes(1) VRel = .RelativeVerticalPosition HRel = .RelativeHorizontalPosition VPos = .Top HPos = .Left PicWdth = .Width Set iShp = .ConvertToInlineShape End With With iShp Set Rng = .Range .Range.Cut End With 'If you don't want a row for captioning etc, change the 2 in the next line to 1. Set Tbl = .Tables.Add(Range:=Rng, Numrows:=2, NumColumns:=1) With Tbl With .Rows .LeftIndent = 0 .WrapAroundText = True .HorizontalPosition = HPos .RelativeHorizontalPosition = HRel .VerticalPosition = VPos .RelativeVerticalPosition = VRel .AllowOverlap = False End With With .Cell(1, 1).Range.ParagraphFormat .SpaceBefore = 0 .SpaceAfter = 0 .LeftIndent = 0 .RightIndent = 0 .FirstLineIndent = 0 .KeepWithNext = True End With .Cell(1, 1).Range.Paste 'If you don't want to add captions, delete from here to 'End With' Set Rng = .Cell(2, 1).Range With Rng .Style = "Caption" .End = .End - 1 .InsertAfter vbCr .InsertCaption Label:="Figure", TitleAutoText:=" ", Title:="", _ Position:=wdCaptionPositionBelow, ExcludeLabel:=0 .Characters.First.Text = vbNullString .Paragraphs.First.Range.Characters.Last.Text = vbNullString End With .Borders(wdBorderLeft).LineStyle = wdLineStyleNone .Borders(wdBorderRight).LineStyle = wdLineStyleNone .Borders(wdBorderTop).LineStyle = wdLineStyleNone .Borders(wdBorderBottom).LineStyle = wdLineStyleNone .Borders(wdBorderHorizontal).LineStyle = wdLineStyleNone .Borders(wdBorderVertical).LineStyle = wdLineStyleNone .TopPadding = 0 .BottomPadding = 0 .LeftPadding = 0 .RightPadding = 0 .Spacing = 0 .Columns.Width = PicWdth End With Wend End With End Sub As coded, the macro inserts the caption row below its image If you want them to be above the images, swap the .Cell(1, 1) and .Cell(2, 1) references around (i.e. all .Cell(1, 1) references become .Cell(2, 1) and vice-versa).
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
thanks for the info!
so I prefer the in-line captions because they create less white space and that's how the majority of the ones in this document are set up. I'm trying to convert the text box captions into in-line captions. Based on your info, if I change the format of the image to "inline" or "square" I should be able to control the type of caption that is created for it, correct? it doesn't seem to be working. if I remove the caption, change the image format to inline, then make a new caption, it still shows up as a text box. any suggestions? thanks again |
#4
|
||||
|
||||
If the images are in-line, right-clicking on them and choosing Insert Caption gives you the option of inserting it above or below the image. In either case, it's inserted into a normal paragraph (with the Caption Style applied)
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
Quote:
-I found one image that has the text-box style caption, that I want to change to in-line caption. -I right click on the image, choose Format Drawing Canvas, and change the Layout to "inline with text" -remove the old caption (that is text box style) -create new caption -the new caption is still in a floating text box. POO. I confirmed the image has been changed to "inline with text" but I'm still getting a floating text box for the caption. any other tricks to try? thanks, gary |
#6
|
||||
|
||||
I haven't been able to replicate that.
Can you attach a document to a post with the offending image (delete anything sensitive)? You do this via the paperclip symbol on the 'Go Advanced' tab at the bottom of this screen.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#7
|
|||
|
|||
I had the exact same problem. Word would just change the layout of the object back to "in front of text" no matter how many times I would change it to "in line with text" every time I added a caption. Really annoying!!
I have solved it now by making sure that I paste the figures in as pictures, not as shapes. Then all the captions appear as "in line with text". |
#8
|
||||
|
||||
That might work for you - it won't work for anyone who wants to wrap the text around the image.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Wrong numbering in Figure/Tables' captions | Shauheen | Word | 6 | 06-13-2017 12:07 PM |
Broken Table/Figure Captions with Headings | kokopelli_2001 | Word | 1 | 06-07-2013 04:50 AM |
Figure group and captions | sdabach | Word | 3 | 02-21-2013 12:07 AM |
Independent figure captions | steel_lady | Word | 4 | 08-21-2012 04:33 PM |
Word 2010 image and table captions style | chaji | Word | 0 | 09-22-2010 03:59 PM |