带有漂亮标题样式的图表

带有漂亮标题样式的图表

我正在使用下面的代码来布局列表的标题。如何才能使图形获得相同的效果,即具有彩色框架和相同的标题样式?虽然我希望标题的背景与图形的框架略微重叠,但我确实不是希望它与实际图形重叠。此外,我希望对图形使用该样式,标题位于顶部和底部。

\documentclass{memoir}

\usepackage{graphicx}
\usepackage{caption}
\usepackage{listings}
\usepackage{color}

\DeclareCaptionFont{white}{\color{white}}
\DeclareCaptionFormat{listing}{\noindent\colorbox{blue}{\hspace{1em}#1#2#3\hspace{1em}}}
\captionsetup[lstlisting]{format=listing,labelfont=white,textfont=white,
singlelinecheck=false, margin=0pt,font={bf,sf,footnotesize}}

\begin{document}
\begin{lstlisting}[caption={Listing with nice caption style.},frame=single,rulecolor=\color{blue}]
Line 1
Line 2
Line 3
\end{lstlisting}

\begin{figure}
\centering
\resizebox{5cm}{!}{\LaTeX}
\caption{Figure with caption at bottom.}
\end{figure}

\begin{figure}
\centering
\caption{Figure with caption on top.}
\resizebox{5cm}{!}{\LaTeX}
\end{figure}

\end{document}

在此处输入图片描述

答案1

这应该可以让你开始了。

我已经定义

\captionsetup[figure]{format=listing,labelfont=white,textfont=white,aboveskip=-10pt,
singlelinecheck=false, margin=3pt,font={bf,sf,footnotesize}}

并将 s的内容装入环境figuremdframed

\documentclass{memoir}

\usepackage{graphicx}
\usepackage{caption}
\usepackage{listings}
\usepackage{color}
\usepackage{mdframed}

\DeclareCaptionFont{white}{\color{white}}
\DeclareCaptionFormat{listing}{\noindent\colorbox{blue}{\hspace{1em}#1#2#3\hspace{1em}}}
\captionsetup[lstlisting]{format=listing,labelfont=white,textfont=white,
singlelinecheck=false, margin=0pt,font={bf,sf,footnotesize}}
\captionsetup[figure]{format=listing,labelfont=white,textfont=white,aboveskip=-10pt,
singlelinecheck=false, margin=3pt,font={bf,sf,footnotesize}}


\begin{document}
\begin{lstlisting}[caption={Listing with nice caption style.},frame=single,rulecolor=\color{blue}]
Line 1
Line 2
Line 3
\end{lstlisting}

\begin{figure}
\centering
\begin{mdframed}[innerbottommargin=10pt,linecolor=blue]
\resizebox{5cm}{!}{\LaTeX}
\end{mdframed}
\caption{Figure with caption at bottom.}
\end{figure}

\begin{figure}
\centering
\caption{Figure with caption on top.}
\begin{mdframed}[innertopmargin=10pt,linecolor=blue]
\resizebox{5cm}{!}{\LaTeX}
\end{mdframed}
\end{figure}

\end{document} 

在此处输入图片描述

相关内容