
我不明白為什麼標題中有額外的字間距。可能是因為子圖?謝謝你的幫忙。
\begin{figure}[H]
\centering
\begin{subfigure}[h]{.45\textwidth}
\centering
\includegraphics[width=\textwidth]{beest}
\caption{ Strandbeest Janson, Theo; hacknmod.com/wp-content/uploads/2013/07/theo-jansen-strandbeest.jpg}
\label{beest}
\end{subfigure}
\hfill
\begin{subfigure}[h]{.45\textwidth}
\centering
\includegraphics[width=\textwidth]{umbrella}
\caption{Sample umbrella mechanism; wiki.ece.cmu.edu/ddl/images/thumb/Umbrella-wikiFrontpage.jpg/500px-Umbrella-wikiFrontpage.jpg}
\label{umbrella}
\end{subfigure}
\caption{}
\label{}
\end{figure}
答案1
您需要將標題材料的對齊方式從對齊更改為不規則右對齊。由於您已經載入了subcaption
包,因此只需發出指令
\captionsetup[subfigure]{justification=raggedright}
如果您希望此說明適用於整個文檔,請將該說明放在序言中;\begin{figure}
如果它僅適用於手頭上的兩個子圖,請將此說明放在序言之後。
另外,我建議您也載入該url
套件(使用選項hyphens
)並將 URL 字串包含在\url
指令的標題中。這樣做將允許 LaTeX 在長 URL 字串中找到額外的換行可能性。
小一點:所有三個\centering
指令都可以省略,因為它們適用於佔用全部可用對應寬度的實體
\documentclass{article}
\usepackage[demo]{graphicx} % omit 'demo' version in real document
\usepackage{subcaption}
\usepackage[hyphens]{url}
\begin{document}
\begin{figure}
\captionsetup[subfigure]{justification=raggedright}
\urlstyle{same}
%%%\centering
\begin{subfigure}[t]{.45\textwidth}
%%%\centering
\includegraphics[width=\linewidth]{beest}
\caption{ Strandbeest Janson, Theo; \url{hacknmod.com/wp-content/uploads/2013/07/theo-jansen-strandbeest.jpg}}
\label{beest}
\end{subfigure}
\hfill
\begin{subfigure}[t]{.45\textwidth}
%%%\centering
\includegraphics[width=\linewidth]{umbrella}
\caption{Sample umbrella mechanism; \url{wiki.ece.cmu.edu/ddl/images/thumb/Umbrella-wikiFrontpage.jpg/500px-Umbrella-wikiFrontpage.jpg}}
\label{umbrella}
\end{subfigure}
\caption{}
\label{}
\end{figure}
\end{document}