LyXFormating a table in two columns or boxes

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Post Reply
bloo
Posts: 1
Joined: Sat Jul 26, 2008 7:44 am

Formating a table in two columns or boxes

Post by bloo »

I'm trying to set up two tables in side-by-side columns, and get them to line up well. I was able to get close with each table in a Box and the page in two-column format, but only when I don't have any other text on the page. Vertical spacing wouldn't correct this. Below is a sketch of what I'm trying to accomplish.

I've also tried a float with two boxes inside (and the text format in one-column) and various other permutations. I've read through Embedded objects, tried ERT and the align command, etc. And I've searched these forums as well, but I'm beating my head against the wall here. Any help would be greatly appreciated. Thank you.

Code: Select all

Section
Subsection
Text

x 1 2 3   x 1 2 3
A          N
B          O
C          P

More text.

Recommended reading 2024:

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

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

Ted
Posts: 94
Joined: Sat Jun 23, 2007 4:11 pm

Formating a table in two columns or boxes

Post by Ted »

bloo wrote:I'm trying to set up two tables in side-by-side columns, and get them to line up well. I was able to get close with each table in a Box and the page in two-column format, but only when I don't have any other text on the page. Vertical spacing wouldn't correct this. Below is a sketch of what I'm trying to accomplish.
It would help if you gave an example of the LaTeX code you've tried and an explanation of what exactly you don't like about what it does.

What's wrong with this code:

Code: Select all

        \begin{tabular}[t]{ccc}
                A & B & C\\
                D & E & F\\
                G & H & I\\
                J & K & L
        \end{tabular}
        \begin{tabular}[t]{ccc}
                a & b & c\\
                d & e & f
        \end{tabular}
In this example, you must be careful not to put a blank line between the two tabular environments. If you want to separate them in code, put a comment (%) on each blank line. More importantly, notice the [t] that I passed to both tabular environments. It causes their "tops" to be aligned. By default, they are aligned by their centers. You can also align them by their bottoms.

[ Note that if the tables are individually too wide, the second table will get "wrapped" to the second line. ]

If you want those on a line by themselves, make sure that they are either in an environment that provides that separation (e.g., a float environment like table) or you have a blank line before and after them (but NOT between them). Some popular choices are

Code: Select all

\begin{table}\centering
% tabular environment one
% tabular environment two
\end{table}
or

Code: Select all

\begin{table}[ht!]\centering
% tabular environment one
% tabular environment two
\end{table}
or

Code: Select all

% Blank line

~\hfill
% tabular environment one
% tabular environment two
\hfill~

% Blank line
or

Code: Select all

% Blank line

~\hfill
% tabular environment one
\hfill
% tabular environment two
\hfill~

% Blank line
Do any of those do what you want? If not, then explain why. Right now I don't think it's clear from your message.
-- Ted [home/blog]
Post Reply