none
How does para keep together impact tables? RRS feed

  • Question

  • Hi;

    I think this is easy but I'm not clear on exactly how this works. The following content can easily fit on the page before, but not all of it (the table continues down).

    Every paragraph in the above, both in the tables and between the tables, is set to "Keep with next" and "Keep lines together."

    But in the table properties ever row is set to "Allow row to break across pages."

    Clearly how Word treats this is that this all must be kept on the same page. But what is the exact rules here? When do the para properties override row breaks? And when do they force a table to be on the same page as it's adjoining paragraph?

    thanks - dave


    What we did for the last 6 months - Made the world's coolest reporting & docgen system even more amazing

    Saturday, December 7, 2019 4:29 PM

Answers

  • Hi Dave

    Incorrect section number for Style Hierarchy were provided in my previous reply. Correct section reference should read 17.7.2 Style Hierarchy.

    The order of precedence that needs to be applied to the styles is described in detail under 17.7.2 Style Hierarchy and 17.7.3 Toggle Properties. Section 17.7.3 also contains the algorithm that you are looking for and I will not paste it here fully since it's rather lengthy.

    I shared your questions with the Product Team, following is their reply:

    1. If a table row does not "allow row to break across pages", the whole row will be kept on the same page. However, if it allows page break, each cell of the row can make its own decision.
    2. Each cell is interpreted as an independent stream. The possibility of a break in the content inside one cell is governed by the same rules as for the text outside of the table.
    3. It is counter-intuitive, but If the first paragraph of the row has “Keep with Next” property, the whole row gets “DoNotBreakInsideAfter” property. It means that page break between this row and next row as well as break inside this row is prohibited if the first paragraph of the row has “Keep with next” property.

    In the example from the thread, page breaks inside rows were prohibited by (2) because neither cell could produce break due to “Keep with Next”/”Keep Together” properties on each text paragraph (and independently by (3) because all rows got “DoNotBreakInsideAfter” property). Breaks between rows were prohibited with (3) because first paragraph of each row has “Keep with next” property.

    Hung-Chun Yu | Microsoft Protocols Open Specifications Team

    • Marked as answer by DavidThi808 Tuesday, December 17, 2019 10:21 PM
    Tuesday, December 17, 2019 10:19 PM

