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

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.

enter image description here


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

  1. Start with inserting the ERT / TeX code

    \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*}
    

enter image description here


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

Add to the LaTeX Preamble:

\usepackage{floatrow}    

In the LyX document create a Figure-float

  1. put \CenterFloatBoxes\begin{floatrow}\ffigbox{ as ERT/TeX code at the beginning
  2. insert your image...
  3. put }{ as ERT
  4. after the Figure caption put }\killfloatstyle\ttabbox{ as ERT
  5. insert your table...
  6. put }{ as ERT
  7. as new line insert the table caption and choose style "FloatRowTableCaption"
  8. put }\end{floatrow} as ERT

Here is a picture how it might look: LyX document with floatrow