• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to use "keep with next" feature for a table row when using Structured documents (i.e. DITA)

Explorer ,
Aug 29, 2024 Aug 29, 2024

Copy link to clipboard

Copied

I have a table in which I want to use the "keep with next row" feature. However, I am using DITA, and so the "keep with row" property that is nominally available with FM is not saved with the .DITA file. How do I do this?

 

My attempt:

I know how to modify my EDD files to define choices for outputclass attribute of a table row (i.e. create a new choice "keep with next row" so that the author can select this option when editing). I also know how to add context rules to the EDD to be able to change the style/formatting based on a particular choice of outputclass (i.e. so that the PDF rendering uses a different format/style). What I am not sure how to do is define a style/format for a table row that would "keep with next", because the "keep with next" property is not part of the Table designer. 

 

Q1: Is my approach possible, and if so how would I do it?

 

Q2: Is there another approach that would work and allow an author to "simply" select/indicate that a particular row should be kept with next?

 

Note: I am aware of the solution proposed by @frameexpert  in https://community.adobe.com/t5/framemaker-discussions/is-it-possible-to-group-rows-of-a-table-and-th.... I was able to get that solution to "work", but it is not a super-user-friendly solution for the authors I work with because I could only make the column "invisible" by manually opening the .DITA file in Notepad++ and manually editing the colspec attribute: colwidth="0.1". I would prefer that the authors can do everything they need in FM.

TOPICS
Formatting and numbering , Structured

Views

295

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Aug 30, 2024 Aug 30, 2024

This 5-minute video will answer your questions.

https://youtu.be/uAdTXp5eY2o

Votes

Translate

Translate
Community Expert ,
Aug 29, 2024 Aug 29, 2024

Copy link to clipboard

Copied

You could have the DITA authors set an outputclass attribute value of, say for instance, "keep-with-next" on those rows. However, you can't use the EDD to automatically set the row format to Keep With Next Row, based on the attribute value. You would need a script that would look for this outputclass value and programmatically set the property on the table row. The script would be relatively straightforward.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 29, 2024 Aug 29, 2024

Copy link to clipboard

Copied

Thanks. I will have to ponder the script approach.

 

Having started to play with the invisible column approach, it does have some advantages (i.e. explicitly organizing a group of rows). However, I also discovered that I did not fully/properly test this approach. It turns out that when a .DITA file is opened and saved, it will auto-magically change colwidth="0.1" to colwidth="0*", which creates a rather wide/visible column. So as long as I do not save the .DITA file, the colwidth="0.1" will be kept (and used), which is a bit awkward. colwidth="1*" is kept, but that is still visible.

 

Any other suggestions on how to make a column in a table invisible? Or does that also require a script?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 29, 2024 Aug 29, 2024

Copy link to clipboard

Copied

You can apply a Condition Format to a table column, then hide the Condition.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 29, 2024 Aug 29, 2024

Copy link to clipboard

Copied

Thanks. I was starting to look up how to do that, but then realized I should confirm a couple of things:

  • Will this work with DITA files? If so, how does one apply a condition to a column in a table?
  • Does this require a script?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 30, 2024 Aug 30, 2024

Copy link to clipboard

Copied

This 5-minute video will answer your questions.

https://youtu.be/uAdTXp5eY2o

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 30, 2024 Aug 30, 2024

Copy link to clipboard

Copied

That was very insightful.

While I can show/hide the column using this method while editing, the extra column always appears in my generated PDF. I have looked at the output template that was imported into my .STS file (i.e. for Chapter Output) and it has the "DITA-Comment" tag in the Hide column. Any quick guesses on what is going on?

 

(NOTE: My console shows the following errors when generating a PDF, and has always done so:

"Show/Hide setting for DITA-Comment is inconsistent.")

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 30, 2024 Aug 30, 2024

Copy link to clipboard

Copied

How are you producing your PDF?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 31, 2024 Aug 31, 2024

Copy link to clipboard

Copied

I select Publish > PDF

I have tried both FM2020 (16.0.4) and FM2022 (17.0.4).

