captionsetup 命令对子字幕有用吗?

captionsetup 命令对子字幕有用吗?

我正在尝试使用环境将三个子图并排放置minipage

问题是我无法控制 minipage 环境中的子标题的宽度。我在下面的代码中尝试了captionsetup和,得到了这个数字。\subcaption[]

在此处输入图片描述

显然这三个子标题太过接近。改变captionsetup或的参数\subcaption[]确实会产生影响,无论我尝试了0.1\textwidth0.5\linewidth1cm

目前唯一可行的方案是直接缩小 minipage 的宽度,然后插入\hspaceminipage 之间。这很不方便,因为我可能会更新具有不同边距的 tikz 图形,而这种方法需要更新 minipage 和 hspace 的参数。

我的问题是,有没有什么方法可以让我们直接控制小页面中子标题的宽度?

\documentclass[sigconf, anonymous, review]{acmart}
\usepackage{booktabs}

\setcopyright{rightsretained}

\usepackage{amsmath}
%\usepackage[small]{caption}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{tikz}
\usetikzlibrary{fit,positioning,automata,calc}

\begin{document}

\title{No title}

\maketitle

\section{PLEASE READ FROM HERE..................................}

\begin{figure}[!t]
\begin{minipage}{0.164\textwidth}% The article is double-column, I'd like to place three subfigures side-by-side in one column. 1/2/3=0.166666...
\centering
\begin{tikzpicture}
\footnotesize
\tikzstyle{main}=[circle, minimum size = 3.6mm, thick, draw =black!80, node distance = 3mm]
\tikzstyle{connect}=[-latex, thick]
  \node[main] (i)  {\scriptsize $i$};
  \node[main] (above_i) [above left=of i] {};
  \node[main] (left_i) [left=of i] {};
  \node[main] (right_i) [right=of i] {};
  \node[main] (right_above_i) [above right=of i, above left=of right_i] {};
  \path (i) edge node {} (above_i);
  \path (i) edge node {} (left_i);
  \path (i) edge node {} (right_i);
  \path (i) edge node {} (right_above_i);
  \path (above_i) edge node {} (left_i);
  \path (right_i) edge node {} (right_above_i);

\end{tikzpicture}
\captionsetup{width=0.7\textwidth}% Within this minipage environment, the local \textwidth is 1 I don't want subcpations of two subfigures too close to each other, so I use a ratio of 0.7. But it does not work.
\subcaption[width=0.7\textwidth]{the subcaption of this subfig is very long very long}
\label{fig:1}
\end{minipage}%
\begin{minipage}{0.164\textwidth}
\centering
\begin{tikzpicture}
\footnotesize
\tikzstyle{main}=[circle, minimum size = 3.6mm, thick, draw =black!80, node distance = 3mm]
\tikzstyle{connect}=[-latex, thick]
  \node[main] (i)  {\scriptsize $i$};
  \node[main] (above_i) [above left=of i] {};
  \node[main,fill=black!10] (left_i) [left=of i] {};
  \node[main] (right_i) [right=of i] {};
  \node[main] (right_above_i) [above right=of i, above left=of right_i] {};
  \path (i) edge node {} (above_i);
  \path (i) edge node {} (left_i);
  \path (i) edge node {} (right_i);
  \path (i) edge node {} (right_above_i);
  \path (above_i) edge node {} (left_i);
  \path (right_i) edge node {} (right_above_i);

\end{tikzpicture}
\captionsetup{width=0.7\textwidth}
\subcaption{\small the subcaption of this subfig is very long very long}
\label{fig:2}
\end{minipage}%
\begin{minipage}{0.164\textwidth}
\centering
\begin{tikzpicture}
\footnotesize
\tikzstyle{main}=[circle, minimum size = 3.6mm, thick, draw =black!80, node distance = 3mm]
\tikzstyle{connect}=[-latex, thick]
  \node[main] (i)  {\scriptsize $i$};
  \node[main] (above_i) [above left=of i] {};
  \node[main] (left_i) [left=of i] {};
  \node[main] (right_i) [right=of i] {};
  \node[main,fill=black!10] (right_above_i) [above right=of i, above left=of right_i] {};
  \path (i) edge node {} (above_i);
  \path (i) edge node {} (left_i);
  \path (i) edge node {} (right_i);
  \path (i) edge node {} (right_above_i);
  \path (above_i) edge node {} (left_i);
  \path (right_i) edge node {} (right_above_i);

\end{tikzpicture}
\captionsetup{width=0.7\textwidth}%
\subcaption{\small the subcaption of this subfig is very long very long}
\label{fig:3}
\end{minipage}
\captionsetup{width=0.4\textwidth}
\caption{\small this caption is the caption to all the three sub-figures}
\vspace{-0.2cm}
\end{figure}


\end{document}

答案1

您可以避免大部分计算:

\documentclass[sigconf, anonymous, review]{acmart}

\usepackage{booktabs}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{tikz}
\usetikzlibrary{fit,positioning,automata,calc}

\setcopyright{rightsretained}

% general options for subfigure captions
\captionsetup[subfigure]{
  font=footnotesize,
  justification=raggedright
}

\begin{document}

\title{No title}

\maketitle

\section{PLEASE READ FROM HERE..................................}

\begin{figure}[!ht]

% local setting for subfigure captions
\captionsetup[subfigure]{margin=0.1\columnwidth}

\begin{subfigure}{0.33333\columnwidth}
\centering
\begin{tikzpicture}
\tikzstyle{main}=[circle, minimum size = 3.6mm, thick, draw =black!80, node distance = 3mm]
\tikzstyle{connect}=[-latex, thick]
  \node[main] (i)  {\scriptsize $i$};
  \node[main] (above_i) [above left=of i] {};
  \node[main] (left_i) [left=of i] {};
  \node[main] (right_i) [right=of i] {};
  \node[main] (right_above_i) [above right=of i, above left=of right_i] {};
  \path (i) edge node {} (above_i);
  \path (i) edge node {} (left_i);
  \path (i) edge node {} (right_i);
  \path (i) edge node {} (right_above_i);
  \path (above_i) edge node {} (left_i);
  \path (right_i) edge node {} (right_above_i);
\end{tikzpicture}
\caption{the subcaption of this subfig is very long very long}
\label{fig:1}
\end{subfigure}\hfill
\begin{subfigure}{0.33333\columnwidth}
\centering
\begin{tikzpicture}
\tikzstyle{main}=[circle, minimum size = 3.6mm, thick, draw =black!80, node distance = 3mm]
\tikzstyle{connect}=[-latex, thick]
  \node[main] (i)  {\scriptsize $i$};
  \node[main] (above_i) [above left=of i] {};
  \node[main,fill=black!10] (left_i) [left=of i] {};
  \node[main] (right_i) [right=of i] {};
  \node[main] (right_above_i) [above right=of i, above left=of right_i] {};
  \path (i) edge node {} (above_i);
  \path (i) edge node {} (left_i);
  \path (i) edge node {} (right_i);
  \path (i) edge node {} (right_above_i);
  \path (above_i) edge node {} (left_i);
  \path (right_i) edge node {} (right_above_i);
\end{tikzpicture}
\subcaption{the subcaption of this subfig is very long very long}
\label{fig:2}
\end{subfigure}\hfill
\begin{subfigure}{0.33333\columnwidth}
\centering
\begin{tikzpicture}
\tikzstyle{main}=[circle, minimum size = 3.6mm, thick, draw =black!80, node distance = 3mm]
\tikzstyle{connect}=[-latex, thick]
  \node[main] (i)  {\scriptsize $i$};
  \node[main] (above_i) [above left=of i] {};
  \node[main] (left_i) [left=of i] {};
  \node[main] (right_i) [right=of i] {};
  \node[main,fill=black!10] (right_above_i) [above right=of i, above left=of right_i] {};
  \path (i) edge node {} (above_i);
  \path (i) edge node {} (left_i);
  \path (i) edge node {} (right_i);
  \path (i) edge node {} (right_above_i);
  \path (above_i) edge node {} (left_i);
  \path (right_i) edge node {} (right_above_i);
\end{tikzpicture}
\subcaption{the subcaption of this subfig is very long very long}
\label{fig:3}
\end{subfigure}

\caption{this caption is the caption to all the three sub-figures}

\end{figure}

\end{document}

在此处输入图片描述

答案2

您可以使用命令的可选参数\subcaptionbox来指定宽度,而无需任何小页面:

\documentclass[sigconf, anonymous, review]{acmart}
\usepackage{booktabs}
\usepackage{threeparttable}
\setcopyright{rightsretained}

\usepackage{amsmath}
%\usepackage[small]{caption}
\usepackage{graphicx}
\usepackage{caption, subcaption}
\usepackage{tikz}
\usetikzlibrary{fit,positioning,automata,calc}

\begin{document}

\title{No title}

\maketitle

\section{PLEASE READ FROM HERE..................................}
\vspace*{1\baselineskip}
\begin{figure}[!htb]%
\captionsetup{justification = RaggedRight}
\subcaptionbox{The subcaption of this subfigure is very long very long}[0.3\linewidth]
 { \begin{tikzpicture}
\footnotesize
\tikzstyle{main}=[circle, minimum size = 3.6mm, thick, draw =black!80, node distance = 3mm]
\tikzstyle{connect}=[-latex, thick]
  \node[main] (i) {\scriptsize $i$};
  \node[main] (above_i) [above left=of i] {};
  \node[main] (left_i) [left=of i] {};
  \node[main] (right_i) [right=of i] {};
  \node[main] (right_above_i) [above right=of i, above left=of right_i] {};
  \path (i) edge node {} (above_i);
  \path (i) edge node {} (left_i);
  \path (i) edge node {} (right_i);
  \path (i) edge node {} (right_above_i);
  \path (above_i) edge node {} (left_i);
  \path (right_i) edge node {} (right_above_i);
\end{tikzpicture}}\hfill
\subcaptionbox{The subcaption of this subfigure is very long very long}[0.3\linewidth]
{\begin{tikzpicture}
\footnotesize
\tikzstyle{main}=[circle, minimum size = 3.6mm, thick, draw =black!80, node distance = 3mm]
\tikzstyle{connect}=[-latex, thick]
  \node[main] (i) {\scriptsize $i$};
  \node[main] (above_i) [above left=of i] {};
  \node[main,fill=black!10] (left_i) [left=of i] {};
  \node[main] (right_i) [right=of i] {};
  \node[main] (right_above_i) [above right=of i, above left=of right_i] {};
  \path (i) edge node {} (above_i);
  \path (i) edge node {} (left_i);
  \path (i) edge node {} (right_i);
  \path (i) edge node {} (right_above_i);
  \path (above_i) edge node {} (left_i);
  \path (right_i) edge node {} (right_above_i);
\end{tikzpicture}}\hfill
\subcaptionbox{The subcaption of this subfigure is very long very long}[0.3\linewidth]
{
\begin{tikzpicture}
\footnotesize
\tikzstyle{main}=[circle, minimum size = 3.6mm, thick, draw =black!80, node distance = 3mm]
\tikzstyle{connect}=[-latex, thick]
  \node[main] (i) {\scriptsize $i$};
  \node[main] (above_i) [above left=of i] {};
  \node[main] (left_i) [left=of i] {};
  \node[main] (right_i) [right=of i] {};
  \node[main,fill=black!10] (right_above_i) [above right=of i, above left=of right_i] {};
  \path (i) edge node {} (above_i);
  \path (i) edge node {} (left_i);
  \path (i) edge node {} (right_i);
  \path (i) edge node {} (right_above_i);
  \path (above_i) edge node {} (left_i);
  \path (right_i) edge node {} (right_above_i);
\end{tikzpicture}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%
\caption{This caption is the caption to all the three sub-figures}
\end{figure}

\end{document} 

在此处输入图片描述

相关内容