This is the situation: I am converting html to xsl-fo to pdf. I am displaying a heading text like "4.4.1. [Header Text]" by use of a table, because it might happen that the [Header Text] is quite long and in that case shall wrap onto the next line like so:
[table-row] [cell with numbering] [cell with header text] [/table-row]
There are 4 different cases how the header may be composed:
- header text single line
- header text wraps onto next line
- header text single line with superscript
- header text wraps onto next line with superscript
The problem is that superscript will increase the row's height and mess with the vertical text alignment. This is how it would look by default in all 4 cases:
__________________________ |_1.2.3_|_header_text____| <<< OK __________________________ | 1.2.3 | long long long | <<< OK |_______|_header_text____| __________________________ | 1.2.3 | (1) | <<< NOT OK |_______|_header_text____| __________________________ | 1.2.3 | long long long | <<< OK | | (1) | |_______|_header_text____|
As you can see, in case no.3 the numbering and most of the header text are not aligned in a nice way.
I could solve case no.3 by using display-align="after" on the table-cell with the numbering. But in order not to mess up the other 3 cases, I would need to determine whether the content of the header text will wrap onto the next line or not. The font I am using for output is not monospaced, this is why counting characters would be an approximation, at best.
My question is, how it could be done so that case 3 looks like:
__________________________ | | (1) | |_1.2.3_|_header_text____|
while the others stay the same.
EDIT: example of the markup for case 3
<fo:table font-size="18pt" font-weight="bold" font-style="italic" space-after="2mm" space-before="7mm" keep-with-next.within-page="always"> <fo:table-column column-width="16mm"/> <fo:table-column/> <fo:table-body> <fo:table-row> <fo:table-cell> <fo:block>1.2.3</fo:block> </fo:table-cell> <fo:table-cell> <fo:block> <fo:block text-align="left"> <fo:block>Header Text (<fo:inline baseline-shift="super">1</fo:inline>) </fo:block> </fo:block> </fo:block> </fo:table-cell> </fo:table-row> </fo:table-body> </fo:table>
EDIT 2: I tried to reverse the superscript-logic:
- don't use superscript markup on the text that should be superscript
- wrap all text parts of the heading (including the numbering) that should be superscript in
This "worked", I tested it for cases 3 + 4 and the heading text was in-line with the numbering in both cases.
But it has the drawback that I get a little extra spacing on top of the heading and that I would have to twist around to completely revert the superscript settings in the heading.