Skip to main content
Inspiring
August 29, 2024
Question

Floating graphics with captions

  • August 29, 2024
  • 5 replies
  • 954 views

Greetings,

 

Am I correct in assuming that the only way to have figures with captions that float and can be programmatically placed, e.g., at top of column, at bottom of column etc. is to use an anchored frame that is taller than the graphic and insert a text box inside the bottom of the frame?

 

Obviously, I cannot use the "one row table with the table title at bottom" method, since tables cannot float at the same time as they are programmatically placed, e.g., at top of column, at bottom of column etc. Those choices are mutually exclusive. Which - if I'm not missing something - is a major disadvantage that I cannot understand is not fixed yet.

 

And I can neither use an anchored frame with a next para tag for the figure title, as that title is kept with the insertion point and not the programmatically repositioned anchored frame e.g. on the next page.

 

Am I missing any other methods?

 

/Mats

    This topic has been closed for replies.

    5 replies

    Inspiring
    September 6, 2024

    Bob - thanks! Also a good idea with the metadata and object ID.

     

    Yatani - script works great, many thanks! 

     

    Matt - this is a very basic usage scenario in figure management for technical documentation, so I wouldn't exactly call it "my standard".

     

    /Mats

    Participating Frequently
    September 5, 2024

    I created a script that adds a text frame to a selected anchor frame.
    ・Edit the paragraph tag name for the caption on line 7.
    ・Please select either an anchor frame, the contents of an anchor frame, or the anchor point of an anchor frame before running the script.
    ・Multiple anchor frames can be processed at once.
    ・Undo is not possible. Save your document before running the script.

    function f_addTextFrame (aFrame){
        // Set the anchored frame position
        aFrame.AFrameIsFloating = true;
        aFrame.AnchorType = Constants.FV_ANCHOR_TOP;
        aFrame.Alignment = Constants.FV_ALIGN_CENTER;
        // The name of the paragraph tag to use in the caption (Change it as needed)
        var pgfFmt = doc.GetNamedPgfFmt("Caption"); 
        if (pgfFmt.ObjectValid()){
            var pgfFmtProps = pgfFmt.GetProps();
            // Add a text frame to an anchored frame
            var textFrame = doc.NewTextFrame (aFrame); 
            textFrame.FirstPgf.SetProps(pgfFmtProps);
            textFrame.Width = aFrame.Width;
            textFrame.Height = pgfFmt.FontSize;
            textFrame.LocY = aFrame.Height + pgfFmt.SpaceAbove;
            // Increase the height of the anchored frame
            aFrame.Height = aFrame.Height + pgfFmt.SpaceAbove + pgfFmt.FontSize + pgfFmt.SpaceBelow;
        }
    }
    
    var doc = app.ActiveDoc;
    if (doc.ObjectValid()){
        var graphic = doc.FirstSelectedGraphicInDoc;
        if (graphic.ObjectValid()){
            if (graphic.type == Constants.FO_AFrame){
                // The anchor frame is selected.
                f_addTextFrame (graphic);
            } else if (graphic.FrameParent.type == Constants.FO_AFrame){
                // The contents of the anchored frame are selected.
                f_addTextFrame (graphic.FrameParent);
            }
        }
        var tr = doc.TextSelection;
        var textItems = doc.GetTextForRange (tr, Constants.FTI_FrameAnchor);
        for (var i=0;i<textItems.length;i++){
            //The anchor points of the anchor frame are selected.
            f_addTextFrame (textItems[i].obj);
        }    
    }
    Inspiring
    September 3, 2024

    Hi Bob,

     

    Not, it doesn't work because this method doesn't backfill the empty area between the original anchoring position and the forced new position. See enclosed test.

     

    Actually, FrameMaker does indeed support "Float" and "Top of column" properties at the same time, but only for anchored frames per se, not for an anchored frame that you want to be tied to a caption. So if you change the placement property for the anchored frame to "Float" and "Top of column" and the AnchorFigure > Pagination  to "Anywhere", the empty space is backfilled but the caption is now untied from the frame.

     

    Mats

    Bob_Niland
    Community Expert
    Community Expert
    September 3, 2024

    Thanks for the correction, Mats.

    This would then tend to argue for putting a Text Frame in the AF.

    And in a prior situation, that's what I did. The TF further used a Table for the caption, which had 3 columns, for Meta, Caption and ObjectID. Meta was document steward info about the graphic type, scale, transforms; hidden by Color View for pub. Caption was just a "Figure ## \r text-string" autonumber. ObjectID was an n-digit accession number assigned enterprise-wide.

    Matt-Tech Comm Tools
    Community Expert
    Community Expert
    August 30, 2024

    I'm not sure if I completely follow your needs here, but it sounds like you are describing my rationale for placing figure titles above the frame.

    Not only does this solve my (perhaps not your) placement needs, it also improves the resulting hyperlinks to figure titles, as the figure isn't placed above the active window when displaying the figure title.

    For me, placing the figure title in a text frame in an anchored frame causes too many issues.

     

    -Matt Sullivan, FrameMaker Course Creator, Author, Trainer, Consultant
    Inspiring
    August 31, 2024

    Hi Matt,

     

    What I want to achieve is to be able to place figure plus its figure title according to the following:

     

    1. Figure and figure title shall always be kept together.
    2. Figure title shall be below the figure.
    3. The figure and its title shall be output at the top of the column (current or next), regardless of the figure's anchor point.
    4. The figure and its title shall float, i.e., any space on the page after the figure's anchor point shall be filled with the text that follows.

     

    So, these are the options that I can see and none are working:

     

    1. Cannot use the method with a graphic in a 1 row, 1 column table with a table title below, as tables cannot float and have "Top of column" placement.
    2. Cannot use an anchored frame (with float and "Top of column") where a figure title para tag follows the anchor point para tag (keep with next for the anchor point para tag), as the anchor point para tag is not included in FrameMaker's "Top of column" forced placement.

     

    This is such a basic usage scenario in figure management in technical documentation that I am convinced I am missing something. The only solution I can come up with is is to use an anchored frame that is taller than the graphic and insert a text box inside the bottom of the frame. But this is really cumbersome.

     

    If Adobe made "Float" for tables into a checkbox (as it is for anchored frames) instead of a dropdown menu choice, this would be a walk in the park.

     

    Mats

    Bob_Niland
    Community Expert
    Community Expert
    August 31, 2024

    Either an Anchored Frame or a Table could be used, with the properties of the anchoring para set to Top of Column.

    The anchoring para could be empty, but I usually have it contain an autonumber text of "¶TableAnchor" or "¶FrameAnchor", and the para set to a color named Authoring, switched on and off in Color Views.

    For ¶FrameAnchor, At Insert Point, and Keep With Next for caption as next para. Centering the caption would require some hack if the frame isn't full column width.

    For ¶TableAnchor, the double-negative vertical spacing trick would be needed, to align the Table top at top of column.

    Bob_Niland
    Community Expert
    Community Expert
    August 29, 2024

    As FM so far lacks Frame-Above, what you descibe is what I've always done for captions.