7

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.

  • 1
    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
4

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 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
4

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

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

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

  • I tried just the first step of adding the usepackage statement, and got an error: "Package floatrow error: Do not use float package with floatrow" – mtigger May 19 '13 at 16:54
  • @mtigger That means something is requiring (loading) the "float" package. The only thing I found so far is the "algorithm" float. Are you using an "algorithm" float in your document? – e-birk May 19 '13 at 19:15
  • no I'm not, but I'm using the caption package which I suspect is using the float package too. – mtigger May 22 '13 at 7:22
  • 1
    According to the documentation of the "floatrow" package the newer versions of the "caption" package should be compatible. But maybe you can find some other information there. – e-birk May 22 '13 at 8:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.