我正在尝试制作一些自动生成的 LaTeX 文档,我想知道如何将子图(带有标题、、等)拆分到a
多页上b
c
自动地。这是我的代码,我唯一想改进的地方是显示图形标题(此处Title
),但只显示每页的最后一行,而不是每行之后。我该怎么做?
\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}
\usepackage{float}
\begin{document}
\centering
\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}
\end{figure}
\begin{figure}[H]\ContinuedFloat
\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}
\end{figure}
\begin{figure}[H]\ContinuedFloat
\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}
\end{figure}
\begin{figure}[H]\ContinuedFloat
\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}
\end{figure}
\end{document}
答案1
我不确定它是否对你有帮助,它不是自动的,但比你的变体更好:
\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}
\usepackage{float}
\newcommand{\treeimg}[7]{%
\begin{figure}[htb]
\begin{subfigure}[t]{.32\textwidth}
\includegraphics[width=\textwidth]{images/#1}
\caption{#2}
\label{fig:1}
\end{subfigure}
\hfill
\begin{subfigure}[t]{.32\textwidth}
\includegraphics[width=\textwidth]{images/#3}
\caption{#4}
\label{fig:2}
\end{subfigure}
\hfill
\begin{subfigure}[t]{.32\textwidth}
\includegraphics[width=\textwidth]{images/#5}
\caption{#6}
\label{fig:1}
\end{subfigure}
\caption{#7}
\end{figure}}
\begin{document}
\treeimg{1.jpg}{captionof1.jpg}{1.jpg}{captionof2.jpg}{1.jpg}{captionof3.jpg}{caption}
\treeimg{1.jpg}{captionof1.jpg}{1.jpg}{captionof2.jpg}{1.jpg}{captionof3.jpg}{caption}
\treeimg{1.jpg}{captionof1.jpg}{1.jpg}{captionof2.jpg}{1.jpg}{captionof3.jpg}{caption}
\treeimg{1.jpg}{captionof1.jpg}{1.jpg}{captionof2.jpg}{1.jpg}{captionof3.jpg}{caption}
\end{document}
答案2
最好的办法是将第一个浮点数设为 [bp],其余设为 [tbp!]。这将填满\bottomfraction
第一页,甚至可能填满第二页的全部内容。
\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[showframe]{geometry}
%\usepackage{float}% friends don't let frineds use [H]
\let\bottomfraction=\topfraction
\let\floatpagefraction=\topfraction
\usepackage{lipsum}
\begin{document}
\begin{figure}[bp]
\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}
\end{figure}
\begin{figure}[tbp!]\ContinuedFloat
\begin{subfigure}[t]{.32\textwidth}
\includegraphics[width=\textwidth]{images/1.png}
\caption{Image 1.}
\label{fig:4}
\end{subfigure}
\hfill
\begin{subfigure}[t]{.32\textwidth}
\includegraphics[width=\textwidth]{images/1.png}
\caption{Image 2.}
\label{fig:5}
\end{subfigure}
\hfill
\begin{subfigure}[t]{.32\textwidth}
\includegraphics[width=\textwidth]{images/1.png}
\caption{Image 3.}
\label{fig:6}
\end{subfigure}
\caption{Title}
\end{figure}
\begin{figure}[tbp!]\ContinuedFloat
\begin{subfigure}[t]{.32\textwidth}
\includegraphics[width=\textwidth]{images/1.png}
\caption{Image 1.}
\label{fig:7}
\end{subfigure}
\hfill
\begin{subfigure}[t]{.32\textwidth}
\includegraphics[width=\textwidth]{images/1.png}
\caption{Image 2.}
\label{fig:8}
\end{subfigure}
\hfill
\begin{subfigure}[t]{.32\textwidth}
\includegraphics[width=\textwidth]{images/1.png}
\caption{Image 3.}
\label{fig:9}
\end{subfigure}
\caption{Title}
\end{figure}
\begin{figure}[tp!]\ContinuedFloat
\begin{subfigure}[t]{.32\textwidth}
\includegraphics[width=\textwidth]{images/1.png}
\caption{Image 1.}
\label{fig:10}
\end{subfigure}
\hfill
\begin{subfigure}[t]{.32\textwidth}
\includegraphics[width=\textwidth]{images/1.png}
\caption{Image 2.}
\label{fig:11}
\end{subfigure}
\hfill
\begin{subfigure}[t]{.32\textwidth}
\includegraphics[width=\textwidth]{images/1.png}
\caption{Image 3.}
\label{fig:12}
\end{subfigure}
\caption{Title}
\end{figure}
\lipsum[1-6]
\end{document}