Latex 可包装内容前导空格过多

Latex 可包装内容前导空格过多

我在使用 wrapfig 包时遇到了问题。正如您在下面的示例中看到的,前导空格导致表格延伸到下一个子部分(如果没有前导空格,表格会溢出,但无论如何)。我该如何避免这种情况?

感谢您的帮助!

梅威瑟:

\documentclass{article}
\usepackage{wrapfig,booktabs}
\begin{document}
The input that has to be provided to compute the time the passenger needs to reach his luggage consists of $n + 3$ lines. The first line describes $n$; is this number equal to zero, the input is finished. The following $n$ lines describe the coordinates of the single corners with the form $x\;y$. Afterwards, the coordinates of the passengers are described in the same format as well as the speed of the luggage and the passenger respectively. For this line, the input's format is $l\;p$ where $l$ represents the luggage's speed and $p$ the passenger's one. A possible input sequence is shown in Table \ref{tabular:inputSequence}.
\begin{wraptable}{r}{0pt}
\begin{tabular}{c|l}
\toprule
4 & Scenario I -- 4 corners \\
0 0 & first corner \\
0 10 & second corner \\
10 10 & third corner \\
10 0 & fourth corner \\
20 30 & passenger's coordinate \\
10 15 & speeds \\
0 & end of input sequence \\
\bottomrule
\end{tabular}
\caption{A possible input sequence}\label{tabular:inputSequence}
\end{wraptable}
\end{document}

答案1

在此处输入图片描述

\documentclass{article}
\usepackage{wrapfig,booktabs}
\begin{document}
\section{Input}

The input that has to be provided to compute the time the passenger needs to reach his luggage consists of $n + 3$ lines. The first line describes $n$; is this number equal to zero, the input is finished. The following $n$ lines describe the coordinates of the single corners with the form $x\;y$. Afterwards, the coordinates of the passengers are described in the same format as well as the speed of the luggage and the passenger respectively. For this line, the input's format is $l\;p$ where $l$ represents the luggage's speed and $p$ the passenger's one. A possible input sequence is shown in Table \ref{tabular:inputSequence}.

% save original \intextsep
\newlength{\oldintextsep}
\setlength{\oldintextsep}{\intextsep}

\setlength\intextsep{0pt}
\begin{wraptable}{r}{0pt}
\begin{tabular}{c|l}
\toprule
4 & Scenario I -- 4 corners \\
0 0 & first corner \\
0 10 & second corner \\
10 10 & third corner \\
10 0 & fourth corner \\
20 30 & passenger's coordinate \\
10 15 & speeds \\
0 & end of input sequence \\
\bottomrule
\end{tabular}
\caption{A possible input sequence}\label{tabular:inputSequence}
\end{wraptable}

The input that has to be provided to compute the time the passenger needs to reach his luggage consists of $n + 3$ lines. The first line describes $n$; is this number equal to zero, the input is finished. The following $n$ lines describe the coordinates of the single corners with the form $x\;y$. Afterwards, the coordinates of the passengers are described in the same format as well as the speed of the luggage and the passenger respectively. For this line, the input's format is $l\;p$ where $l$ represents the luggage's speed and $p$ the passenger's one. A possible input sequence is shown in Table \ref{tabular:inputSequence}.

\section{Output}
The input that has to be provided to compute the time the passenger needs to reach his luggage consists of $n + 3$ lines. The first line describes $n$; is this number equal to zero, the input is finished. The following $n$ lines describe the coordinates of the single corners with the form $x\;y$. Afterwards, the coordinates of the passengers are described in the same format as well as the speed of the luggage and the passenger respectively. For this line, the input's format is $l\;p$ where $l$ represents the luggage's speed and $p$ the passenger's one. A possible input sequence is shown in Table \ref{tabular:inputSequence}.
\end{document}

正如@UlrikeFischer 在回答类似问题,每个 wrapfig 前都会\intextsep插入一个空格。在页面开头看不到这种空格,因为页面开头的垂直空格会消失。\intextsep由 latex 格式声明/定义,用于在文本中插入带有“h”的浮点数。因此,如果您将其全局设置为 0pt,也会影响此类浮点数。

此处的解决方法是先保存当前的,然后在 之前\intextsep将其设置为新值。同样,在浮动之前,恢复原始值。0ptwrapfig\setlength{\intextsep}{\oldintextsep}

% save original \intextsep
\newlength{\oldintextsep}
\setlength{\oldintextsep}{\intextsep}

\setlength\intextsep{0pt}

相关内容