带有小页面的图形 - 如何使其适合文本宽度

带有小页面的图形 - 如何使其适合文本宽度

下面是我的代码,产生以下输出: 在此处输入图片描述

我该怎么做才能使它适应\textwidth

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc} % ensure your document is UTF-8
\usepackage[spanish]{babel}

\usepackage[demo]{graphicx} % demo option just for testing
\usepackage{caption}
\usepackage{subcaption}
\usepackage{float}
\usepackage[showframe]{geometry}

\begin{document}

% Begin minipage figure
\begin{figure}[htb]
    \begin{minipage}[t]{.32\textwidth}
        \centering
        \includegraphics[width=\textwidth]{images/1.png}
        \subcaption{Image 1.}\label{fig:1}
    \end{minipage}
    \hfill
    \begin{minipage}[t]{.32\textwidth}
        \centering
        \includegraphics[width=\textwidth]{images/2.png}
        \subcaption{Image 2.}\label{fig:2}
    \end{minipage}
    \hfill
    \begin{minipage}[t]{.32\textwidth}
        \centering
        \includegraphics[width=\textwidth]{images/rtk3.png}
        \subcaption{Image 3.}\label{fig:3}
    \end{minipage}  
    \hfill
    \label{fig:1-2-3}
    \caption{Title.}
\end{figure}


\begin{minipage}{\textwidth}
      \centering
      \begin{minipage}{0.475\textwidth}
          \begin{figure}[H]
              \includegraphics[width=\linewidth]{france-in-pictures-beautiful-places-to-photograph-eiffel-tower}
              \caption{This is the first figure}
          \end{figure}
      \end{minipage}
      \hfill
      \begin{minipage}{0.475\textwidth}
          \begin{figure}[H]
              \includegraphics[width=\linewidth]{france-in-pictures-beautiful-places-to-photograph-eiffel-tower}
              \caption{This is the second figure}
          \end{figure}
      \end{minipage}
        \hfill
  \end{minipage}

\end{document}

答案1

尝试一下这个代码。

(1)删除\hfill最后一张图后面的;(2)将小页面放在第二行的图环境中,而不是相反;(3)将标签放在第一行的标题后面。

A

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc} % ensure your document is UTF-8
\usepackage[spanish]{babel}

\usepackage[demo]{graphicx} % demo option just for testing
\usepackage{caption}
\usepackage{subcaption}
\usepackage{float}
\usepackage[showframe]{geometry}

\begin{document}
    
    % Begin minipage figure
    \begin{figure}[htb]
        \begin{minipage}[t]{.32\textwidth}
            \centering
            \includegraphics[width=\textwidth]{images/1.png}
            \subcaption{Image 1.}\label{fig:1}
        \end{minipage}
        \hfill
        \begin{minipage}[t]{.32\textwidth}
            \centering
            \includegraphics[width=\textwidth]{images/2.png}
            \subcaption{Image 2.}\label{fig:2}
        \end{minipage}
        \hfill
        \begin{minipage}[t]{.32\textwidth}
            \centering
            \includegraphics[width=\textwidth]{images/rtk3.png}
            \subcaption{Image 3.}\label{fig:3}
        \end{minipage}  
%       \hfill  
\label{fig:1-2-3}%changed
        \caption{Title.} %<<<<<<<<<<<<<<<
    \end{figure}
    
    \begin{figure}[htb]
%   \begin{minipage}{\textwidth}
        \centering
        \begin{minipage}{0.475\textwidth}
%           \begin{figure}[H]
                \includegraphics[width=\linewidth]{france-in-pictures-beautiful-places-to-photograph-eiffel-tower}
                \caption{This is the first figure}
%           \end{figure}
        \end{minipage}
        \hfill
        \begin{minipage}{0.475\textwidth}
%           \begin{figure}[H]
                \includegraphics[width=\linewidth]{france-in-pictures-beautiful-places-to-photograph-eiffel-tower}
                \caption{This is the second figure}
%           \end{figure}
        \end{minipage}
%       \hfill
%   \end{minipage}
    \end{figure}
    
\end{document}

答案2

对于子图像,我将使用subfigure环境(在包中定义),在图像行末尾subcaption删除并删除第二行图形周围的s::hfillminipageminipage

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[spanish]{babel}

\usepackage[demo]{graphicx} % demo option just for testing
\usepackage{caption}
\usepackage{subcaption}
\usepackage[showframe]{geometry}

\begin{document}
    \begin{figure}[htb]
\begin{subfigure}[t]{.32\textwidth}
    \includegraphics[width=\textwidth]{images/1.png}
    \caption{Image 1.}
    \label{fig:1}
\end{subfigure}
    \hfill
\begin{subfigure}[t]{.32\textwidth}
    \includegraphics[width=\textwidth]{images/1.png}
    \caption{Image 2.}
    \label{fig:2}
\end{subfigure}
    \hfill
\begin{subfigure}[t]{.32\textwidth}
    \includegraphics[width=\textwidth]{images/1.png}
    \caption{Image 3.}
    \label{fig:1}
\end{subfigure}
\caption{Title}

\bigskip
\begin{minipage}{0.475\textwidth}
    \includegraphics[width=\linewidth]{france-in-pictures-beautiful-places-to-photograph-eiffel-tower}
    \caption{This is the first figure}
\end{minipage}%
\hfill
\begin{minipage}{0.475\textwidth}
    \includegraphics[width=\linewidth]{france-in-pictures-beautiful-places-to-photograph-eiffel-tower}
    \caption{This is the second figure}
\end{minipage}
    \end{figure}
\end{document}

在此处输入图片描述

答案3

试试这个代码:

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc} % ensure your document is UTF-8
\usepackage[spanish]{babel}

\usepackage[demo]{graphicx} % demo option just for testing
\usepackage{caption}
\usepackage{subcaption}
\usepackage{float}
\usepackage[showframe]{geometry}

\begin{document}

% Begin minipage figure
\begin{figure}[htb]
    \begin{minipage}[t]{.32\textwidth}
        \centering
        \includegraphics[width=\textwidth]{images/1.png}
        \subcaption{Image 1.}\label{fig:1}
    \end{minipage}
    \hfill
    \begin{minipage}[t]{.32\textwidth}
        \centering
        \includegraphics[width=\textwidth]{images/2.png}
        \subcaption{Image 2.}\label{fig:2}
    \end{minipage}
    \hfill
    \begin{minipage}[t]{.32\textwidth}
        \centering
        \includegraphics[width=\textwidth]{images/rtk3.png}
        \subcaption{Image 3.}\label{fig:3}
    \end{minipage}  
    \hfill
    \label{fig:1-2-3}
    \caption{Title.}
\end{figure}


\begin{figure}[h]
      \centering
      \begin{minipage}{0.475\textwidth}
          \begin{figure}[H]
              \includegraphics[width=\linewidth]{france-in-pictures-beautiful-places-to-photograph-eiffel-tower}
              \caption{This is the first figure}
          \end{figure}
      \end{minipage}
      \hfill
      \begin{minipage}{0.475\textwidth}
          \begin{figure}[H]
              \includegraphics[width=\linewidth]{france-in-pictures-beautiful-places-to-photograph-eiffel-tower}
              \caption{This is the second figure}
          \end{figure}
      \end{minipage}
        \hfill
  \end{figure}

\end{document}

在此处输入图片描述

相关内容