如何使用 floatrow 包将一些浮点数均匀分布在一行中?

如何使用 floatrow 包将一些浮点数均匀分布在一行中?

我试图在一条线上均匀分布三个带有标题的浮点数 (tikzpictures),使它们在线上等距:第一个应该在最左边,第二个应该正好在线的中点,第三个应该在线的最右边,但没有成功。我在手册中找不到任何可以帮助我的东西floatrow(可能是我错过了)。如果有人能帮忙,我将不胜感激。我愿意接受新的建议,因为这个floatrow包有点旧了(从 2009 年开始就没有更新了)。我试过了,\makebox[s]但没有成功。

\documentclass[12pt]{exam}
\usepackage{calc}
\usepackage[a4paper, total={180mm,257mm},left=15mm,top=20mm,showframe]{geometry}
\usepackage[labelformat=empty,indention=0pt,justification=centering,singlelinecheck=no,textfont={normalsize}]{caption}
\usepackage{floatrow,tikz,amsmath}
\begin{document}
    \begin{figure}[h!]
        \begin{floatrow}[3]
            \ffigbox[\FBwidth]{
                \begin{tikzpicture}[scale=0.7]
                    \draw[thick] (0,0) circle (2);
                    \draw[fill=gray!50] (0,0) -- +(180:2) arc (180:108:2);
                    \foreach \x in {0,36,...,360} \draw[thick] (0,0) -- (\x:2);
            \end{tikzpicture}}{\caption{$\dfrac{1}{5}=\dfrac{\fbox{\phantom{\Large A}}}{\fbox{\phantom{\Large A}}}$}}
            
            \ffigbox[\FBwidth+\Xhsize/2]{
                \begin{tikzpicture}[scale=0.7]
                    \draw[fill=gray!50,step=0.75,line width=1pt] (0,1.5) grid (3,3.75) rectangle (0,1.5);
                    \draw[step=0.75, line width=1pt] (0,0) grid (3,1.5);
            \end{tikzpicture}}{\caption{$\dfrac{3}{5}=\dfrac{\fbox{\phantom{\Large A}}}{\fbox{\phantom{\Large A}}}$}}
            
            \ffigbox[\Xhsize]{
                \begin{tikzpicture}[scale=0.7]
                    \foreach \x in {0,1} \draw[thick, fill=gray!50] (\x,0) rectangle (\x+1,3);
                    \draw[thick] (2,0) rectangle (3,3);
                    \draw[thick] (0,1.5) -- (3,1.5);
            \end{tikzpicture}}{\caption{$\dfrac{2}{3}=\dfrac{\fbox{\phantom{\Large A}}}{\fbox{\phantom{\Large A}}}$}}
        \end{floatrow}
    \end{figure}
\end{document}

在此处输入图片描述

答案1

这使用了\subfloatsubcaption 包。间距由 提供\hfill

从技术上讲,要将中心放置\subfloat在正中央,应该将左手放在\subfloat里面\leavevmode\rlap{...},将右手\subfloat放在里面\llap{...}

\documentclass[12pt]{exam}
\usepackage{calc}
\usepackage[a4paper, total={180mm,257mm},left=15mm,top=20mm,showframe]{geometry}
\usepackage[labelformat=empty,indention=0pt,justification=centering,singlelinecheck=no,textfont={normalsize}]{caption}
\usepackage{subcaption,tikz,amsmath}

\begin{document}
  \begin{figure}[h]
    \captionsetup[sub]{labelformat=empty}
    \subfloat[$\dfrac{1}{5}=\dfrac{\fbox{\phantom{\Large A}}}{\fbox{\phantom{\Large A}}}$]{%
      \begin{tikzpicture}[scale=0.7]%
        \draw[thick] (0,0) circle (2);
        \draw[fill=gray!50] (0,0) -- +(180:2) arc (180:108:2);
        \foreach \x in {0,36,...,360} \draw[thick] (0,0) -- (\x:2);
      \end{tikzpicture}}%
    \hfill
     \subfloat[$\dfrac{3}{5}=\dfrac{\fbox{\phantom{\Large A}}}{\fbox{\phantom{\Large A}}}$]{%
      \begin{tikzpicture}[scale=0.7]
        \draw[fill=gray!50,step=0.75,line width=1pt] (0,1.5) grid (3,3.75) rectangle (0,1.5);
        \draw[step=0.75, line width=1pt] (0,0) grid (3,1.5);
      \end{tikzpicture}}%
    \hfill
    \subfloat[$\dfrac{2}{3}=\dfrac{\fbox{\phantom{\Large A}}}{\fbox{\phantom{\Large A}}}$]{%
      \begin{tikzpicture}[scale=0.7]
        \foreach \x in {0,1} \draw[thick, fill=gray!50] (\x,0) rectangle (\x+1,3);
        \draw[thick] (2,0) rectangle (3,3);
        \draw[thick] (0,1.5) -- (3,1.5);
      \end{tikzpicture}}%
    \end{figure}
\end{document}

演示

相关内容