強制乳膠將圖形和表格放在同一頁中

強制乳膠將圖形和表格放在同一頁中

我嘗試過使用浮動屬性和靜態對齊來強制乳膠將圖形和表格放在一起,但沒有成功。另外,當我\noindent\begin{minipage}{\linewidth}\captionof包一起使用時,它們會放在一起,但是,迷你中斷會導致上一頁在中間被剪切。有人對我有建議嗎?實際上這些圖和表必須佔據整頁。

%\noindent\begin{minipage}{\linewidth}
%\centering
%\resizebox{13.4cm}{!}{\includegraphics{figures}}
%\captionof{figure}{figure i would like to be on top}
%\label{fig:BN_breakdown}
%%\end{figure}




%%\begin{table}[]
%\small
%\centering
%\captionof{table}{Table I would like to be bottom of the figure}
%\label{table}
%\centering
%\begin{tabular}{| l | l  | p{7cm}|c|}
%\hline 
%\textbf{}  & \textbf{Category} & \textbf{Description} & \textbf{Time\%}  \\  
%\hline    
%\\ \hline
%\end{tabular}
%\end{minipage} 

答案1

你可以載入後頁將圖形/表格材料打包並封裝在一條\afterpage{...}語句中:指令參數的排版\afterpage被推遲到下一頁的開始。

\documentclass{article}
\usepackage[demo]{graphicx} % remove 'demo' option in real document
\usepackage{caption,afterpage,tabularx}
\usepackage{lipsum} % for filler text

\begin{document}
\lipsum[1-3] % filler text

\afterpage{% % defer placement until start of next page
\noindent
\begin{minipage}{\textwidth}
\centering

\includegraphics[width=0.9\textwidth]{figures} % choose width of graph
\captionof{figure}{Figure above table}
\label{fig:BN_breakdown}

\vspace{2cm} % choose the vertical separation between figure and table

\small
\captionof{table}{Table below figure}
\label{table}
\begin{tabularx}{0.9\textwidth}{| l | l | X | c |} % choose width of `tabularx`
\hline 
\textbf{} & \textbf{Category} & \textbf{Description} & \textbf{Time \%}  \\  
\hline    
 & & & \\ \hline
\end{tabularx}
\end{minipage}
\clearpage  % if needed/desired
}% end of argument of \afterpage

\lipsum[4-9] % more filler text
\end{document}

答案2

您可以將圖片和表格放在一個環境中(例如\begin{table}),並使用\captionof命令新增相應的標題。既然您說圖形和表格應該佔據一頁,只需添加[p]說明符作為表格的可選參數。

微量元素:

\documentclass{article}
\usepackage{caption}

\usepackage{lipsum} % for dummy text
\usepackage{tikz} % for dummy picture

\begin{document}

\lipsum[1] % dummy text

\begin{table}[p]
    \centering

    \begin{tikzpicture} % dummy picture
        \fill circle (3cm);
    \end{tikzpicture}

    \captionof{figure}{\protect\lipsum[2]} % dummy caption

    \hspace{\parskip}

    \captionof{table}{\protect\lipsum[2]} % dummy caption

    \begin{tabular}{| l | l | p{7cm} | c |} % dummy table
        \hline
        \textbf{} & \textbf{Category} & \textbf{Description} & \textbf{Time\%} \\ \hline 
        \textbf{} & 00000 & 11111 & 22222 \\ 
        \textbf{} & 00000 & 11111 & 22222 \\ 
        \textbf{} & 00000 & 11111 & 22222 \\  \hline            
    \end{tabular}
\end{table}

\lipsum[1-5] % dummy text

\end{document}

相關內容