# Using LyX, how can I make a 6 column table with the second row having multiple lines of text?

Using LyX, how can I make a 6 column table with the second row having multiple lines of text? I am trying to create the following layout in LyX:

I'm using LyX 2.0 for mac.

What are ways to accomplish this?

-
Hi Jane, Welcome to TeX.SE! Most TeX users would probably call this a table. There have been many questions on this site about tables- this link will take you directly to questions that have been tagged with them, and should help get you started. –  cmhughes Nov 26 '11 at 4:38
I've edited the title to refer to tables for future users: 'chart' is misleading here. –  Joseph Wright Nov 26 '11 at 12:00
If my answer solved your problem, would you consider accepting it, by clicking the checkmark on the left? This marks the question as "solved", and awards some points to both yourself and me. –  Torbjørn T. Dec 9 '11 at 0:30

I'm not sure about the Lyx side of things, but here's some code that should get you started.

Note that I've used the column type p{width} to represent a 'paragraph' column that takes a width as an argument. The & are column separators, and we use \\ to start a new line.

\documentclass{article}

\begin{document}

\begin{table}
\centering
\begin{tabular}{|p{1.5cm}|p{2cm}|p{1.5cm}|p{2cm}|p{1.5cm}|p{2cm}|}
\hline
\textbf{Topic 1}             & \textbf{Topic 2}    &   \textbf{Topic 3} &  \textbf{Topic 4} & \textbf{Topic 5} & \textbf{Topic 6}\\ \hline
here is some text   & text                & 0923 0923 0923     & some more text goes here    & and some more text goes here    & and yet more here  \\ \hline
\end{tabular}
\end{table}

\end{document}


A lot of users on this site would recommend using the booktabs package to make your tables beautiful. This package provides the commands \toprule, \midrule, and \bottomrule, which are demonstrated below.

\documentclass{article}
\usepackage{booktabs}

\begin{document}

\begin{table}
\centering
\begin{tabular}{p{1.5cm}p{2cm}p{1.5cm}p{2cm}p{1.5cm}p{2cm}}
\toprule
\textbf{Topic 1}             & \textbf{Topic 2}    &   \textbf{Topic 3} &  \textbf{Topic 4} & \textbf{Topic 5} & \textbf{Topic 6}\\
\midrule
here is some text   & text                & 0923 0923 0923     & some more text goes here    & and some more text goes here    & and yet more here  \\
\bottomrule
\end{tabular}
\end{table}

\end{document}

-

To fill in a little on the LyX side of things:

You can create a tabular by either choosing Insert --> Table ... or clicking the button on the toolbar. In both cases, you choose the number of columns and rows for your table. Say you create a table with 6 columns and 2 rows, then you'll get something like this:

You'll want to remove most of the lines in the table, so start by selecting all the cells, and clicking the appropriate buttons on the toolbar at the bottom of the LyX window (that's where the toolbar appears on my installation, at least):

The button on the far right in the red oval removes all the lines. However, you'll still want the horizontal lines above and below the top row, so select just this, and add the lines:

Following cmhughes, you can set the column width. You can do this by right clicking in a cell, choosing More --> Settings, and writing a width in the appropriate text box.

I think you have to do this for each column, but I may be wrong, as I don't use LyX that much.

Another thing you want to do in the settings, is to go to the Borders tab, and select the "Formal" style. This will make LyX use booktabs, that cmhughes described in his answer.

You can add more rows to your table, by clicking the Add row button in the bottom left of the tabular toolbar, or using the keyboard shortcut. On Windows this is Alt + M, W I, i.e., hold down Alt and press M, then release both and type WI. (May be different on your Mac, but it will probably show up as a tooltip then hovering the mouse over the button.)

-
If I could vote this up more than once I would. Exceptional. It also illustrates to me why I use LaTeX though. This seems rather complex! –  qubyte Nov 26 '11 at 10:07
+1 for an excellent LyX answer! –  Daniel Nov 26 '11 at 14:15
+1 there are quite a few unanswered lyx questions that could benefit from this kind of great answer –  cmhughes Nov 26 '11 at 17:08
Thanks all! @cmhughes: I've looked at that list a couple of times, and if I was able to answer some of the questions, I would have. –  Torbjørn T. Nov 26 '11 at 17:17
+1 for showing that LyX actually supports booktabs (quite hidden so...) –  e-birk Apr 20 '13 at 20:35