如何将三张图片均匀分布在一行中

如何将三张图片均匀分布在一行中

我有 3 张图片排成一行,但我希望它们均匀分布,目前,它们似乎挤在一起,在最右侧留出空间。我是 LaTeX 新手,所以请耐心等待!我猜想这与此有关,{.3\textwidth}但当我摆弄它时,它会改变它们的大小并将它们放在新的行上。

\begin{figure}[ht]
\begin{subfigure}{.3\textwidth}
  \centering
  % include first image
  \includegraphics[angle=270, width=1\linewidth]{Trisecting an angle 1}  
  \caption{Put your sub-caption here}
  \label{fig:sub-first}
\end{subfigure}
\begin{subfigure}{.3\textwidth}
  \centering
  % include second image
  \includegraphics[angle=270, width=1\linewidth]{Trisecting an angle 2}  
  \caption{Put your sub-caption here}
  \label{fig:sub-second}
\end{subfigure}
\begin{subfigure}{.3\textwidth}
  \centering
  % include third image
  \includegraphics[angle=270, width=1\linewidth]{Trisecting an angle 3}  
  \caption{Put your sub-caption here}
  \label{fig:sub-second}
\end{subfigure}
\caption{Put your caption here}
\label{fig:fig}
\end{figure}

答案1

下图中,图像被用˙|hfill`命令推开:

\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}
    \begin{figure}[ht] 
\begin{subfigure}{.3\textwidth} 
\centering 
% include first image 
\includegraphics[angle=270, width=1\linewidth]{example-image-a}%{Trisecting an angle 1}   
\caption{Put your sub-caption here} 
\label{fig:sub-first} 
\end{subfigure}\hfill% <---
\begin{subfigure}{.3\textwidth} 
\centering 
% include second image 
\includegraphics[angle=270, width=1\linewidth]{example-image-b}%{Trisecting an angle 2}   
\caption{Put your sub-caption here} \label{fig:sub-second} 
\end{subfigure}\hfill% <--- 
\begin{subfigure}{.3\textwidth} 
\centering 
% include third image 
\includegraphics[angle=270, width=1\linewidth]{example-image-c}%{Trisecting an angle 3}   \caption{Put your sub-caption here} \label{fig:sub-second} 
\end{subfigure} 
\caption{Put your caption here} 
\label{fig:fig} 
    \end{figure}
\end{document}

在此处输入图片描述

(红线表示文本边框)

相关内容