All replies

  • Hi Dave,

    Thank you for posting your Office File formats question. One of our engineers will respond to assist. 

    Thanks,


    Jeff McCashland | Microsoft Protocols Open Specifications Team

    Saturday, December 7, 2019 4:57 PM
    Moderator
  • Hi Dave

    Thank you for the question, I will be assisting you with your questions.

    To re-iterate your questions:

    You would like to know how Paragraph properties rules work with a table under Microsoft Word. In particular, the case where Paragraph is set to “Keep with next” and “Keep lines together.”  

    I would like to know which version of Microsoft Word that you are using? Could you share the document that you are having issue with or provide steps on how to recreate the issue, so I can better assist you?

    Thank You

    Hung-Chun Yu | Microsoft Protocols Open Specifications Team

    Monday, December 9, 2019 7:40 PM
  • Hi;

    I am using 32-bit Word 365 on 64-bit Windows. The sample file for the above screenshot is ATE-2554.docx. As you can see, the top of page 2 can easily fit on page 1 if it breaks between table rows or between a table & paragraph.

    thanks - dave


    What we did for the last 6 months - Made the world's coolest reporting & docgen system even more amazing

    Monday, December 9, 2019 8:01 PM
  • Hi Dave

    Here is what I found. Table Properties “Allow row to break across pages” are applied first, followed by Paragraph properties Keep with next and Keep lines together.” Therefor Paragraph properties overwrite Table Properties, as the result you see the empty gap on first page of your sample document. With ISO/IEC 29500-1:2016(E) Section 17.2.2 Style Hierarchy gives detail illustration the rules that Microsoft Word follows.

    Let me know if this answers your question.

    Hung-Chun Yu | Microsoft Protocols Open Specifications Team

    Tuesday, December 10, 2019 11:13 PM
  • Hi Hung-Chun;

    Thank you for your answer. So paragraph properties override row properties to make the row keep together/with next.

    So the next question is, what has to be set in the paragraph? What if a cell is 3 paragraphs long and only the last paragraph is keep with next? What if the cell in column [0] is not keep with next, but in column [1] it is?

    And my concern is what does Word look at? I can test lots of different use cases, but that doesn't mean I will match Word for other use cases. So what is the complete logic for when the paragraph properties override the row property?

    thanks - dave


    What we did for the last 6 months - Made the world's coolest reporting & docgen system even more amazing

    Tuesday, December 10, 2019 11:17 PM
  • Let me paraphrase your questions.

    1. Paragraph Properties for each cell in relationship with Row Properties with Table under Microsoft Word.
    2. “Keep with Next Properties” from multiple columns
    3. Complete Logic when the Paragraph Properties override the Row Properties.

    With my additional research, I found out the following:

    1. With Table, Paragraph Properties overwrites Row Properties.
    2. From my testing with “Keep with Next”, I noticed that Microsoft Word only checks the left most cell in a given row. Let me know if you observed the similar behavior.
    3. We do not have an exhaustive description for all possible combinations and scenarios and coming up with something like that could be very complex. We can always address specific situations (i.e. what happens when column 0’s last paragraph in the cell has “Keep with next” set to “off” and column 1’s first paragraph has it set to “on”?) and try to describe what happens.

    Let me know your questions have been answered.

    Hung-Chun Yu | Microsoft Protocols Open Specifications Team

    Wednesday, December 11, 2019 11:36 PM
  • We do not have an exhaustive description for all possible combinations and scenarios and coming up with something like that could be very complex.

    Our problem is we are creating PDF files from a DOCX file as part of our library. So we do not know what our various customers will do. So we don't know what combinations to check.

    In addition, when we find a new situation, telling a customer they need to wait 6 weeks while we determine what the situation is for their specific case, adding code in for that, and then wait until our next release ships - isn't acceptable.

    What I'm asking here is not what testing shows, I can do that. I'm asking what the DOCX specification, as implemented by Word, does. Without this information in the spec, complete information, then the DOCX spec is incomplete.

    Can you please ask the Word team to document this?

    thanks - dave


    What we did for the last 6 months - Made the world's coolest reporting & docgen system even more amazing

    Wednesday, December 11, 2019 11:44 PM
  • Hi Dave

    I stand correct on my answer to “Keep with Next Properties” from multiple columns. My test result was incorrect. “Keep with Next Properties” does work correctly with any columns, not just left most column.

    Microsoft Word does follow ISO/IEC 29500-1:2016(E) Section 17.2.2 Style Hierarchy accordingly. Go back to the simple file ATE-254.docx, “Allow row to break across pages” is set for the table that is at the top of the second page. At the same time, each cell’s Paragraph Properties is set with "Keep with next". By the Style Hierarchy Standard, Microsoft Word did correctly apply the Properties for Table first, followed by Properties for Paragraph, as the result we see the big gap at the bottom of the first page.

    If your implementation team found that Microsoft Word is not following the Style Hierarchy in applying these Table and Paragraph Properties, let me know. I will be more than happy to address this with the product team to get the correct behavior documented for that case.

    Hung-Chun Yu | Microsoft Protocols Open Specifications Team

    Thursday, December 12, 2019 1:16 AM
  • Thank you but 17.2.2 in ISO_IEC_29500-1_2016 is the body element. And the style sections I did find for tables did not mention paragraph properties.

    And some more detail questions:

    1. If column[0] paragraphs are not set to "keep with ..." but column [1] is - is that no break? In other words, if any 1 column is set to "keep with..." is that sufficient?
    2. What if there are 2 paragraphs in the cell and they are set to "keep together" but not "keep with next"?
    3. What if there are 2 paragraphs in the cell and they are set to "keep with next" but not "keep together"?

    We really need to know what Word is doing here - for all cases, not just what we test.

    ??? - thanks - dave


    What we did for the last 6 months - Made the world's coolest reporting & docgen system even more amazing

    Thursday, December 12, 2019 11:46 PM
  • Hi Dave

    Incorrect section number for Style Hierarchy were provided in my previous reply. Correct section reference should read 17.7.2 Style Hierarchy.

    The order of precedence that needs to be applied to the styles is described in detail under 17.7.2 Style Hierarchy and 17.7.3 Toggle Properties. Section 17.7.3 also contains the algorithm that you are looking for and I will not paste it here fully since it's rather lengthy.

    I shared your questions with the Product Team, following is their reply:

    1. If a table row does not "allow row to break across pages", the whole row will be kept on the same page. However, if it allows page break, each cell of the row can make its own decision.
    2. Each cell is interpreted as an independent stream. The possibility of a break in the content inside one cell is governed by the same rules as for the text outside of the table.
    3. It is counter-intuitive, but If the first paragraph of the row has “Keep with Next” property, the whole row gets “DoNotBreakInsideAfter” property. It means that page break between this row and next row as well as break inside this row is prohibited if the first paragraph of the row has “Keep with next” property.

    In the example from the thread, page breaks inside rows were prohibited by (2) because neither cell could produce break due to “Keep with Next”/”Keep Together” properties on each text paragraph (and independently by (3) because all rows got “DoNotBreakInsideAfter” property). Breaks between rows were prohibited with (3) because first paragraph of each row has “Keep with next” property.

    Hung-Chun Yu | Microsoft Protocols Open Specifications Team

    • Marked as answer by DavidThi808 Tuesday, December 17, 2019 10:21 PM
    Tuesday, December 17, 2019 10:19 PM
  • Tuesday, December 17, 2019 10:22 PM
  • Hi;

    One remaining question - does this also hold for the first para in any cell set to keepTogether too? Or just for keepWithNext?

    thanks - dave


    What we did for the last 6 months - Made the world's coolest reporting & docgen system even more amazing

    Friday, January 3, 2020 10:47 PM
  • Here is the Product Group's Reply

    If it is regarding (3), then answer is: No, KeepTogether property is not extended to the row. Also (3) is about the KeepWithNext property of the first paragraph in the ROW (not any cell) influencing properties of the ROW.


    HungChun Yu (MSFT)

    Monday, January 6, 2020 8:11 PM
  • You said above:

    >> “Keep with Next Properties” does work correctly with any columns, not just left most column.

    Is that not correct? It's just the first paragraph in the first cell of the row?

    thanks - dave


    What we did for the last 6 months - Made the world's coolest reporting & docgen system even more amazing

    Monday, January 6, 2020 9:02 PM
  • I will go with what Product Group's reply - KeepWithNext property of the first paragraph in the ROW (not any cell) influencing properties of the ROW.


    HungChun Yu (MSFT)

    Monday, January 6, 2020 11:07 PM