# Latex Beamer Box around figure, caption name and caption

I have been trying to put separate frames around a figure, its caption and caption name. Please see the image below:

I already managed to create a frame around the image itself and the caption:

But how can I put the caption name (e.g. Fig.1) in a separate box?

My code looks like this so far:

\documentclass[t,8pt]{beamer}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{caption}
\usepackage{tcolorbox}
\usepackage[framemethod=tikz]{mdframed}

\newmdenv[
innerlinewidth=0.1mm,
roundcorner=4pt,
linecolor=black,
innerleftmargin=6pt,
innerrightmargin=6pt,
innertopmargin=6pt,
innerbottommargin=6pt]{mybox}

% Framed figure
\newcommand{\framedFigure}[2]{%
\vspace{-2mm}
\begin{figure}

\begin{mybox}
\centering
#1
\end{mybox}

\vspace{-3.5mm}

\begin{tcolorbox}[
boxrule=0.2mm,boxsep=-3.5mm,lowerbox=ignored,colback=lightgray,
colframe=black
]
\caption{#2}
\end{tcolorbox}

\vspace{-3mm}
\end{figure}
}

\begin{document}

\begin{frame}{}

\framedFigure{
\begin{tikzpicture}[scale=1.3]
\node[draw=black,circle,fill=lightgray] (A) at (0,0){\textbf{A}};
\node[draw=black,circle,fill=lightgray] (B) at (3,0){\textbf{B}};
\draw[->,dashed] (A) -- node[above]{$k$} (B);
\end{tikzpicture}
}{$k$-$folgt$ Relation für die kritischen Abschnitte A und B}

\end{frame}

\end{document}


Any help would be appreciated. Thanks in advance. :) Daniel

• Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – Henri Menke Oct 26 '16 at 15:12
• The step "aksing questions on tex.stackexchange" is missing in your problem solving flowchart! – user36296 Oct 26 '16 at 15:34

\documentclass[t,8pt]{beamer}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{tcolorbox}
\usepackage[framemethod=tikz]{mdframed}

\newmdenv[
innerlinewidth=0.1mm,
roundcorner=4pt,
linecolor=black,
innerleftmargin=6pt,
innerrightmargin=6pt,
innertopmargin=6pt,
innerbottommargin=6pt]{mybox}

\setbeamertemplate{caption}{%
\begin{tcolorbox}[colback=lightgray,colframe=black,width=.25\linewidth]
\insertcaptionname~%
\insertcaptionnumber%
\usebeamertemplate{caption label separator}%
\end{tcolorbox}%
\space%
\begin{tcolorbox}[colback=lightgray,colframe=black,width=.74\linewidth]
\insertcaption%
\end{tcolorbox}%
}

\begin{document}

\begin{frame}{}
\begin{figure}
\begin{mybox}
\centering
\begin{tikzpicture}[scale=1.3]
\node[draw=black,circle,fill=lightgray] (A) at (0,0){\textbf{A}};
\node[draw=black,circle,fill=lightgray] (B) at (3,0){\textbf{B}};
\draw[->,dashed] (A) -- node[above]{$k$} (B);
\end{tikzpicture}
\end{mybox}
\caption{$k$-$folgt$ Relation für die kritischen Abschnitte A und B}
\end{figure}
\end{frame}

\end{document}


• @DanielWehner You're welcome! But your "Vom Problem zum Program" image is still missing asking questions on TeX.SX and getting an answer that solves your problem :) – user36296 Oct 26 '16 at 15:58
• yes, that's true :P – Daniel Wehner Oct 31 '16 at 13:43