难以将图片和标题置于中心

难以将图片和标题置于中心

我尝试将图形水平并排放置,但遇到以下困难:

  1. 左右边距大小不一致。

  2. 图形之间的空间大小不相等。

  3. 标题与图形不处于同一中心。

  4. 左图的标题已损坏。

附上问题的代码和截图。

我将非常感激您的帮助。

人物

    \begin{frame}
        \begin{center}
            \begin{figure}
                \centering
                \begin{minipage}{.17\linewidth}
                    \captionsetup[subfigure]{font=scriptsize,labelfont=scriptsize,justification=raggedright}
                    \subcaptionbox*{0-simplex \\ "point"}
                    {
                        \begin{tikzpicture}[scale=1]
                            \coordinate (A) at (0,0);
                            \shade[ball color = red, opacity = 1] (A) circle (1mm);
                        \end{tikzpicture}
                    }
                \end{minipage}
                \begin{minipage}{.17\linewidth}
                    \captionsetup[subfigure]{font=scriptsize,labelfont=scriptsize}
                    \subcaptionbox*{1-simplex \\ "line segment"}
                    {
                        \begin{tikzpicture}[scale=1]
                            \coordinate (A) at (.6,0);
                            \coordinate (B) at (-.6,0);
                            \draw[opacity=.5] (A)--(B);
                            \shade[ball color = red, opacity = 1] (A) circle (1mm);
                            \shade[ball color = red, opacity = 1] (B) circle (1mm);
                        \end{tikzpicture}
                  }
                \end{minipage}
                \begin{minipage}{.17\linewidth}
                    \captionsetup[subfigure]{font=scriptsize,labelfont=scriptsize}
                    \subcaptionbox*{2-simplex \\ "triangle"}
                    {
                        \begin{tikzpicture}[scale=1]
                        \coordinate (A) at (.6,0);
                        \coordinate (B) at (0,1);
                        \coordinate (C) at (-.6,0);
                        \draw[fill=green!30, opacity=.5] (A)--(B)--(C)--cycle;
                        \shade[ball color = red, opacity = 1] (A) circle (1mm);
                        \shade[ball color = red, opacity = 1] (B) circle (1mm);
                        \shade[ball color = red, opacity = 1] (C) circle (1mm);
                    \end{tikzpicture}
                }
                \end{minipage}
                \begin{minipage}{.17\linewidth}
                    \captionsetup[subfigure]{font=scriptsize,labelfont=scriptsize}
                    \subcaptionbox*{3-simplex \\ "tetrahedron"}
                    {
                        \begin{tikzpicture}[scale=1]
                            \coordinate (A) at (.8,0,0);
                            \coordinate (B) at (-.7,-.1,0);
                            \coordinate (C) at (0,1,0);
                            \coordinate (D) at (.2,-.6,0);
                            \draw[fill=gray!30, opacity=1, dashed] (A)--(D)--(B)--cycle;
                            \draw[fill=green!30, opacity=.5] (A)--(D)--(C)--cycle;
                            \draw[fill=red!30, opacity=.5] (B)--(D)--(C)--cycle;
                            \shade[ball color = red, opacity = 1] (A) circle (1mm);
                            \shade[ball color = red, opacity = 1] (B) circle (1mm);
                            \shade[ball color = red, opacity = 1] (C) circle (1mm);
                            \shade[ball color = red, opacity = 1] (D) circle (1mm);
                        \end{tikzpicture}
                    }
                \end{minipage}
                \begin{minipage}{.17\linewidth}
                    \centering
                    \captionsetup[subfigure]{font=scriptsize,labelfont=scriptsize}
                    \subcaptionbox*{4-simplex \\ "5-cell"}
                    {
                        \begin{tikzpicture}[scale=1]
                            \coordinate (A) at (.8,0,0);
                            \coordinate (B) at (-.7,-.1,0);
                            \coordinate (C) at (0,1,0);
                            \coordinate (D) at (.2,-.6,0);
                            \coordinate (E) at (-.1,.2,0);
                            \draw[fill=gray!30, opacity=1, dashed] (A)--(D)--(B)--cycle;
                            \draw[fill=green!30, opacity=.5] (A)--(D)--(C)--cycle;
                            \draw[fill=red!30, opacity=.5] (B)--(D)--(C)--cycle;
                            \draw[opacity=.5,dashed] (A)--(E)--cycle;
                            \draw[opacity=.5,dashed] (B)--(E)--cycle;
                            \draw[opacity=.5,dashed] (C)--(E)--cycle;
                            \draw[opacity=.5,dashed] (D)--(E)--cycle;
                            \shade[ball color = red, opacity = 1] (A) circle (1mm);
                            \shade[ball color = red, opacity = 1] (B) circle (1mm);
                            \shade[ball color = red, opacity = 1] (C) circle (1mm);
                            \shade[ball color = red, opacity = 1] (D) circle (1mm);
                            \shade[ball color = red, opacity = 1] (E) circle (1mm);
                        \end{tikzpicture}
                    }
                \end{minipage}
            \end{figure}
        \end{center}
    \end{frame}

