图表周围注释符号的用途

图表周围注释符号的用途

在许多 Latex 文档中,我看到人们这样做:

This is an example paragraph... blah...blah...
%
\begin{figure}
    ...
\end{figure}
%
and then blah...blah...

%我很困惑,之前和之后的用途是什么figure

有什么区别

This is an example paragraph... blah...blah...
\begin{figure}
    ...
\end{figure}
and then blah...blah...

答案1

注释表明这些空行会被 LaTeX 忽略,因此“然后...”不会放到不同的段落中。

看到不同:

% CODE 1
\documentclass{article}
\usepackage{graphicx}
\begin{document}
This is an example paragraph... blah...blah... is an example paragraph... blah...blah...
is an example paragraph... blah...blah... is an example paragraph... blah...blah...
is an example paragraph... blah...blah... is an example paragraph... blah...blah...

\begin{figure}
  \includegraphics{example-image-duck}
\end{figure}

and is an example paragraph... blah...blah... is an example paragraph... blah...blah...
is an example paragraph... blah...blah... is an example paragraph... blah...blah...
is an example paragraph... blah...blah... is an example paragraph... blah...blah...
\end{document}

在此处输入图片描述

% CODE 2
\documentclass{article}
\usepackage{graphicx}
\begin{document}
This is an example paragraph... blah...blah... is an example paragraph... blah...blah...
is an example paragraph... blah...blah... is an example paragraph... blah...blah...
is an example paragraph... blah...blah... is an example paragraph... blah...blah...
%
\begin{figure}
  \includegraphics{example-image-duck}
\end{figure}
%
and is an example paragraph... blah...blah... is an example paragraph... blah...blah...
is an example paragraph... blah...blah... is an example paragraph... blah...blah...
is an example paragraph... blah...blah... is an example paragraph... blah...blah...
\end{document}

在此处输入图片描述

你也可以删除空行以避免段落中断。下面的代码和 CODE 2 被同等对待latex,但忽略空行使代码更具可读性。

% CODE 3
\documentclass{article}
\usepackage{graphicx}
\begin{document}
This is an example paragraph... blah...blah... is an example paragraph... blah...blah...
is an example paragraph... blah...blah... is an example paragraph... blah...blah...
is an example paragraph... blah...blah... is an example paragraph... blah...blah...
\begin{figure}
  \includegraphics{example-image-duck}
\end{figure}
and is an example paragraph... blah...blah... is an example paragraph... blah...blah...
is an example paragraph... blah...blah... is an example paragraph... blah...blah...
is an example paragraph... blah...blah... is an example paragraph... blah...blah...
\end{document}

答案2

环境的唯一目的figure是将其内容从主文档流中取出,以便稍后插入,如果您需要段落中间的图像,可以\includegraphcs直接在文本中使用。所以你可以问这个问题,而figure根本不需要那里。

以下显示了该句子的四种可能的标记样式

# 这是一个示例段落...等等等等...然后等等等等...

在此处输入图片描述

\documentclass{article}

\begin{document}


1 This is an example paragraph... blah...blah... and then blah...blah...

2 This is an example paragraph... blah...blah...
and then blah...blah...

3 This is an example paragraph... blah...blah...
%
%
and then blah...blah...

4 This is an example paragraph... blah...blah...
%
{}
%
and then blah...blah...


\end{document}

请注意,前三个是等效的,因为注释会被忽略,并且行尾会被视为空格。第四个通常是标记错误,因为它在 之前引入了双字空格and

您可以使用figure任何这些样式将环境插入到句子中,您展示的样式本质上等同于 4,不同之处在于{}figure如果环境前后都有空格,则环境会采取特别预防措施并删除前面的空格。

我认为 1 是句子中最自然的标记,因此在(有点罕见的)需要在句子中间指定图形标注的情况下,我会使用

This is an example paragraph... blah...blah...\begin{figure}
    ...
\end{figure} and then blah...blah...

这突显了其句中性质。

通常,当您可以在环境标记周围使用空行时,在段落之间指定图形会更清晰figure

相关内容