我正在尝试使用包\DeclareCaptionLabelFormat
中定义的自定义标题标签格式包含图像caption
。如果我将其放入环境\captionsetup
中\floatbox
,标题和图像将无法正确对齐。
\documentclass[10pt]{article}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{floatrow}
\DeclareCaptionFont{red}{\color{red}}
\DeclareCaptionFont{blue}{\color{blue}}
\DeclareCaptionFont{green}{\color{green}}
\DeclareCaptionLabelFormat{mycap1}{(#2) Caption label type 1}
\DeclareCaptionLabelFormat{mycap2}{(#2) Caption label type 2}
\captionsetup[figure]{labelformat=default,
labelsep=newline,
justification=centering,
labelfont={small,red,bf,it},
textfont={blue}}
\begin{document}
\begin{figure}
\begin{floatrow}
\floatbox{figure}
{\captionsetup{labelformat=mycap1}}
{\caption {Caption for this figure}}
{\includegraphics[scale=0.5]{sample.png}}
\end{floatrow}
\end{figure}
\end{document}
如果我在图像和标题正确对齐\captionsetup
后将其删除\floatbox
,但我将无法获取标题的自定义标签。我在这里遗漏了什么?
答案1
Axel Sommerfeldt 写道:
你应该使用
\floatbox% {%first mandatory argument figure% }% {%second mandatory argument \captionsetup{labelformat=mycap1}% \caption {Caption for this figure}% }% {%third mandatory argument \includegraphics[scale=0.5]{sample.png}% }
相反,由于
\floatbox
有三个(而不是四个)强制参数。