2

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

enter image description here

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

enter image description here

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

2
  • 1
    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. Oct 26, 2016 at 15:12
  • The step "aksing questions on tex.stackexchange" is missing in your problem solving flowchart! Oct 26, 2016 at 15:34

1 Answer 1

2
\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}

enter image description here

2
  • @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 :) Oct 26, 2016 at 15:58
  • yes, that's true :P Oct 31, 2016 at 13:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .