FOP table with cell having two blocks top and bottom aligned - alignment

I would like to generate a table like the one in the image below using FOP:
Left column can have 1 or any number of rows.
Block1 and Block2 in right column can have 1 or any number of lines. I want Block1 to be top aligned and Block2 to be bottom aligned.
For the right column I tried this:
<fo:table-cell number-rows-spanned="$rows-spanned" display-align="after">
<fo:block>
Block1 Lorem ipsum
</fo:block>
<fo:block>
Block2 Lorem ipsum bla aaaa
</fo:block>
</fo:table-cell>
but it aligns Block1 and Block2 to the bottom.
Any idea how to achieve the desired output?

(disclosure: I'm a FOP developer, though not very active nowadays)
After some pondering, I've thought of two possible solutions.
Solution 1 (recommended): using two spanning cells
Instead of spanning all the rows with a single cell containing both blocks, span just half the rows with a cell containing Block 1, and then use another row-spanning cell with display-align="after" for Block 2:
<fo:table width="100%" table-layout="fixed">
<fo:table-column column-width="50%"/>
<fo:table-column column-width="50%"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell border="1pt solid #000000">
<fo:block>header</fo:block>
</fo:table-cell>
<fo:table-cell border="1pt solid #000000" border-bottom="none" number-rows-spanned="6">
<fo:block color="red">Block 1 Lorem ipsum</fo:block>
</fo:table-cell>
</fo:table-row>
<!-- ... 5 more rows ... -->
<fo:table-row>
<fo:table-cell border="1pt solid #000000">
<fo:block>item 6</fo:block>
</fo:table-cell>
<fo:table-cell border="1pt solid #000000" border-top="none" number-rows-spanned="5" display-align="after">
<fo:block color="blue">Block 2 Lorem ipsum bla aaaa</fo:block>
</fo:table-cell>
</fo:table-row>
<!-- ... the remaining 4 rows ... -->
</fo:table-body>
</fo:table>
Pros:
cleaner solution
no overlapping problems if there are few rows and the text blocks are several lines long
Cons:
the stylesheet to produce this would be more complicated (you have got to produce two row-spanning cells in the right row, taking into account that the number of rows could be odd / even)
Solution 2: using an extra column and margin tricks
You can define the table to have 3 columns, put Block 1 in a cell spanning all rows in column #2 and Block 2 spanning all rows in column #3, and creatively use margins to "move" Block 2 in the desired location:
<fo:table width="12cm" table-layout="fixed">
<fo:table-column column-width="4cm"/>
<fo:table-column column-width="4cm"/>
<fo:table-column column-width="4cm"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell border="1pt solid #000000">
<fo:block>header</fo:block>
</fo:table-cell>
<fo:table-cell border="1pt solid #000000" number-rows-spanned="11">
<fo:block color="red">Block 1 Lorem ipsum</fo:block>
</fo:table-cell>
<fo:table-cell number-rows-spanned="11" display-align="after">
<!-- use margins to "push" the block in the previous column -->
<fo:block margin-left="-4cm" margin-right="4cm" color="blue">Block 2 Lorem ipsum bla aaaa</fo:block>
</fo:table-cell>
</fo:table-row>
<!-- ... the other 10 rows ... -->
</fo:table-body>
</fo:table>
Pro:
simpler template to produce this, as you have to care about column #2 and #3 in the first row only
Cons:
if there are few rows and long blocks of text, they could overlap
should the table have a page break inside it, both text would appear on the first page (as they are both in the first row)
this is probably a dirty trick, so I would not recommend doing this (I tested it with FOP 1.1 and 2.0 and it works, with an INFO message about the table being larger than the available space)

If you know height you can do this simply
<fo:table-cell text-align="left" height="5cm">
<fo:block>
<fo:block-container height="25mm">
<fo:block xsl:use-attribute-sets="myBorder">
Block1 Lorem ipsum
</fo:block>
</fo:block-container>
<fo:block-container height="25mm" xsl:use-attribute-sets="myBorder" display-align="after">
<fo:block xsl:use-attribute-sets="myBorder" vertical-align="bottom" display-align="after">
Lorem ipsum bla aaaa
</fo:block>
</fo:block-container>
</fo:block>

Related

Graphviz: aligning a graph wrt its label

By default, Graphviz centers the graph relatively to its caption (label):
graph {
label="lorem ipsum dolor sit amet consectetur adipiscing elit"
A -- B
}
How can I align the graph to the left, i.e., make A, B and the initial of "lorem" vertically aligned?
The attributes labeljust and labelloc have other purposes, and I cannot see anything in the reference to achieve this result.
(it helps it include your source as text, not png)
No direct way, but (if needed) use invisible nodes and/or node width to get the graph wide enough to meet your needs. Then use the labeljust attribute to to justify the label to the left (or right) of the entire graph.
graph {
// does not seem to work size="8!"
label="abcdefghijklmnopqrstuvblahblah" labeljust=r
{rank=same a node[style=invis width="2."] x1 x2 edge[style=invis] x1--a--x2}
a--b
}
giving:

XSL:FO avoid Space between Table Cells

Hello guy I have two table Cells and a <fo:leader/> in both Cells. How can i avoid to get a space between the two Cells. It's not possible to span the two cells.
I use Antennahouse and XSLT 2.0 .
Here is my Code for the table
<fo:table width="100%" >
<fo:table-column column-width="50%"/>
<fo:table-column column-width="50%"/>
<fo:table-body >
<fo:table-row>
<fo:table-cell >
<fo:block border-right-width="0.0mm" >
<xsl:if test="page">
<xsl:attribute name="text-align-last">justify</xsl:attribute>
</xsl:if>
<xsl:value-of select="concat(#ref1,' ')"/>
<xsl:if test="page">
<fo:leader leader-pattern="dots"/>
</xsl:if>
</fo:block>
</fo:table-cell>
<fo:table-cell >
<fo:block text-align="justify" text-align-last="right" axf:text-align-first="justify">
<xsl:if test="page">
<fo:leader leader-pattern="dots" />
</xsl:if>
<fo:inline><xsl:apply-templates select="page" mode="normal"><xsl:with-param name="chapter" select="#chapterNumber"></xsl:with-param></xsl:apply-templates></fo:inline></fo:block>
</fo:table-cell>
</fo:table-row>
Without all the other stuff you have, with pure XSL FO and no extensions this works for me:
<fo:table width="100%" >
<fo:table-column column-width="50%"/>
<fo:table-column column-width="50%"/>
<fo:table-body >
<fo:table-row>
<fo:table-cell>
<fo:block text-align-last="justify">
<fo:inline>Stuff</fo:inline>
<fo:leader leader-pattern="dots"/>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block text-align-last="justify">
<fo:leader leader-pattern="dots" />
<fo:inline>1</fo:inline></fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
No spaces.
In response to the question, is it possible I got lucky? Tested again, various content and table column widths. Content that I am showing likely is kerned and of various lengths and I varied the size of the table cells. In all cases there is no gap.
I tested a few others things and realize the difference is the formatter. Apache FOP and Antennahouse yield the issue you have shown, I was using RenderX XEP (whom I work for). It does not exhibit this behavior. IMHO, the correct answer is no spaces if your formatter has the algorithms for allowing inter-character and word space squeezing to fit within an allowable tolerance. Justified is "justified".
I think there are two reasons for the strange "gap" between the two series of dots on each table row:
the column is not an exact multiple of the leader pattern (dot + space); for example, supposing a dot and a space are 3 mm wide and the empty area to be filled by the fo:leader has a width of 17 mm, the formatter can only insert 5 dots, leaving an extra gap of 2 mm
the dots on different rows are not aligned; each series of dots in the left column starts rigth from the end of the preceding text, so the gap depends also on the text length
Solution:
use leader-alignment="reference-area" (which XSLFormatter supports)
set a leader-pattern-width, and set the table width to a multiple of that

Latex: Insert vertical space after includegraphics

I'm using the scrartcl documentclass and try to insert some vertical space after including an image.
Lorem ipsum...\\\\
\includegraphics[width=\textwidth]{image.png}
% Add vertical space here
Lorem ipsum...
Before the image I can just add like \\\\ to add some space (which I don't like as well...), but I can't add these after the image because there is no line to end.
Is there an option to add a margin before and after the image?
I know that I could use figures, but I like the simple way of just adding one simple line of \inludegraphics{blah}
You should try using \vspace. \\ just adds newlines while \vspace adds vertical skips. Alternatively you could use \smallskip \medskip or \bigskip.

mathml on iOS -- mtable row spacing

This is driving me crazy. I need spacing between the rows of my mtable elements. For now, I am content to get it in the html; once I have that working, I'll try to move it to CSS.
Here are some things I am trying. In each case, I've set the amount of space crazy large so that if it works it will be unmistakable. But so far I can't see any space.
The implementation of mathML is incomplete. But until now, I've been able to find work-arounds for almost everything.
<math>
<mtable rowspacing="10ex">
<mtr padding="40px">
<mtd padding="40px">
<!-- remainder of the table here -->
another attempt, equally useless:
<math>
<mtable framespacing="40px 40px">
<mtr margin="40px">
<mtd margin="40px">
<!-- remainder of the table here -->
This did it:
<mtd style="padding:10px 0 10px 0">

Graying out texts with/without lines with LaTeX?

This is a screen capture from Pragmatic Bookshelf.
How to make this boxed text with LaTeX? It has it's own heading with underline, and uses color.
And how to make some text with gray background as follows?
http://img20.imageshack.us/img20/7351/screenshot20100718at916.png
Added
Konrad's method works, but it looks like that it doesn't work well with multicolumn package.
Tonio's method shows the gray only for the characters, but I want to have the gray box expanded to the end of \textwidth.
http://img714.imageshack.us/img714/8417/screenshot20100718at247.png
I posted another question with respect to the \texwidth, and it seems to working anyway.
The rounded box is most easily created using TikZ:
\begin{tikzpicture}
\draw node[draw=black,fill=black!20,rounded corners,inner sep=2ex,text width=\textwidth] {
Lorem ipsum dolor sit amet \dots
};
\end{tikzpicture}
You should use the color package.
For example,
\colorbox{red}{Black text on red background}
creates a black text, with a red background.
A good description of the color capabilities can be seen here, and an extended example here.

Resources