我有两个彼此相邻的图形,我想将图形标题居中,但要完全居中,即包括图 xx: 居中。
这是我正在使用的代码:
\begin{figure}[!tbph]
\centering
\begin{minipage}[b]{0.4\textwidth}
\includegraphics[scale=0.2]{images/pie_chart_mobile.png}
\caption{Frequency of playing mobile video games}
\label{fig:pie_chart_mobile}
\end{minipage}
\hfill
\begin{minipage}[b]{0.4\textwidth}
\includegraphics[scale=0.2]{images/pie_chart_multiplayer.png}
\caption{Preference regarding multiplayer games}
\label{fig:pie_chart_multiplayer}
\end{minipage}
\end{figure}
这就是我得到的:
我真正想要的是这个:
我试过包装justification=centering
上的caption
,没用。有什么想法吗?
编辑:MWE:
\RequirePackage[l2tabu,orthodox]{nag}
\documentclass[headsepline,footsepline,footinclude=false,oneside,fontsize=11pt,paper=a4,listof=totoc,bibliography=totoc]{scrbook} % one-sided
\PassOptionsToPackage{table,svgnames,dvipsnames}{xcolor}
\usepackage[%
backend=biber,
url=false,
style=alphabetic,
maxnames=4,
minnames=3,
maxbibnames=99,
firstinits,
uniquename=init]{biblatex} % TODO: adapt bibliography style
\usepackage[demo]{graphicx}
\usepackage{caption}
\captionsetup{justification=centering}
\begin{document}
\begin{figure}[!tbph]
\centering
\begin{minipage}[b]{0.4\textwidth}
\includegraphics[scale=0.2]{images/pie_chart_mobile.png}
\caption{Frequency of playing mobile video games}
\end{minipage}
\hfill
\begin{minipage}[b]{0.4\textwidth}
\includegraphics[scale=0.2]{images/pie_chart_multiplayer.png}
\caption{Preference regarding multiplayer games}
\end{minipage}
\end{figure}
\end{document}
结果:
答案1
您必须在 KOMA-Script 中将标题缩进设置为,0pt
并将格式设置为\centering
如下所示:
\setcapindent{0pt}
\addtokomafont{caption}{\centering}
因此,以下操作应该有效:
\RequirePackage[l2tabu,orthodox]{nag}
\documentclass[headsepline,footsepline,footinclude=false,oneside,fontsize=11pt,paper=a4,listof=totoc,bibliography=totoc]{scrbook} % one-sided
\PassOptionsToPackage{table,svgnames,dvipsnames}{xcolor}
\usepackage[%
backend=biber,
url=false,
style=alphabetic,
maxnames=4,
minnames=3,
maxbibnames=99,
firstinits,
uniquename=init]{biblatex} % TODO: adapt bibliography style
\usepackage[demo]{graphicx}
\usepackage{caption}
% The fix:
\setcapindent{0pt}
\addtokomafont{caption}{\centering}
\begin{document}
\begin{figure}
\centering
\begin{minipage}[b]{0.4\textwidth}
\includegraphics[width=\linewidth]{images/pie_chart_mobile.png}
\caption{Frequency of playing mobile video games}
\label{fig:pie_chart_mobile}
\end{minipage}
\hfill
\begin{minipage}[b]{0.4\textwidth}
\includegraphics[width=\linewidth]{images/pie_chart_multiplayer.png}
\caption{Preference regarding multiplayer games}
\label{fig:pie_chart_multiplayer}
\end{minipage}
\end{figure}
\end{document}
答案2
包裹caption
caption
带有选项的包justification=centering
通常有助于:
\documentclass{article}
\usepackage[demo]{graphicx}% demo only because of missing images
\usepackage{caption}
\captionsetup{justification=centering}
\begin{document}
\begin{figure}[!tbph]
\centering
\begin{minipage}[b]{0.4\textwidth}
\includegraphics[width=\linewidth]{images/pie_chart_mobile.png}
\caption{Frequency of playing mobile video games}
\label{fig:pie_chart_mobile}
\end{minipage}
\hfill
\begin{minipage}[b]{0.4\textwidth}
\includegraphics[width=\linewidth]{images/pie_chart_multiplayer.png}
\caption{Preference regarding multiplayer games}
\label{fig:pie_chart_multiplayer}
\end{minipage}
\end{figure}
\end{document}
KOMA 脚本类
看回答的 nordev。
班级memoir
课程memoir
提供\captionstyle
:
\documentclass{memoir}
\usepackage[demo]{graphicx}% demo only because of missing images
\captionstyle{\centering}
\begin{document}
\begin{figure}[!tbph]
\centering
\begin{minipage}[b]{0.4\textwidth}
\includegraphics[width=\linewidth]{images/pie_chart_mobile.png}
\caption{Frequency of playing mobile video games}
\label{fig:pie_chart_mobile}
\end{minipage}
\hfill
\begin{minipage}[b]{0.4\textwidth}
\includegraphics[width=\linewidth]{images/pie_chart_multiplayer.png}
\caption{Preference regarding multiplayer games}
\label{fig:pie_chart_multiplayer}
\end{minipage}
\end{figure}
\end{document}