是否可以在本地定義“figure”和“table”環境(“\intextsep”)上方和下方的空間?

是否可以在本地定義“figure”和“table”環境(“\intextsep”)上方和下方的空間?

在確定瞭如何在captions全局和局部定義上方和下方的垂直空間後,我想知道是否有一種方法也可以\intextsep在局部定義。另外,floating透過使用Hpackage 提供的參數禁用float,我認為這\textfloatsep不是問題。

\documentclass{article}
\usepackage[demo]{graphicx} 
\setlength{\intextsep}{50.0pt plus 2.0pt minus 2.0pt}
\usepackage[font=small,skip=10pt]{caption}
\usepackage{float}

\begin{document}

Some text...

\begin{figure}[H]
\captionsetup{font=Large,skip=5pt}
\begin{center}
\includegraphics[height=1in,width=1in,angle=-90]{foo}
\caption{This is a figure.}
\end{center}
\end{figure}

... more text...

\begin{figure}[H]
\captionsetup{font=tiny,skip=15pt}
\begin{center}
\includegraphics[height=1in,width=1in,angle=-90]{foo}
\caption{This is another figure.}
\end{center}
\end{figure}

... still more text...
\newpage
Text...

\begin{table}[H]
\captionsetup{font=small,skip=10pt}
\centering
\caption{This is a table.}
\begin{tabular}{|c|c|}
\hline
    % after \\: \hline or \cline{col1-col2} \cline{col3-col4} ...
    1 & 2 \\
    4 & 7 \\
    \hline
\end{tabular}
\end{table}

... end of text.

\end{document}

答案1

您可以在內部定義它\begingroup\endgroup使用命令參見下文並檢查已設定為 20pt 的第一個距離:

編輯:正如@daleif 在問題中評論的那樣\begin{centrer}\end{center} 添加額外的空間是不需要的,並且增加了實際空間。因此,我替換為,\centering以便為未來的訪客提供更好的程式碼。

\documentclass{article}
\usepackage[demo]{graphicx} 
\setlength{\intextsep}{50.0pt plus 2.0pt minus 2.0pt}
\usepackage[font=small,skip=10pt]{caption}
\usepackage{float}

\begin{document}

Some text...

\begingroup
\setlength{\intextsep}{20.0pt plus 2.0pt minus 2.0pt}
\begin{figure}[H]
\captionsetup{font={Large},skip=5pt}
\centering
\includegraphics[height=1in,width=1in,angle=-90]{foo}
\caption{This is a figure.}
\end{figure}

... more text...
\endgroup

\begin{figure}[H]
\captionsetup{font={normalsize},skip=15pt}
\centering
\includegraphics[height=1in,width=1in,angle=-90]{foo}
\caption{This is another figure.}
\end{figure}

... still more text...
\newpage
Text...

\begin{table}[H]
\captionsetup{font=small,skip=10pt}
\centering
\caption{This is a table.}
\begin{tabular}{|c|c|}
\hline
    % after \\: \hline or \cline{col1-col2} \cline{col3-col4} ...
    1 & 2 \\
    4 & 7 \\
    \hline
\end{tabular}
\end{table}

... end of text.

\end{document}

相關內容