Use display-align="after" on the table cell:

<fo:table-cell padding-before="3pt" padding-after="3pt" display-align="after">
<fo:block>
**This text I want to be aligned to bottom (in the second line)**
</fo:block>
</fo:table-cell>

Just as a tip for people who want to align text vertically in the middle of a <fo:block/> - it doesn't work with Apache FOP: xmlgraphics.apache.org/fop/

@masche: So what do you mean by "in my case"? If you need help, ask a new question. Provide the information needed to reproduce the problem.

## Vertical alignment of text in a table cell - Stack Overflow

alignment vertical-alignment xsl-fo

Impossible to tell from the information provided. Obviously, a CSS issue but can't tell where to begin. Common problems are the display CSS not completely accounted for in the print CSS and, using display:none; on an child element inside of a div tag that has height defined (removes the content but the space is still there.) The latter is what I suspect. I've found adding background colors to various elements very helpful in debugging CSS problems such as yours.

TY that is helpful, I will go from here to start debugging. I realize I didn't provide that much info, but like I said there is a lot of stuff going on.

## html - Page-break-after vertical alignment of a table - Stack Overflow

html css page-break

There is a pure html/css solution for this, but it's not pretty. You need to separate the decimal aligned column into two columns, with no padding between them. The first column has the integer value and is right aligned, the second has the decimal and the decimal value.

<table>
<th>customers</th>
<th colspan="2">balance</th>
<tbody>
<tr><td>John</td>  <td>4</td><td>.45</td></tr>
<tr><td>Jane</td>  <td>20</td><td></td></tr>
<tr><td>Jim</td>   <td>2,300</td><td>.64</td></tr>
</tbody>
</table>

<style>
th {
text-align: center;
}
td:nth-child(2) {
text-align: right;
}
td:nth-child(3) {
position: relative;
left: -0.2em;
text-align: left;
}
</style>

You could also use classes like ".integer" and ".decimal" as opposed to :nth-child selectors. That would be more robust, but I was trying to keep the markup short.

## html - Aligning decimal point of numbers in a table, with appearance o...

html css html-table alignment decimal

## Load a mask for VMOVMASKPS from a window into a table. AVX2, or AVX1 ...

The mask can also be used for ANDPS in registers in a reduction that needs to count each element exactly once. As Stephen Canon points out in comments on the OP, pipelining loads can allow overlapping unaligned stores to work even for a rewrite-in-place function like the example I picked, so VMASKMOVPS is NOT the best choice here.

This should be good on Intel CPUs, esp. Haswell and later for AVX2.

Agner Fog's method for getting a pshufb mask actually provided an idea that is very efficient: do an unaligned load taking a window of data from a table. Instead of a giant table of masks, use an index as a way of doing a byte-shift on data in memory.

