Как выровнять 2 блока по вертикали с помощью выноски

Мне нужно использовать fo:leader для создания таблицы с такими запросами и ответами:

лидер таблицы вот так

Однако конечный результат таков:

Оба блока выравниваются сверху

Моя проблема заключается в том, что левый блок имеет 2 строки, а правый блок имеет 2 строки, обе из которых выравниваются сверху. Мне нужно выровнять левый блок сверху и правый блок снизу.

Это возможно?

Следуйте действительному коду:

<fo:inline-container vertical-align="top" inline-progression-dimension="60%">
<fo:block start-indent="0.5em" text-indent="-0.5em" text-align-last="justify" margin-right="0.3cm"<xsl:value-of select="challenge/para|limitdesc/para|sopitem/para"/>
<fo:leader leader-pattern="dots"/</fo:block>
</fo:inline-container>
<fo:inline-container relative-position="relative" vertical-align="bottom" display-align="after" inline-progression-dimension="40%">
<fo:block start-indent="0.5em" text-indent="-0.5em" display-align="after"><xsl:value-of select="response/para|limitvalue/para|limittext/para|act/para"/></fo:block>
</fo:inline-container>

person Audye Junior    schedule 07.05.2018    source источник
comment
Какой форматтер вы используете?   -  person Tony Graham    schedule 08.05.2018
comment
AHFormatter 6.5   -  person Audye Junior    schedule 08.05.2018


Ответы (2)


Я попытался использовать AH Formatter и нашел два решения.

[1] Используйте baseline-shift для последнего fo:inline-container

<fo:block>
    <fo:inline-container vertical-align="top" inline-progression-dimension="60%">
        <fo:block start-indent="0.5em" text-indent="-0.5em" text-align-last="justify">
            [1] Text here text here text here text here text here text here text here
            <fo:leader leader-pattern="dots"/></fo:block></fo:inline-container><fo:inline-container baseline-shift="-1.44em" inline-progression-dimension="40%">
        <fo:block start-indent="0.5em" text-indent="-0.5em" display-align="after">
            Continued text here text here text here text here
        </fo:block>
    </fo:inline-container>
</fo:block>

Я указываю `baseline-shift="-1.44em". (Это зависит от используемого шрифта) Этот метод работает, только если количество первой строки равно 2.

[2] Используйте fo:table вместо fo:inline-container

<fo:table width="100%">
    <fo:table-column column-number="1" column-width="60%"/>
    <fo:table-column column-number="2" column-width="40%"/>
    <fo:table-body>
        <fo:table-row>
            <fo:table-cell>
                <fo:block start-indent="0.5em" text-indent="-0.5em" text-align-last="justify">
                    [2] Text here text here text here text here text here text here text here
                    <fo:leader leader-pattern="dots"/></fo:block>
            </fo:table-cell>
            <fo:table-cell/>
        </fo:table-row>
        <fo:table-row>
            <fo:table-cell/>
            <fo:table-cell padding-before="-1.32em">
                <fo:block start-indent="0.5em" text-indent="-0.5em" display-align="after">
                    Continued text here text here text here text here
                </fo:block>
            </fo:table-cell>
        </fo:table-row>
    </fo:table-body>
</fo:table>

Этот метод не зависит от текстовых строк в первых fo:table-cell.

Два результата форматирования с использованием графического интерфейса AH Formatter:

Результат форматирования в графическом интерфейсе AH Formatter

Моя версия Formatter 6.4. Но результат будет тот же.

person tmakita    schedule 08.05.2018
comment
Большое тебе спасибо! Второй ответ работает отлично. Мне очень помог. - person Audye Junior; 08.05.2018

Расширяя ответ @tmakita, вы можете использовать alignment-baseline для выравнивания базовых линий двух fo:inline-container (см. обсуждение в https://www.w3.org/TR/xsl11/#fo_inline-container).

Вы можете использовать last-line-end-indent (см. https://www.w3.org/TR/xsl11/#last-line-end-indent), чтобы выноска выступала за конец текста, но вам также необходимо ограничить ширину текста. В этом примере я использовал fo:block-container внутри первого fo:inline-container:

<fo:block>
    <fo:inline-container vertical-align="top" inline-progression-dimension="60%" alignment-baseline="text-after-edge">
        <fo:block-container width="50%">
            <fo:block start-indent="0.5em" text-indent="-0.5em" text-align-last="justify" last-line-end-indent="-100%">
            [3] Text here text here text here text here text here text here text here text here text here text here text here text here text here Text here text here text here text here text here text here text here<fo:leader leader-pattern="dots" leader-length.minimum="50%" leader-length.optimum="50%"/></fo:block>
        </fo:block-container>
    </fo:inline-container><fo:inline-container inline-progression-dimension="40%">
                <fo:block start-indent="0.5em" text-indent="-0.5em">
                    Continued text here text here text here text here
                </fo:block>
            </fo:inline-container>
</fo:block>

Если вы не хотите, чтобы текст в последней строке мог выходить за пределы остальной части, минимальная и оптимальная длина выноски должна быть не меньше ширины промежутка между двумя наборами текста.

person Tony Graham    schedule 08.05.2018