我有一个图形,其中有 4 个子图形,以 2 x 2 矩阵显示
\begin{figure}[h]
\begin{subfigmatrix}{2}
\subfigure[ALS1]{\includegraphics[height=2.5cm,keepaspectratio]{fig1.png}}
\subfigure[ALS2]{\includegraphics[height=2.5cm,keepaspectratio]{fig2.png}}
\subfigure[Hepatitis1]{\includegraphics[height=2.5cm,keepaspectratio]{fig3.png}}
\subfigure[Hepatitis2]{\includegraphics[height=2.5cm,keepaspectratio]{fig4.png}}
\end{subfigmatrix}
\caption{Baseline accuracy (several classifiers and number of observations).}
\label{fig:baseline}
\end{figure}
它看起来像这样
我怎样才能让图像更靠近页面中心,而不是占用整个页面的宽度?基本上它们会位于现在空白的空间中……
谢谢!
答案1
更新:(2014/10/16) 第二种方法是使用patchcmd
来etoolbox
修补\hfill
嵌入的命令,subfigmatrix
因为\hfill
用于均匀分配一行中的图形。
代码
\PassOptionsToPackage{}{graphicx}
\documentclass[]{article}
\usepackage[papersize={20cm,25cm}]{geometry}
\usepackage{graphicx}
\usepackage{subfigmat}
\usepackage{etoolbox}
\begin{document}
Before
\begin{figure}[!h]
\begin{subfigmatrix}{3}
\subfigure[ALS1]{\includegraphics[height=2.5cm,keepaspectratio]{example-image-a}}
\subfigure[ALS2]{\includegraphics[height=2.5cm,keepaspectratio]{example-image-a}}
\subfigure[ALS1]{\includegraphics[height=2.5cm,keepaspectratio]{example-image-a}}
\subfigure[Hepatitis1]{\includegraphics[height=2.5cm,keepaspectratio]{example-image-b}}
\subfigure[Hepatitis2]{\includegraphics[height=2.5cm,keepaspectratio]{example-image-b}}
\end{subfigmatrix}
\caption{Baseline accuracy (several classifiers and number of observations.)}
\label{fig:baseline1}
\end{figure}
After:
%\patchcmd{<command>}{<code to replace>}{<code>}{<success>}{<failure>}
\patchcmd{\subfigmatrix}{\hfill}{\hspace{0.8cm}}{}{}
\begin{figure}[!h]
\begin{subfigmatrix}{3}
\subfigure[ALS1]{\includegraphics[height=2.5cm,keepaspectratio]{example-image-a}}
\subfigure[ALS2]{\includegraphics[height=2.5cm,keepaspectratio]{example-image-a}}
\subfigure[ALS1]{\includegraphics[height=2.5cm,keepaspectratio]{example-image-a}}
\subfigure[Hepatitis1]{\includegraphics[height=2.5cm,keepaspectratio]{example-image-b}}
\subfigure[Hepatitis2]{\includegraphics[height=2.5cm,keepaspectratio]{example-image-b}}
\end{subfigmatrix}
\caption{Baseline accuracy (several classifiers and number of observations.)}
\label{fig:baseline2}
\end{figure}
\end{document}
这是一种可能性。将subfigmatrix
环境放入adjustwidth
来自changepage
包的环境中。在 adjustwidth 环境中,可以调整左右边距。环境采用两个必需的长度参数:
\begin{adjustwidth}{hleftmargini}{hrightmargini}
content
\end{adjustwidth}
代码
\documentclass[]{article}
\usepackage[]{graphicx}%,caption}
\usepackage{subfigmat}
\usepackage{changepage}
\begin{document}
Before
\begin{figure}[!h]
\begin{subfigmatrix}{2}
\subfigure[ALS1]{\includegraphics[height=2.5cm,keepaspectratio]{example-image-a}}
\subfigure[ALS2]{\includegraphics[height=2.5cm,keepaspectratio]{example-image-b}}
\subfigure[Hepatitis1]{\includegraphics[height=2.5cm,keepaspectratio]{example-image-b}}
\subfigure[Hepatitis2]{\includegraphics[height=2.5cm,keepaspectratio]{example-image-a}}
\end{subfigmatrix}
\caption{Baseline accuracy (several classifiers and number of observations.)}
\label{fig:baseline}
\end{figure}
After:
\begin{figure}[!h]
\begin{adjustwidth}{2.2cm}{2.2cm}
\begin{subfigmatrix}{2}
\subfigure[ALS1]{\includegraphics[height=2.5cm,keepaspectratio]{example-image-a}}
\subfigure[ALS2]{\includegraphics[height=2.5cm,keepaspectratio]{example-image-b}}
\subfigure[Hepatitis1]{\includegraphics[height=2.5cm,keepaspectratio]{example-image-b}}
\subfigure[Hepatitis2]{\includegraphics[height=2.5cm,keepaspectratio]{example-image-a}}
\end{subfigmatrix}
\caption{Baseline accuracy (several classifiers and number of observations.)}
\label{fig:baseline}
\end{adjustwidth}
\end{figure}
\end{document}