# Using LyX, how do you put a table and a figure side by side and caption them Table XX and Figure XX?

I have found solutions for them to be done in normal TeX, but how do I do this in LyX? What I wish to obtain is something like that shown in Table and Figure side-by-side with Table caption above, Figure caption below

I have tried doing this by creating a mini-page and putting two boxes inside, but the table keeps getting captioned as a sub-figure instead of a table.

• Welcome to TeX.SX! You may have a look on our starter guide. – e-birk May 19 '13 at 13:46
• According to the documentation of the floatrow package you must not load float or rotfloat to use floatrow. – user31459 May 29 '13 at 15:27
• Note: I updated point 7 of my answer with a second option. – Torbjørn T. Jun 3 '13 at 20:04

You can use minipages as you first tried, if you add the capt-of (or caption) package and write the caption in an ERT using captionof command, which has the syntax

\captionof{<float type>}{<caption>}


So, in LyX:

1. Document --> Settings --> LaTeX preamble, add either

\usepackage{capt-of}


(or \usepackage{caption})

2. Insert a figure float, with Insert --> Float --> Figure or the button on the toolbar.
3. Delete the caption that is there by default (just place the cursor outside it, and hit backspace or delete).
4. Add two minipages with Insert --> Boxes --> Frameless. Add the second one immediately after the first one, do not hit enter after the first one.
5. Set the width of both to just below half the line width, e.g. 49% of the line width.
6. In the minipage where you want the figure, add a new caption with Insert --> Caption. Add the image above it, as you normally would.
7. In the minipage where you want the table, add an ERT with Ctrl + L or Insert --> TeX Code, and write

\captionof{table}{Your table caption}


Add the table below the caption as you normally would.

Optionally, you could write

\captionsetup{type=table}


in the ERT, and add the caption outside the ERT with Insert --> Caption. Make sure the ERT is placed before the caption. Note that this will not change the caption type in the LyX GUI, there you'll still have two figure captions, but in the PDF it will be correct. This also makes it easier to add cross references or citations in the caption, as you can use the GUI for that.

You may have to change the vertical alignment of the minipages as well, which you can do in the settings for the Inset. In the image below, the right minipage has the vertical alignment for the Box set to Middle, all other vertical alignments are set to Top.

• This is already simpler, of course. But a table float inserted after this construct is numbered wrong by one... One could use a local "style" definition like it is shown here to work around this. – e-birk Jun 6 '13 at 16:45
• @e-birk What do mean, numbered wrong? Yes, the number in the LyX GUI is wrong, but in the PDF it is correct. – Torbjørn T. Jun 6 '13 at 16:51
• @TorbjørnT. Yes, I was referring only to LyX. (PDF is okay.) – e-birk Jun 6 '13 at 17:21

This approach keeps the numbering of floats in LyX, the "List of Tables", and the "List of Figures" intact.

\begin{figure*}[htpb]

2. Insert a minipage, reduce its width to a fraction of 100%, e.g. 45%, insert a float (e.g. figure or table float) within the minipage, and set float setting to "Here definitely";

3. Insert some horizontal space (e.g. "Horizontal Fill") and repeat step 2. with another float; (this step can be repeated more times);

4. Finish with the ERT / TeX code

\end{figure*}


• I like your solution the best. The Here definitely cannot be highlighted enough! – Woltan Apr 5 '16 at 7:52

This approach numbers all tables correctly in LyX and LaTeX. It has the drawback that a table in a "floatrow" environment is not listed under "List of Tables" in the "Outline" side bar of LyX.

In Local Layout under "Document settings" add the following code and "validate" it.

Style FloatRowTableCaption
LatexType        command
LatexName        caption
OptionalArgs     1
LeftMargin       MMN
LabelSep         xx
Align            Center
LabelType        Counter
LabelCounter     table
LabelString      "Table \arabic{table} (FloatRow):"
End


\usepackage{floatrow}


In the LyX document create a Figure-float

1. put \CenterFloatBoxes\begin{floatrow}\ffigbox{ as ERT/TeX code at the beginning
3. put }{ as ERT
4. after the Figure caption put }\killfloatstyle\ttabbox{ as ERT
6. put }{ as ERT
8. put }\end{floatrow} as ERT