## LaTeX forum ⇒ Graphics, Figures & Tables ⇒ Vertically centering text in a tabularx (again!) Topic is solved

Information and discussion about graphics, figures & tables in LaTeX documents.
Cham
Posts: 894
Joined: Sat Apr 02, 2011 4:06 pm

### Vertically centering text in a tabularx (again!)

I'm having troubles (again!?) with vertically centering items in a table, as shown in this MWE below:


While this code is using "p" for the first and third columns, and "m" for the second column, the text isn't vertically well centered in the second column. Why? What is happening here? What's wrong with my code?

Here's a preview of what this super awesome code ( ) is doing:
vertical.jpg (17.65 KiB) Viewed 826 times

Johannes_B
Site Moderator
Posts: 3854
Joined: Thu Nov 01, 2012 4:08 pm
This is what you are asking for. A m columns aligns the middle of its contents with the baseline of the other columns.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

Cham
Posts: 894
Joined: Sat Apr 02, 2011 4:06 pm
Johannes,

your code above doesn't work. Even in overleaf, the table is all messed.

Johannes_B
Site Moderator
Posts: 3854
Joined: Thu Nov 01, 2012 4:08 pm
No, it isn't messed at all. It is supposed to look like that. It demonstrates more clearly, that LaTeX does the correct centering of the content.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

Cham
Posts: 894
Joined: Sat Apr 02, 2011 4:06 pm
No, it's all messed up! Here's what it does, and it's horrible :
garbled.jpg (11.91 KiB) Viewed 803 times

I get the same in Overleaf.

Please, could you stick with the original code, and just show the appropriate modifications?

Johannes_B
Site Moderator
Posts: 3854
Joined: Thu Nov 01, 2012 4:08 pm
The image shows, the text is vertically centered.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

Johannes_B
Site Moderator
Posts: 3854
Joined: Thu Nov 01, 2012 4:08 pm
Johannes_B wrote:This is what you are asking for. A m columns aligns the middle of its contents with the baseline of the other columns.

That actually was wrong as i just now noticed. It is your arraystretch that messes stuff up

Google gives me https://tex.stackexchange.com/questions ... raystretch
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

Cham
Posts: 894
Joined: Sat Apr 02, 2011 4:06 pm
It is worst. This table is horrible. Please, use the original code. What to do to center (vertically) everything in their cell, without changing the stretch ?

Johannes_B
Site Moderator
Posts: 3854
Joined: Thu Nov 01, 2012 4:08 pm
Of course it is horrible, it is to show off the reason.
Have you tried the solutions in the link i gave you?

I don't have a lot of time today and don't want to waste it on your tables. As far as I am concerned, they will just as ugly if that spacing is fixed. I really don't like how they look.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

Stefan Kottwitz
Posts: 9105
Joined: Mon Mar 10, 2008 9:44 pm
Text should be aligned at base lines. If one just aligns vertically, the base lines are not at the same height, that looks strange.

Today the typographic taste is usually, that no vertical lines are used (reading flow from left to right without blocking lines) and no double lines; just few horizontal lines (top, bottom). Putting everything in cells with borders is rarely the case in good books but in printed excel tables when the full grid is printed, in cheap productions. How are tables in professional books in your field of work? Perhaps compare?

Stefan