I have tried both my .STS file (see below) and the default .STS file.

In all cases the column appears in the PDF, while it is

STS screenshot.JPG

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 31, 2024 Aug 31, 2024

Copy link to clipboard

Copied

You have to figure out which template FrameMaker is using for the PDF and make sure the condition is hidden in that template. That's probably the subject of a new post.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 30, 2024 Aug 30, 2024

Copy link to clipboard

Copied

Here is a teaser script that will allow you to use DITA markup to control Keep With Next Row setting. Follow these steps to set it up:

  1. Open a DITA topic that has tables in it.
  2. Go to your row or rows that you want to set to keep with next row.
  3. Change the outputclass attribute on the row element(s) to "keep-next".
  4. Run the script below.

 

#target framemaker

main ();

function main () {

    var doc, element;
    
    doc = app.ActiveDoc;
    if (doc.ObjectValid () === 1) {
        // Make sure the document is structured.
        element = doc.MainFlowInDoc.HighestLevelElement;
        if (element.ObjectValid () === 1) {
            processDoc (doc, element);
        }
    }
}

function processDoc (doc, element) {
    
    var tbls, count, i;
    
    if (app.Displaying === 1) {
        app.Displaying = 0;
    }

    // Get all of the tables in the document's main flow.
    tbls = getMainFlowTables (doc);
    // Process each table.
    count = tbls.length;
    for (i = 0; i < count; i += 1) {
        processTbl (tbls[i], doc);
    }
    
    if (app.Displaying === 0) {
        app.Displaying = 1;
        doc.Rehyphenate ();
        doc.Redisplay ();
    }
}

function processTbl (tbl, doc) {
    
    var row, element, value;
    
    // Loop through the rows in the table.
    row = tbl.FirstRowInTbl;
    while (row.ObjectValid () === 1) {
        // Get the row element of the row object.
        element = row.Element;
        value = getAttributeValue (element, "outputclass");
        if ((value) && (value === "keep-next")) {
            row.RowKeepWithNext = 1;
        }
        else {
            row.RowKeepWithNext = 0;
        }
        row = row.NextRowInTbl;
    }
}

function getMainFlowTables (doc) {
    
    var tbls, textList, count, i;
    
    // Make an array for the table objects.
    tbls = [];
    
    // Get all the table text items from the main flow of the document.
    textList = doc.MainFlowInDoc.GetText (Constants.FTI_TblAnchor);
    count = textList.length;
    // Add each Tbl object to the array.
    for (i = 0; i < count; i += 1) {
        tbls.push (textList[i].obj);
    }
    
    // Return the array.
    return tbls;    
}

function getAttributeValue (element, name) {
    
	var attrList, count, i;
	
    attrList = element.Attributes;
    count = attrList.length;
    for (i = 0; i < count; i += 1) {
        if (attrList[i].name === name) {
            if (attrList[i].values[0] !== undefined) {
                return (attrList[i].values[0]);
            }
        }
    }
}

Why do I call it a teaser script?

  1. Because you have to run it manually every time you open a topic in FrameMaker. A production version would be run automatically whenever you open a topic.
  2. I have only added the option for Keep With Next Row ("keep-next"). A production script could add other options such as "keep-previous", "next-page", "next-column", etc. In other words, you would have options to match what is in the Row Format dialog box.
  3. Any other things that amazing users like you come up with.

 

image.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 12, 2024 Sep 12, 2024

Copy link to clipboard

Copied

This was the answer I was hoping that was marked correct. Here is a video about a free script that you try:

https://youtu.be/tU8vshrS2sA?si=A3jxcxqLgstl-tv0

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 13, 2024 Sep 13, 2024

Copy link to clipboard

Copied

@frameexpertsorry! I think these are both good answers. I selected the other answer for two reason:

- I have not used any scripts with FM before

- the other solution can solve other, related problems as well

So for anyone else reading his - please look at both answers!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 13, 2024 Sep 13, 2024

Copy link to clipboard

Copied

LATEST

No problem, I was just be facetious. It gave me a chance to write a useful script.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines