I am trying to change a caption format with the caption
package within a float environment (in this case figure
). However, \captionsetup[figure]{}
is not working within the \begin{figure} ... \end{figure}
which is definitely possible and described on pg. 4 of the caption
documentation, namely:
It’s good to know that \captionsetup has an effect on the current environment only. So if you want to change settings for the current figure or table only, just place the
\captionsetup
command inside the figure or table right before the \caption command. For example\begin{figure}
. . .\captionsetup{singlelinecheck=off}
\caption{. . .}
\end{figure}
switches the single-line-check off, but only for this figure, so all the other captions remain untouched.
I cannot recall having issues with this before, can anybody reproduce this issue or provide guidance on how to fix it so the local \captionsetup
is used? I think I am calling the commands correctly although a simple error on my end is likely too.
The log file (with \showfiles
):
This is pdfTeX, Version 3.141592653-2.6-1.40.24 (TeX Live 2022) (preloaded format=pdflatex)
restricted \write18 enabled.
entering extended mode
(./test.tex
LaTeX2e <2022-11-01> patch level 1
L3 programming layer <2023-02-22>
(c:/texlive/2022/texmf-dist/tex/latex/base/book.cls
Document Class: book 2022/07/02 v1.4n Standard LaTeX document class
(c:/texlive/2022/texmf-dist/tex/latex/base/bk10.clo))
(c:/texlive/2022/texmf-dist/tex/latex/caption/caption.sty
(c:/texlive/2022/texmf-dist/tex/latex/caption/caption3.sty
(c:/texlive/2022/texmf-dist/tex/latex/graphics/keyval.sty)))
(c:/texlive/2022/texmf-dist/tex/latex/caption/subcaption.sty)
(c:/texlive/2022/texmf-dist/tex/latex/l3backend/l3backend-pdftex.def)
No file test.aux.
Caption Info: Option list on `figure'
Caption Data: {position=bottom,labelfont={Large,it}, labelsep=period} on input
line 27.
Package caption Warning: Unused \captionsetup[figure] on input line 25.
See the caption package documentation for explanation.
[1{c:/texlive/2022/texmf-var/fonts/map/pdftex/updmap/pdftex.map}] (./test.aux)
*File List*
book.cls 2022/07/02 v1.4n Standard LaTeX document class
bk10.clo 2022/07/02 v1.4n Standard LaTeX file (size option)
caption.sty 2022/03/01 v3.6b Customizing captions (AR)
caption3.sty 2022/03/17 v2.3b caption3 kernel (AR)
keyval.sty 2022/05/29 v1.15 key=value parser (DPC)
subcaption.sty 2022/01/07 v1.5 Sub-captions (AR)
l3backend-pdftex.def 2023-01-16 L3 backend support: PDF output (pdfTeX)
***********
)<c:/texlive/2022/texmf-dist/fonts/type1/public/amsfonts/cm/cmbx9.pfb><c:/texl
ive/2022/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb><c:/texlive/2022/t
exmf-dist/fonts/type1/public/amsfonts/cm/cmr9.pfb>
Output written on test.pdf (1 page, 30235 bytes).
Transcript written on test.log.
MWE:
\documentclass[oneside]{book}
\usepackage{caption}
\usepackage{subcaption}
\captionsetup[figure]{position=bottom,labelfont={bf, small}, textfont={small}}
\begin{document}
\begin{figure}[t]
\caption{Bold and small}
\end{figure}
\begin{figure}[t]
\captionsetup[figure]{position=bottom,labelfont={Large,it}, labelsep=period}
\caption{Large and italic}
\showcaptionsetup{figure}
\end{figure}
\end{document}
How it currently looks:
figure
follows, but the caption style doesn't change.[figure]
then the code compiles but in my main document, I have\captionsetup[subfigure]
which meant I wanted to not affectsubcaptions
too by changing a local definition "global" when I\input
other files. Just requires careful management but it is not mentioned in the documentation not to use it within a float, I am not sure why it won't work though it is puzzling.