In LyX, how can I set a float that contain figure so that the caption is under the figure? By default the caption is always on the left side of figure.
[Tex/LaTex] Put figure text under images
floatslyx
Related Solutions
Adding
\usepackage{caption}% http://ctan.org/pkg/caption
to your document preamble (using the menus Document > Settings... > LaTeX Preamble) centres the captions by default. Although this also changes the default formatting, it would be possible to adapt it to match that of the default IEEEtran
document class.
If this is for a journal submission, it is advised to stick to their formatting.
You can use minipage
s 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:
Document --> Settings --> LaTeX preamble, add either
\usepackage{capt-of}
(or
\usepackage{caption}
)- Insert a figure float, with Insert --> Float --> Figure or the button on the toolbar.
- Delete the caption that is there by default (just place the cursor outside it, and hit backspace or delete).
- Add two
minipage
s with Insert --> Boxes --> Frameless. Add the second one immediately after the first one, do not hit enter after the first one. - Set the width of both to just below half the line width, e.g. 49% of the line width.
- In the minipage where you want the figure, add a new caption with Insert --> Caption. Add the image above it, as you normally would.
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.
Best Answer
A figure float in LaTeX is just a
figure
environment (\begin{figure} ... \end{figure}
) but when you make afigure
float ("flotante" in the capture because the Spanish configuration) in LyX is also created a\caption{}
command inside (the "Figure n: [text]
" box) inside. Note that captions are optionals, so you can cut this box to have a figure without legend or even insert more that one caption in the same float.The images, when translated to LaTeX language are
\includegraphics{imagename}
commands that allowed inside or outside a float. Inside the float, the image could be before or after the caption. Inside a caption, an image is not allowed in LaTeX by default. However, LyX can force this position including a\protect
command.Then you must care of the exact cursor position when inserting images. Insert the
image
inside the float but above or below thecaption
box. When the image was placed in the wrong position, just select only the image, cut it, move the cursor and paste in the right place.Note that
label
(\label{}
command in LaTeX) might also be inserted in any place in a float, but always place the labels inside or after the caption, never before, in order to avoid wrong cross-references.With a mouse click then you can control the configuration of the image dimensions. Usually you may want the image centered making a selection with the cursor, and then with a right click selecting center justification. This put in the source code a center environment (
\begin{center}
...\end{center}
) inside the float, but probably is better make an ERT box at the beginning of the float and write\centering
(that can produce a different result in terms of vertical spacing).You can check in the menu
View
that source LaTeX commands are in the correct order. A figure float with\centering
in an ERT box and the image above the caption, correctly labelled, should have this order: