我正在尝试在 overleaf 文档的图形中插入子图形。问题是子图形的标题没有居中。
有人知道该如何修复吗?提前谢谢
这是代码:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{multirow}
\usepackage{graphicx}
\usepackage{subcaption}
\begin{document}
\section {Scrum roles}
\indent\hspace{0.1in}Scrum has three roles: product owner, scrum master and the development team members. While this is pretty clear, what to do with existing job titles can get confusing. Many teams ask if they need to change their titles when adopting scrum. The short answer is no.
In this section, we’ll define scrum roles.
\begin{figure}[h]
\centering
\begin{subfigure}[b]{0.3\textwidth}
\includegraphics[width=2.5cm, height=2.5cm, scale=1.1]{figures/master.jpg}
\caption{Scrum master}
\label{fig:Scrum master}
\end{subfigure}
\begin{subfigure}[b]{0.3\textwidth}
\includegraphics[width=2.5cm, height=2.5cm, scale=1.1]{figures/equipe.jpg}
\caption{Team}
\label{fig:Equipe de développement}
\end{subfigure}
\begin{subfigure}[b]{0.3\textwidth}
\includegraphics[width=2.5cm, height=2.5cm, scale=1.1]{figures/productowner.JPG}
\caption{Product owner}
\label{fig:Product owner}
\end{subfigure}
\caption{The scrum roles}
\label{fig:The scrum roles}
\end{figure}
\begin{table}[h]
\centering
\begin{tabular}{ ||c|c||}
\hline
Product Owner & ensures that they are delivering the most value..\\
\hline
Scrum Master & gluing everything together and ensuring that scrum is being done well.\\
\hline
Team & The development team are the people that do the work\\
\hline
\end{tabular}
\caption{Description des rôles dans Scrum}
\label{table:1}
\end{table}
\end{document}
答案1
但是,您搜索的行\captionsetup[subfigure]{justification=centering}
只是使用不适合您,因为您将图像宽度硬编码为 0.3/textwidth 的浮动对象中的 2.5cm,因此您的标题将与浮动对象居中,但不与图像本身居中。 通过将图像的宽度设置为其容器,可以将两者对齐,这应该适合您:
\captionsetup[subfigure]{justification=centering}
\centering
\begin{subfigure}[b]{0.3\textwidth}
\includegraphics[width=\textwidth, scale=1.1]{figures/master.jpg}
\caption{Scrum master}
\label{fig:Scrum master}
\end{subfigure}
~
\begin{subfigure}[b]{0.3\textwidth}
\includegraphics[width=\textwidth, scale=1.1]{figures/equipe.jpg}
\caption{Team}
\label{fig:Equipe de développement}
\end{subfigure}
~
\begin{subfigure}[b]{0.3\textwidth}
\includegraphics[width=\textwidth, scale=1.1]{figures/productowner.JPG}
\caption{Product owner}
\label{fig:Product owner}
\end{subfigure}
\caption{The scrum roles}
\label{fig:The scrum roles}
\end{figure}
我还注意到您的表格超出了文本的宽度,因此我建议使用具有以下功能的 tabularx:
\usepackage{tabularx}
[![enter image description here][1]][1]
\begin{tabularx}{\textwidth}{ ||c|X||}
\hline
Product Owner & ensures that they are delivering the most value..\\
\hline
Scrum Master & gluing everything together and ensuring that scrum is being done well.\\
\hline
Team & The development team are the people that do the work\\
\hline
\end{tabularx}
答案2
像这样:
\documentclass{article}
\usepackage{graphicx}
\usepackage{tabularx}
\usepackage{subcaption}
\begin{document}
\section {Scrum roles}
\indent\hspace{0.1in}Scrum has three roles: product owner, scrum master and the development team members. While this is pretty clear, what to do with existing job titles can get confusing. Many teams ask if they need to change their titles when adopting scrum. The short answer is no. In this section, we’ll define scrum roles.
With \verb+\centering+ in `\verb+subfigre+ environments:
\begin{figure}[ht]
\centering
\setkeys{Gin}{width=2.5cm, height=2.5cm}
\begin{subfigure}[b]{0.3\textwidth}\centering
\includegraphics{example-image-duck}%{figures/master.jpg}
\caption{Scrum master}
\label{fig:Scrum master}
\end{subfigure}
\begin{subfigure}[b]{0.3\textwidth}\centering
\includegraphics{example-image-duck}%{figures/equipe.jpg}
\caption{Team}
\label{fig:Equipe de développement}
\end{subfigure}
\begin{subfigure}[b]{0.3\textwidth}\centering
\includegraphics{example-image-duck}%{figures/productowner.JPG}
\caption{Product owner}
\label{fig:Product owner}
\end{subfigure}
\caption{The scrum roles}
\label{fig:The scrum roles}
\end{figure}
or with use of \verb+subfloat+ commands
\begin{figure}[ht]
\centering
\setkeys{Gin}{width=2.5cm, height=2.5cm}
\subfloat[Scrum master]{\includegraphics{example-image-duck}
\label{fig:Scrum master}}
\hfil
\subfloat[Team]{\includegraphics{example-image-duck}
\label{fig:Equipe de développement}}
\hfil
\subfloat[Product owner]{\includegraphics{example-image-duck}
\label{fig:Product owner}}
\caption{The scrum roles}
\label{fig:The scrum roles}
\end{figure}
\begin{table}[h]
\centering
\begin{tabularx}{\linewidth}{ ||l|X||}
\hline
Product Owner & ensures that they are delivering the most value..\\
\hline
Scrum Master & gluing everything together and ensuring that scrum is being done well.\\
\hline
Team & The development team are the people that do the work\\
\hline
\end{tabularx}
\caption{Description des rôles dans Scrum}
\label{table:1}
\end{table}
\end{document}
笔记:
- 在您的 MWE(最小工作示例)中,子标题居中于
subfigure
环境,但图像却不是(它们左对齐)。可以通过添加\centering
后缀来纠正此问题\begin{subfigure}[b]{0.3\textwidth}
,就像上面的 MWE 中所做的那样。 - 除了使用子图环境(如果您使用的是最新版本的
subcaption
软件包),您还可以使用\subfloat
命令来自动将图像和标题居中。请参阅 MWE 中的第二个示例。
无关:
- 通过
[width=2.5cm, height=2.5cm, scale=1.1]
“scale”选项定义图像大小没有任何效果。可以像上面的MWE一样删除它 - 您的表格 ID 比 宽
\textwidth
,因此它会突出右侧文本区域边距。这可以通过使用tabularx
表格轻松防止(请参阅 MWE)