答案1

将每个项目放置在固定宽度中,\subcaptionbox每个图像的宽度均等。我在下面使用了5em\hfill每个项目之间的宽度\subcaptionbox均等地分布在图像之间。

在此处输入图片描述

\documentclass{beamer}

\usepackage{tikz,subcaption}

\begin{document}

\begin{frame}

  \begin{figure}
    \captionsetup[subfigure]{font=scriptsize,justification=centering}
    \subcaptionbox*{0-simplex \\ ``point''}[4em]{%
      \begin{tikzpicture}[scale=1]
        \coordinate (A) at (0,0);
        \shade[ball color = red, opacity = 1] (A) circle (1mm);
      \end{tikzpicture}
    }\hfill
    \subcaptionbox*{1-simplex \\ ``line segment''}[5em]{%
      \begin{tikzpicture}[scale=1]
        \coordinate (A) at (.6,0);
        \coordinate (B) at (-.6,0);
        \draw[opacity=.5] (A)--(B);
        \shade[ball color = red, opacity = 1] (A) circle (1mm);
        \shade[ball color = red, opacity = 1] (B) circle (1mm);
      \end{tikzpicture}
    }\hfill
    \subcaptionbox*{2-simplex \\ ``triangle''}[5em]{%
      \begin{tikzpicture}[scale=1]
        \coordinate (A) at (.6,0);
        \coordinate (B) at (0,1);
        \coordinate (C) at (-.6,0);
        \draw[fill=green!30, opacity=.5] (A)--(B)--(C)--cycle;
        \shade[ball color = red, opacity = 1] (A) circle (1mm);
        \shade[ball color = red, opacity = 1] (B) circle (1mm);
        \shade[ball color = red, opacity = 1] (C) circle (1mm);
      \end{tikzpicture}
    }\hfill
    \subcaptionbox*{3-simplex \\ ``tetrahedron''}[5em]{%
      \begin{tikzpicture}[scale=1]
        \coordinate (A) at (.8,0,0);
        \coordinate (B) at (-.7,-.1,0);
        \coordinate (C) at (0,1,0);
        \coordinate (D) at (.2,-.6,0);
        \draw[fill=gray!30, opacity=1, dashed] (A)--(D)--(B)--cycle;
        \draw[fill=green!30, opacity=.5] (A)--(D)--(C)--cycle;
        \draw[fill=red!30, opacity=.5] (B)--(D)--(C)--cycle;
        \shade[ball color = red, opacity = 1] (A) circle (1mm);
        \shade[ball color = red, opacity = 1] (B) circle (1mm);
        \shade[ball color = red, opacity = 1] (C) circle (1mm);
        \shade[ball color = red, opacity = 1] (D) circle (1mm);
      \end{tikzpicture}
    }\hfill
    \subcaptionbox*{4-simplex \\ ``5-cell''}[5em]{%
      \begin{tikzpicture}[scale=1]
        \coordinate (A) at (.8,0,0);
        \coordinate (B) at (-.7,-.1,0);
        \coordinate (C) at (0,1,0);
        \coordinate (D) at (.2,-.6,0);
        \coordinate (E) at (-.1,.2,0);
        \draw[fill=gray!30, opacity=1, dashed] (A)--(D)--(B)--cycle;
        \draw[fill=green!30, opacity=.5] (A)--(D)--(C)--cycle;
        \draw[fill=red!30, opacity=.5] (B)--(D)--(C)--cycle;
        \draw[opacity=.5,dashed] (A)--(E)--cycle;
        \draw[opacity=.5,dashed] (B)--(E)--cycle;
        \draw[opacity=.5,dashed] (C)--(E)--cycle;
        \draw[opacity=.5,dashed] (D)--(E)--cycle;
        \shade[ball color = red, opacity = 1] (A) circle (1mm);
        \shade[ball color = red, opacity = 1] (B) circle (1mm);
        \shade[ball color = red, opacity = 1] (C) circle (1mm);
        \shade[ball color = red, opacity = 1] (D) circle (1mm);
        \shade[ball color = red, opacity = 1] (E) circle (1mm);
      \end{tikzpicture}
    }
  \end{figure}

