我有一个由 4 张 svg 图像组成的网格,我想将它们强制放入网格中。我的问题是,当我将它们放入 LaTex 中时,网格对齐略有偏差。
我努力了:
- 移动
\hfill
到不同的位置, - 导入带有设置参数的 SVG 并
- 按照建议使用顶部对齐这里。
但这两种方法对我来说都不起作用。我的输出如下所示:
\begin{figure}[htb]
\centering
\begin{subfigure}[hbt!]{0.45\textwidth}
\includesvg[width=7cm,height=5.1cm]{images/image1a}
\caption{svg 1}
\label{fig:image1a}
\end{subfigure}\hfill%
\begin{subfigure}[hbt!]{0.45\textwidth}
\includesvg[width=7cm,height=5.1cm]{images/image1b}
\caption{svg 2}
\label{fig:image1b}
\end{subfigure}\hfill%
\begin{subfigure}[hbt]{0.45\textwidth}
\includesvg[width=7cm,height=5.1cm]{images/image1c}
\caption{svg 3}
\label{fig:image1c}
\end{subfigure}
\begin{subfigure}[hbt]{0.45\textwidth}
\includesvg[width=7cm,height=5.1cm]{images/image1d}
\caption{svg 4}
\label{fig:image1d}
\end{subfigure}
%\hfill
\caption{Image1}
\end{figure}
最小工作示例
\documentclass[12pt,oneside,openany,a4paper,afrikaans,english,masters-t,goldenblock]{usthesis}
%% Language and font encodings
\usepackage[afrikaans, english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz}
%%%%%%%%%%%%%%%%%%%%%%% Packages %%%%%%%%%%%%%%%%%%%%%%%
\usepackage{graphicx}
\usepackage{svg} % To be able to add SVG images
\usepackage{usbib}
\bibliographystyle{unsrt}
\setcitestyle{square}
\bibpunct{[}{]}{,}{n}{,}{,}
\usepackage{caption}
\usepackage{subcaption}
%%%%%%%%%%%%%%%%%%%%%%% Sets page size and margins %%%%%%%%%%%%%%%%%%%%%%%
\usepackage{geometry}
\geometry{a4paper, total={210.2mm,297.3mm}, left=25mm, right = 25mm, top=26.3mm, bottom=43.8mm }
\begin{document}
%%%%%%%%%%%%%% Error here %%%%%%
% Insert the 4 figures here in even grid (error in equal spacing)
\begin{figure}[htb]
\centering
\begin{subfigure}[hbt!]{0.45\textwidth}
\includesvg[width=7cm,height=5.1cm]{images/image1a}
\caption{svg 1}
\label{fig:image1a}
\end{subfigure}\hfill% % <-- \hfill is new
\begin{subfigure}[hbt!]{0.45\textwidth}
\includesvg[width=7cm,height=5.1cm]{images/image1b}
\caption{svg 2}
\label{fig:image1b}
\end{subfigure}\hfill% % <-- \hfill is new
\begin{subfigure}[hbt]{0.45\textwidth}
\includesvg[width=7cm,height=5.1cm]{images/image1c}
\caption{svg 3}
\label{fig:image1c}
\end{subfigure}
\begin{subfigure}[hbt]{0.45\textwidth}
\includesvg[width=7cm,height=5.1cm]{images/image1d}
\caption{svg 4}
\label{fig:image1d}
\end{subfigure}
%\hfill
\caption{Image1}
\end{figure}
In text reference: Fig.~\ref{fig:image1a}.
\bibliography{sample} % no need for bibliography
\end{document}
答案1
像这样吗?
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{subcaption}
\begin{document}
\begin{figure}
\begin{subfigure}{0.45\textwidth}
\includegraphics{example-image-a}
\caption{svg 1}
\label{fig:image1a}
\end{subfigure}%
\hfill
\begin{subfigure}{0.45\textwidth}
\includegraphics{example-image-a}
\caption{svg 2}
\label{fig:image1b}
\end{subfigure}
\begin{subfigure}{0.45\textwidth}
\includegraphics{example-image-a}
\caption{svg 3}
\label{fig:image1c}
\end{subfigure}%
\hfill
\begin{subfigure}{0.45\textwidth}
\includegraphics{example-image-a}
\caption{svg 4}
\label{fig:image1d}
\end{subfigure}
\caption{...}
\end{figure}
\end{document}