Masks in LSB-first byte order (as they're stored in memory), not the usual notation for {X3,X2,X1,X0} elements in a vector. As written, they line up with an aligned window including the start/end of the input array in memory.

• start misalign count = 1: mask = {0,-1,-1,-1,-1,-1,-1,-1} (skip one in the first 32B)

start misalign count = 7: mask = {0, 0, 0, 0, 0, 0, 0,-1} (skip all but one in the first 32B)

end misalign count = 0: no trailing elements. mask = all-ones (Aligned case).this is the odd case, not similar to count=1. A couple extra instructions for this special case is worth avoiding an extra loop iteration and a cleanup with a mask of all-zeros.

{-1, 0, 0, 0, 0, 0, 0, 0}
{-1,-1,-1,-1,-1,-1,-1, 0}

Untested code, assume there are bugs

section .data
align 32  ; preferably no cache-line boundaries inside the table

; byte elements, to be loaded with pmovsx. all-ones sign-extends
DB  0,  0,  0,  0,  0,  0,  0,  0
masktable_intro:                      ; index with 0..-7
DB -1, -1, -1, -1, -1, -1, -1, -1
masktable_outro:                      ; index with -8(aligned), or -1..-7
DB  0,  0,  0,  0,  0,  0,  0,  0

; the very first and last 0 bytes are not needed, since we avoid an all-zero mask.

section .text
global floatmul   ; (float *rdi)
floatmul:
mov    eax, edi
and    eax, 0x1c            ; 0x1c = 7 << 2 = 0b11100

lea    rdx, [rdi + 4096 - 32]  ; one full vector less than the end address (calculated *before* masking for alignment).
;;  replace 4096 with rsi*4 if rsi has the count (in floats, not bytes)

and    rdi, ~0x1c           ; Leave the low 2 bits alone, so this still works on misaligned floats.

shr    eax, 2               ; misalignment-count, in the range [0..7]

neg        rax
vpmovsxbd  ymm0, [masktable_intro + rax]  ; Won't link on OS X: Need a separate LEA for RIP-relative

vmaskmovps ymm1, ymm0, [rdi]
vaddps     ymm1, ymm1, ymm1   ; *= 2.0
vmaskmovps [rdi], ymm0, ymm1

;;; also prepare the cleanup mask while the table is still hot in L1 cache

; if the loop count known to be a multiple of the vector width,
; the alignment of the end will be the same as the alignment of the start
; so we could just invert the mask
; vpxor    xmm1, xmm1, xmm1     ; doesn't need an execution unit
; vpcmpeqd ymm0, ymm1, ymm0

; In the more general case: just re-generate the mask from the one-past-the-end addr
mov    eax, edx
xor    ecx, ecx      ; prep for setcc
and    eax, 0x1c     ; sets ZF when aligned
setz   cl            ; rcx=1 in the aligned special-case, else 0
shr    eax, 2
lea    eax, [rax + rcx*8]   ; 1..7, or 8 in the aligned case
neg    rax
vpmovsxbd  ymm0, [masktable_outro + rax]

.loop:
vmovups  ymm1, [rdi]    ; Or vmovaps if you want to fault if the address isn't 4B-aligned
vaddps   ymm1, ymm1, ymm1   ; *= 2.0
vmovups  [rdi], ymm1
cmp      rdi, rdx           ; while( (p+=8) < (start+1024-8) )
jb    .loop        ; 5 fused-domain uops, yuck.

; use the outro mask that we generated before the loop for insn scheduling / cache locality reasons.

vmaskmov ymm1, ymm0, [rdi]
vaddps     ymm1, ymm1, ymm1   ; *= 2.0
vmaskmovps [rdi], ymm0, ymm1
ret

; vpcmpeqd ymm1, ymm1, ymm1   ; worse way to invert the mask: dep-chain breaker but still needs an execution unit to make all-ones instead of all-zeros.
; vpxor    ymm0, ymm0, ymm1

This does require a load from a table, which can miss in L1 cache, and 15B of table data. (Or 24B if the loop count is also variable, and we have to generate the end mask separately).

Either way, after the 4 instructions to generate the misalignment-count and the aligned start address, getting the mask only takes a single vpmosvsxbd instruction. (The ymm, mem form can't micro-fuse, so it's 2 uops). This requires AVX2.

[masktable_intro + rax]
[masktable_intro + rax + 4]

Or: (more insns, and more shuffle-port pressure, but less load-port pressure)

• vpmovsxbw into a 128b register
• vmovdqu from a 60B table of DWORDs (DD) instead of Bytes (DB). This would actually save an insn relative to AVX2: address & 0x1c is the index, without needing a right-shift by two. The whole table still fits in a cache line, but without room for other constants the algo might use.

The code inside the loop is replicated 3 times.

TODO: write another answer generating the mask on the fly, maybe as bytes in a 64b reg, then unpacking it to 256b. Maybe with a bit-shift, or BMI2's BZHI(-1, count)?

On the topic of the unalgined approaches versus the various aligned approaches, it probably (as usual) comes down to your expectations for your input. Often I expect that data will be aligned (e.g., because people are using allocators that align it, or whatever) - but I can't exclude the possibility of unaligned input in a general purpose shared library. In that case, the unaligned approach probably dominates, since you don't actually pay the misaligned penalty of cache-line crossing (you may still pay a penalty for using unaligned mov* instructions on some older CPUs).

On the other hand, if your data is often misaligned, I think the aligning approaches will work well, for moderately sized data, anyway (e.g., 100+ bytes up to perhaps around the size of the L1). For small sizes, the intro/outro overhead may make it less competitive. For large sizes, the unaligned approach may catch up again (but not be better) since higher level cache or memory access may come to dominate the time (but not always for L2 or L3 given good prefetching).

A reasonable approach in some cases, where you expect one behavior to dominate (e.g., usually aligned vs usually unaligned), would be to have both versions, with a quick check at front which selects one or other other. If well predicted, this is close to free. It would be useful for a widely shared library where you don't know the behavior, but believe it is likely that any given user will be primarily be in one regime or the other. Where that would really fail, however, is in a system where say 50% of inputs are aligned.

Unfortunately, that's pretty likely in some systems, because memory allocators often align by 8 (50% chance of being aligned for 16B) and/or 16 (same 50% chance of alignment for 256bit vectors). Of course, you pay a significant cost in code complexity and validation effort (and code size, in case both paths are taken).

## gcc - Vectorizing with unaligned buffers: using VMASKMOVPS: generating...

gcc assembly x86 sse avx

I would recommend using CSS for this. You should create a CSS rule to enforce the centering, for example:

.ui-helper-center {
text-align: center;
}

And then add the ui-helper-center class to the table cells for which you wish to control the alignment:

<td class="ui-helper-center">Content</td>

EDIT: Since this answer was accepted, I felt obligated to edit out the parts that caused a flame-war in the comments, and to not promote poor and outdated practices.

CSS 1 became a recommendation almost 15 years ago. Don't use the align attribute.

@Quentin - Agreed about "don't use 'align'". But Cory Larson himself recommended the CSS equivalent over "align=center". I hope you don't mark him down (and if you did, please consider changing it. OK?)

@paulsm4 I didn't, and he hadn't when I made the comment.

@Jack - in the header section of your html document. Ideally, you'd want to create a css include file and link it from the header: htmlhelp.com/reference/css/style-html.html

Sign up for our newsletter and get our top new questions delivered to your inbox (see an example).

## html - Center text in table cell - Stack Overflow

html html-table alignment center
\usepackage{array}
\begin{tabular}{| >{\centering\arraybackslash}m{1in} | >{\centering\arraybackslash}m{1in} |}

note that the "m" for fixed with column is provided by the array package, and will give you vertical centering (if you don't want this just go back to "p"

## alignment - How to center cell contents of a LaTeX table whose columns...

alignment latex tabular

The reality is, that the only tags in HTML that have native fluid vertical alignment are the table cells.

CSS does not have anything that would get you what you want. Not today.

If the requirements are: 1. Works with every browser 2. fluid height 3. vertical centering 4. no scripting 5. No TABLEs 6. You want the solution today, not in few years

You are left with 1 option: 1. Drop ONE of your requirements

Otherwise this "puzzle" is not completable. And this is the only complete acceptable answer to your request.

... if only I could get all the salaries for the wasted hours on this particular challenge :)

## css - Trouble (vertically) Centering Text in another DIV with relative...

css html

The reality is, that the only tags in HTML that have native fluid vertical alignment are the table cells.

CSS does not have anything that would get you what you want. Not today.

If the requirements are: 1. Works with every browser 2. fluid height 3. vertical centering 4. no scripting 5. No TABLEs 6. You want the solution today, not in few years

You are left with 1 option: 1. Drop ONE of your requirements

Otherwise this "puzzle" is not completable. And this is the only complete acceptable answer to your request.

... if only I could get all the salaries for the wasted hours on this particular challenge :)