\end{frame}

\end{document}

答案2

在框架内(重新)定义\setbeamertemplate(仅在此框架内有效)并用于minipage放置[b]

\documentclass{beamer}
\usepackage{tikz}

\begin{document}
\begin{frame}
    \setbeamertemplate{caption}{\parbox{\linewidth}{\centering\insertcaption\vphantom{g}\par}} % <--- 
    \setbeamerfont{caption}{size=\scriptsize} % <---
\begin{figure}
    \begin{minipage}[b]{.18\linewidth}\centering % <---
        \begin{tikzpicture}[baseline] % <---
            \coordinate (A) at (0,0);
            \shade[ball color = red, opacity = 1] (A) circle (1mm);
        \end{tikzpicture}
        \caption{0-simplex\\ "point"}
    \end{minipage}%
    \hfill
    \begin{minipage}[b]{.18\linewidth}\centering
        \begin{tikzpicture}[baseline]
            \coordinate (A) at (.6,0);
            \coordinate (B) at (-.6,0);
            \draw[opacity=.5] (A)--(B);
            \shade[ball color = red, opacity = 1] (A) circle (1mm);
            \shade[ball color = red, opacity = 1] (B) circle (1mm);
        \end{tikzpicture}
        \caption{1-simplex\\ "line segment"}
    \end{minipage}%
    \hfill
    \begin{minipage}[b]{.18\linewidth}\centering
        \begin{tikzpicture}[baseline]
            \coordinate (A) at (.6,0);
            \coordinate (B) at (0,1);
            \coordinate (C) at (-.6,0);
            \draw[fill=green!30, opacity=.5] (A)--(B)--(C)--cycle;
            \shade[ball color = red, opacity = 1] (A) circle (1mm);
            \shade[ball color = red, opacity = 1] (B) circle (1mm);
            \shade[ball color = red, opacity = 1] (C) circle (1mm);
        \end{tikzpicture}
        \caption{2-simplex\\ "triangle"}
    \end{minipage}%
    \hfill
    \begin{minipage}[b]{.18\linewidth}\centering
        \begin{tikzpicture}[baseline]
            \coordinate (A) at (.8,0,0);
            \coordinate (B) at (-.7,-.1,0);
            \coordinate (C) at (0,1,0);
            \coordinate (D) at (.2,-.6,0);
            \draw[fill=gray!30, opacity=1, dashed] (A)--(D)--(B)--cycle;
            \draw[fill=green!30, opacity=.5] (A)--(D)--(C)--cycle;
            \draw[fill=red!30, opacity=.5] (B)--(D)--(C)--cycle;
            \shade[ball color = red, opacity = 1] (A) circle (1mm);
            \shade[ball color = red, opacity = 1] (B) circle (1mm);
            \shade[ball color = red, opacity = 1] (C) circle (1mm);
            \shade[ball color = red, opacity = 1] (D) circle (1mm);
        \end{tikzpicture}
        \caption{3-simplex\\ "tetrahedron"}
    \end{minipage}%
    \hfill
    \begin{minipage}[b]{.18\linewidth}\centering
        \centering
        \begin{tikzpicture}[baseline]
            \coordinate (A) at (.8,0,0);
            \coordinate (B) at (-.7,-.1,0);
            \coordinate (C) at (0,1,0);
            \coordinate (D) at (.2,-.6,0);
            \coordinate (E) at (-.1,.2,0);
            \draw[fill=gray!30, opacity=1, dashed] (A)--(D)--(B)--cycle;
            \draw[fill=green!30, opacity=.5] (A)--(D)--(C)--cycle;
            \draw[fill=red!30, opacity=.5] (B)--(D)--(C)--cycle;
            \draw[opacity=.5,dashed] (A)--(E)--cycle;
            \draw[opacity=.5,dashed] (B)--(E)--cycle;
            \draw[opacity=.5,dashed] (C)--(E)--cycle;
            \draw[opacity=.5,dashed] (D)--(E)--cycle;
            \shade[ball color = red, opacity = 1] (A) circle (1mm);
            \shade[ball color = red, opacity = 1] (B) circle (1mm);
            \shade[ball color = red, opacity = 1] (C) circle (1mm);
            \shade[ball color = red, opacity = 1] (D) circle (1mm);
            \shade[ball color = red, opacity = 1] (E) circle (1mm);
        \end{tikzpicture}
        \caption{4-simplex\\ "5-cell"}
    \end{minipage}
\end{figure}
\end{frame}
\end{document}

在此处输入图片描述

相关内容