# Inserting a table made with ERT into a float in LyX

Is it impossible to insert a table made with ERT into a float in LyX 2.0 such that I can edit the height and placement of the table in my document?

• Is this the same table as your previous question? Jun 6 '13 at 17:23
• In my previous question i could not get the table to work.. Now it works but now i want my table inside a float, so that i can control the size and placement of the table in my document. Jun 6 '13 at 20:07

Looking at the table code you posted in your previous question, I'll give some explanation of it, and how it relates to LyX.

\begin{table}[ht]
\caption{Nonlinear Model Results}
\centering
\begin{tabular}{c c c c}
\hline\hline
Case & Method\#1 & Method\#2 & Method\#3 \\ [0.5ex]
\hline
1 & 50& 837 & 970 \\
2 & 47 & 877 & 230 \\
3 & 31 & 25 & 415 \\
4 & 35 & 144 & 2356 \\
5 & 45 & 300 & 556 \\ [1ex]
\hline
\end{tabular}
\label{table:nonlin}
\end{table}

1. The table environment, i.e.

 \begin{table}[ht]
...
\end{table}


This is a float, and it is what you get when you do Insert --> Float --> Table in LyX. The optional argument, i.e. [ht] is the placement specifier, and equivalent to choosing Here if possible and Top of page in the float settings.

2. The caption, i.e. \caption{...}. This is the same as the caption-box that is placed in floats in LyX by default. You can also get it in LyX with Insert --> Caption.

3. Centering of the content of the float, i.e.

\centering


This is (almost) the same as changing the paragraph settings inside the table float to centered alignment, via right-click --> Paragraph settings.

The difference is that LyX inserts a centering environment, instead of the \centering switch.

4. The tabular enviroment, i.e.

 \begin{tabular}{c c c c}
...
\end{tabular}


This is what actually produces your table, and is what you get when doing Insert --> Table in LyX.

5. The label, i.e. \label{table:nonlin}. This is the same as labels in LyX, so you can insert this with Insert --> Label.

## The point

If you would like to edit your tables such as this with code rather than the LyX GUI, you really don't need anything more than the tabular environment in an ERT, the rest can just as well be added via the GUI. That could also make cross-referencing easier, as the label will be listed in the GUI. For example as seen in the screenshot below:

You don't have to use the GUI though, you could just have the complete code as above in an ERT. Just don't place it inside a second float, which won't work, and doesn't make sense.

Finally, note that floating environments have nothing to do with the scaling of their contents, so having your table in a float won't help you change its height.

• That was the solution to my problem :-) Jun 7 '13 at 6:51
• @Lasse Glad it helped. Perhaps you'll consider accepting the answer by clicking the checkmark on the left. This marks the question as answered, as well as rewarding some points to both yourself and me. See our starter guide or the help center for more information on how the site works. Jun 7 '13 at 8:31