## css - Trouble (vertically) Centering Text in another DIV with relative...

css html

You had some incorrect syntax. You were using style="align-right" when I believe you meant style="text-align:right;". You also need to add a colspan="2" to the <td> which needs to span 2 columns - aka the "item b" cell:

<table width="500px">
<tr>
<td>
item a
</td>
<td style="text-align:right;" colspan="2">
item b
</td>
</tr>
<tr>
<td>
item c
</td>
<td style="text-align:right;">
item d
</td>
<td style="text-align:right;">
item e
</td>
</tr>
</table>

+1 Yes, the colspan solution is even better, saving some text there.

Ha! Thanks, I did have that syntax error in my jsfiddle. I just put that together quickly for the question, and didn't have that error in my original code. I was trying to use the td property align and not style. so, instead of style="text-align:right", I originally had align="right" but it was the colspan that did the trick, in either case.

## css - Html Table alignment right - Stack Overflow

html css alignment html-table
table {
width:500px;
margin: 10px auto;
}

## alignment - center table in HTML - Stack Overflow

html alignment html-table

I would suggest you to encapsulate the table in a div and give the center alignment to this div with display: inline-block; and margin: auto;. You will probbaly need to give a width=100% to your table

## css - cannot center table in firefox - Stack Overflow

css firefox alignment vertical-alignment

