[Tex/LaTex] Position of caption in LyX

captionslyxsidecaptables

I used sidecap package in LyX to put the caption on the right of the tables, but I got problem with it.
sidecap works good with figure caption but it's not good with table caption:

enter image description here

Please are there any why to put the table caption on the right of table in LyX.

enter image description here

Best regards

Best Answer

There is no straightforward way of moving a caption from left to right or vice versa. The package only allows for global settings, so the captions are always on the left or always on the right. For two page setups you can also have them always on the inner or always on the outer side. There are things you can try though:

Make the caption wider

It looks from your screenshot that the problem is more that the area for the caption is too narrow, making it overprint the table itself. Fixing this problem is very easy:

At the very start of the SCtable float, add an ERT with Ctrl + L, and write [3] in this. What this does is adding [3] as an optional argument to the SCtable environment, and that number is the relative width of the caption to the table. With 3 the caption can be three times the width of the table. Here is a screenshot from LyX with PDF output next to it:

enter image description here

ERT hackery

Add an ERT just before the table, and write in that the following:

{\makeatletter
\renewcommand*{\SC@FLOAT}[2]{{#1}\hspace{\sidecaptionsep}{#2}}
\makeatother

If you copy-paste, use Edit --> Paste Special (Ctrl+Shift+v) to paste the code in.

Just after the table, add a new ERT and add just a closing brace, i.e. }.

enter image description here

Don't use sidecap

You can place captions next to tables without using sidecap at all. Add a normal table float, and start by deleting the caption that is already there. Add a minipage with Insert -> Box -> Frameless, and make that for example half the width of the line. Add the caption inside this box, with Insert --> Caption. Finally, add the table on the same line as the box (i.e., don't hit enter before adding the table).