LyXCentering text in table cell ?!

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Post Reply
lyxer
Posts: 47
Joined: Mon May 10, 2010 5:17 pm

Centering text in table cell ?!

Post by lyxer »

Hi,

I'm having a problem centering a text in a table cell. Basically,
I have a three column table. The two end cells (1 and 3) in row 2 have
equations and the middle cell has an image. When I inserted the
image the two equations appeared in the bottom of the cell.

How can I place them in the middle of the cell ?
I'm attaching the table. The second row is the one that has a problem.

Thanks
Attachments
Jpeg image
Jpeg image
Table.jpg (17.98 KiB) Viewed 17001 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Re: Centering text in table cell ?!

Post by meho_r »

All you need to do is to set a fixed width for a column and select centered vertical alignment (Right Click in a cell > Settings > Vertical alignment in row).

I attached an example .lyx file.
Attachments
Example.zip
(6.12 KiB) Downloaded 651 times
Last edited by meho_r on Tue Jun 15, 2010 2:53 pm, edited 1 time in total.
lyxer
Posts: 47
Joined: Mon May 10, 2010 5:17 pm

Re: Centering text in table cell ?!

Post by lyxer »

Thanks,

I tried that but it's not working.
I set the column width to 2 inch but no mater what option I choose
for the vertical alignment (Top, Middle, Bottom) the text still
appears in the bottom. I tried deleting the cell content and re-write
the equation but the cursor is only active at the bottom.

I'm not sure if this has to do with using Lyx on a mac.
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Centering text in table cell ?!

Post by meho_r »

Have you been looking at the output file (pdf or dvi), not in LyX itself (LyX doesn't show the change, but in pdf output it should be set right)?

BTW, you should use middle vertical alignment for all columns.

And, if everything else fails, you may add this code in LaTeX Argument field in Settings for every column:

Code: Select all

>{\centering}m{2in}
lyxer
Posts: 47
Joined: Mon May 10, 2010 5:17 pm

Re: Centering text in table cell ?!

Post by lyxer »

Yes,

It's working now. I re-created the table and before putting
anything there I set the column width, and the vertical row
alignment to Middle.

A side question, in the other picture I'm attaching now, I created
a Subsection which I called "1. step function", I hit Enter and Lyx
switched to the "Standard" environment. After creating a vertical space,
I created a two-cell table. However, the table appeared on the same line
as the Subsection heading and it is shifted all the way to the right. The
cell widths are 1.5 inch. How do I get the table to appear in the next line
at the left. In other parts of the document it worked fine. I'm not sure what
I did different here.
Attachments
Second attachment
Second attachment
Table2.jpg (5.39 KiB) Viewed 16991 times
lyxer
Posts: 47
Joined: Mon May 10, 2010 5:17 pm

Re: Centering text in table cell ?!

Post by lyxer »

Thanks for the example.
I just realized it was there.
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Re: Centering text in table cell ?!

Post by meho_r »

It would help if you attach an example .lyx file with the problematic text as well as your .pdf output. Just put them in a .zip archive and attach them to your post.
lyxer
Posts: 47
Joined: Mon May 10, 2010 5:17 pm

Re: Centering text in table cell ?!

Post by lyxer »

The archive is attached.

From the output you notice that row 2 of table 1 is not centered (I thought I solved it) . Also, the tables following subsections 1 and 3 are on the same line as the heading. But for subsection 2 the table is in an appropriate position.
Attachments
Archive.zip
Archive
(98.04 KiB) Downloaded 369 times
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Centering text in table cell ?!

Post by meho_r »

1. You haven't set table settings correctly. You must set fixed column width for all columns and then set middle vertical alignment. In your table only the last column is set to fixed width.

2. The issue with subsection is caused by document class (article (AMS)). Normal article document class doesn't have this problem. However, puting \mbox{} (i.e. Ctrl+L > \mbox{}) after vertical space should put the table below the subsection.

Note: if you encounter more issues, please don't forget to provide images together with .lyx and .pdf files.
lyxer
Posts: 47
Joined: Mon May 10, 2010 5:17 pm

Re: Centering text in table cell ?!

Post by lyxer »

It's working now. I had to switch to "article" to get the \mbox trick to
work.

Thanks so much
Post Reply