There is no way in raw HTML to do this. I wrote a jQuery plugin to solve just this problem. See https://github.com/ndp/align-column

It's simple to use with your uncorrupted table:

\$('table').alignColumn(3);

This is great, I've seen your example. But I couldn't work this right. Hope you can help me. Give me a reply then I will show my code. Thanks

## html - Aligning decimal point of numbers in a table, with appearance o...

html css html-table alignment decimal

What would you think about placing the 'total' column after the 'name' column, rather than at the very end? Wouldn't this avoid the requirement for only a portion of the table to scroll?

It's not exactly what you're asking for, but perhaps it is a sufficient solution, given that the alternative would be pretty messy. (Placing the 'total' and 'name' columns outside of the table, for instance, would create alignment problems when not all rows are of equal height. You could correct this with javascript but then you'd be entering a whole new world of pain).

Also from a UI perspective, it may be that 'name' and 'total' are the most important data, in which case it would make sense to put them together, followed by a sort of 'breakdown' of the total. Of course, we seem to have an intuition that a 'total' should come after its constituent parts, but I don't think it would cause too much confusion to the user if the order were reversed like this (though this is a question for you, based on your product and your users).

• Paginate the scores. Give the most recent ten, say, and the total, and a link to older scores, which are provided 10 at a time
• Only give names, totals, and some other meaningful measures such as mean and sd, then provide a link for each name that shows all results corresponding to that name. You could then also provide a link showing all results for a given score set, so that comparisons between different users can be made. The point is that you'd only have to give 1 dimension of data for each view, rather than having an unwieldy 2D data set
• Make the rows sortable (easy with jQuery UI) so that if I want to compare Mary to Jane, I can drag and place one after the other, so I wont need to keep scrolling left and right to see which scores correspond to which names
• Highlight a row when it is clicked, by changing the background color or similar, again so I don't need to keep scrolling left and right.

Anyway you get the idea. Perhaps it is better to look for a UI solution than a contorted markup solution. Ultimately I would be questioning how important it is to present so much data to the user at once, that a portion of it needs to scroll in a particular fashion for the data to be readable. Perhaps you're building a spreadsheet app, and you really do need to display a 100x100 matrix in a single view. If not, you could surely come up with more creative ways than I have to split up the results.

True - the total could be put at the start and it would make sense. It really comes down to what I want the users to see - while they browse through the other columns, it'd be good for them to be able to see the name and the total. I'd still want to only scroll the rest.

I guess if you want to scroll the rest anyway it doesn't make all that much of a difference. I thought your main concern was that a user might not realise that the 'total' column exists if they are required to scroll to it.

No, more that if they want to compare people's scores, they'd need to keep scrolling back and forth between the name and the later score columns or total.

## javascript - How do I freeze the first and last columns of an html tab...

javascript html layout html-table

This is a trick I figured out for getting a DIV to float exactly in the center of a page. Works in IE and Chrome. The trick is in the vertical alignment of the table cell, and fixed positioning.

<div style="border: 5 dashed red;position:fixed;top:0;bottom:0;left:0;right:0;padding:5">
<table style="position:fixed;" width="100%" height="100%">
<tr>
<td style="width:50%"></td>
<td style="text-align:center">
<div style="width:200;border: 5 dashed green;padding:10">
Perfectly Centered Content
</div>
</td>
<td style="width:50%"></td>
</tr>
</table>
</div>

## css - How to center absolutely positioned element in div? - Stack Over...

css css-position center absolute

This is a trick I figured out for getting a DIV to float exactly in the center of a page. Works in IE and Chrome. The trick is in the vertical alignment of the table cell, and fixed positioning.

<div style="border: 5 dashed red;position:fixed;top:0;bottom:0;left:0;right:0;padding:5">
<table style="position:fixed;" width="100%" height="100%">
<tr>
<td style="width:50%"></td>
<td style="text-align:center">
<div style="width:200;border: 5 dashed green;padding:10">
Perfectly Centered Content
</div>
</td>
<td style="width:50%"></td>
</tr>
</table>
</div>

## css - How to center absolutely positioned element in div? - Stack Over...

css css-position center absolute

This is a trick I figured out for getting a DIV to float exactly in the center of a page. Works in IE and Chrome. The trick is in the vertical alignment of the table cell, and fixed positioning.

<div style="border: 5 dashed red;position:fixed;top:0;bottom:0;left:0;right:0;padding:5">
<table style="position:fixed;" width="100%" height="100%">
<tr>
<td style="width:50%"></td>
<td style="text-align:center">
<div style="width:200;border: 5 dashed green;padding:10">
Perfectly Centered Content
</div>
</td>
<td style="width:50%"></td>
</tr>
</table>
</div>

## css - How to center absolutely positioned element in div? - Stack Over...

css css-position center absolute

This is a trick I figured out for getting a DIV to float exactly in the center of a page. Works in IE and Chrome. The trick is in the vertical alignment of the table cell, and fixed positioning.

<div style="border: 5 dashed red;position:fixed;top:0;bottom:0;left:0;right:0;padding:5">
<table style="position:fixed;" width="100%" height="100%">
<tr>
<td style="width:50%"></td>
<td style="text-align:center">
<div style="width:200;border: 5 dashed green;padding:10">
Perfectly Centered Content
</div>
</td>
<td style="width:50%"></td>
</tr>
</table>
</div>

## css - How to center absolutely positioned element in div? - Stack Over...

css css-position center absolute
<table style="margin:0px auto; width:500px">

@R.S you should mark this or the other answer as accepted if they both solve your problem

## alignment - center table in HTML - Stack Overflow

html alignment html-table

CSV files carry no formatting or alignment info, it is just data separated by comma. Normally it is table processor job to render csv pretty.

with PTable

from prettytable import from_csv
fp = open("myfile.csv", "r")
mytable = from_csv(fp)
fp.close()
mytable.border = False
print mytable.get_string()

For few simple tables a simple snippet might do as well.

Personally, when I had to print out a table without extra hassle with packages I would use some ad-hoc string formatting, but packages usually more fool-proved, support many options, so if you gonna deal with many tables it might be worth the effort.

Prettytable seems be the most popular (great name). Tabulate claims better performance than most pretty table printers, save asciitable ( now astropy.io.ascii , so might be a bit of overkill unless you are a rocket scientist )

Hi Serge, Thank you for pointing me in the right direction. This is what I was looking for.

Anytime, good luck. If you find the answer helpful do not hesitate to upvote or accept it

## python - convert csv to txt without losing column alignment - Stack Ov...

python csv text-files