I am using Sphinx to build PDFs of some rst-documents. But I am having some trouble adjusting the formatting of my figure and table captions. In the latex-preamble, I use the caption package to adjust e.g. the spacing around the captions like this:
\usepackage{caption}
\captionsetup[table]{aboveskip=5pt}
\captionsetup[figure]{aboveskip=6pt}
However, when I use the caption package, it can cause a caption and a table to be placed on two different pages in the built PDF. This happens when the table does not fit on the current page and is moved to the next (note that I have table captions placed above tables). I.e. the caption is not "glued" to the table when using the caption package. I am unsure whether the same can happen for a figure as well, but since I have figure captions below figures, this would not be an issue in practice even if it could.
This problem have been mentioned in this old sphinx issue: https://github.com/sphinx-doc/sphinx/issues/5520#issuecomment-511305396 But I have not found any active issue for this problem.
no page break between table and table caption describes the same problem, but for pure latex (no Sphinx or rst involved). The accepted answer for that question does not seem easily incorporated into a Sphinx-based document.
Can I somehow "glue" the caption to the table when using the caption package? If not, is there any "easy" way of configuring the caption formatting without using the caption package?