段落の末尾に \vspace を配置するのは、LaTeX コーディングとして適切ではないでしょうか?

段落の末尾に \vspace を配置するのは、LaTeX コーディングとして適切ではないでしょうか?

コメントの後デイビッド・カーライル質問使用方法について、段落間のスペースを追加または削除するために\vspace、次のようなコマンドを段落の最後のコマンドとして追加することを避けるべきかどうか、いつ避けるべきか、そしてなぜ避けるべきかを調べよ\vspaceうとしました。

This is the text of a paragraph here.\vspace{1cm}

This is the text of the next paragraph.

@DavidCarlisle は私のコメントで次のように答えました:

「空白行は vspace の前に置く必要があります。水平モードで vspace を使用することは明確に定義されていますが、奇妙なので、ほとんどの場合、これを避ける必要があります。」

したがって、提案されている「修正」は(私が理解している限りでは)次のとおりです。

This is the text of a paragraph here.

\vspace{1cm}This is the text of the next paragraph.

しかし、私は多くの例を試しましたが、予想外の出力 (垂直間隔の順序、一般的な順序) が得られる例を見つけることができませんでした。また、最初の LaTeX の手順では、次のスタイルを使用していました。

This is the text of a paragraph here.

\vspace{1cm}

This is the text of the next paragraph.

これは今ではひどいように思えますが、最初の例(現在使用しているスタイル)よりも優れた LaTeX コーディングと見なすことができます。

そこで私の質問は次のとおりです。

  1. 何らかの理由で最初の例のコーディングスタイルを避けるべきでしょうか?
  2. 私のスタイルが期待される間隔で失敗する例はありますか? (またはこれは単にコード スタイルに関するものです)

MWE:

\documentclass{article}
\usepackage{parskip}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{positioning}
\setlength{\parskip}{1cm plus 0cm minus 0cm}
\setlength{\parindent}{0pt}

\newcommand{\expectedVSkip}[2][2.2cm]{\begin{tikzpicture}[overlay,remember picture,baseline=0pt]\node[use as bounding box,inner sep=0,outer sep=0] at (0,0) (A){\vphantom{\texttt{p}}};\draw[->,blue] (A.south)--node[midway,right]{$#2$}($(A.south)+(0,-{#2})$);\draw[->,thin,blue] ($(A.south)+(-{#1},0)$)--($(A.south)+(0,0)$);\draw[->,thin,blue] ($(A.south)+(-{#1},-{#2})$)--($(A.south)+(0,-{#2})$);\end{tikzpicture}}

\begin{document}

This is the first paragraph that will have a space of the \verb|\parskip|$=1\;cm$ length from the following command since no \verb|\vspace|\expectedVSkip{1cm} command is added here.

This is the second paragraph that will have a space of $0.5\;cm$ from the folowing paragraph since a \verb|\vspace{-0.5cm}|\expectedVSkip{0.5cm} command is added just in its end.\vspace{-0.5cm}

This\vspace{2cm} is the third paragraph with a \verb|\vspace{2cm}|\expectedVSkip{2cm} command before the end of its first line. The paragpaph have enough text following, in order to let us discover if the \verb|\vspace| will act from the point of the first linebreak or from the end of this paragraph (Since the command is placed in its first line, the command is supposed to act just at the place that \LaTeX{} will deside to break the line and the paragraph will be an ugly broken paragraph with a strange added vertical space of exactly $2\;cm$). After this paragraph the following paragraph will be in distance of 2cm since an additional (just one) $cm$ have been added through a \verb|\vspace{1cm}|\expectedVSkip{2cm} to the \verb|\parskip|.\vspace{1cm}

This is just the fourth paragraph.


\end{document}

MWEの出力:

ここに画像の説明を入力してください

答え1

段落の末尾で使用すると、\vspace次の垂直リストで使用した場合と同じ視覚的な結果が得られますが、コード パスは大きく異なり、より複雑になります。vmode で vspace を使用すると、現在の垂直リストにグルー ノードが直接追加されます。h モードで使用すると、垂直グルーは現在の水平リストの vadjust ノードに追加され、改行後に現在の垂直リストに移行し、vadjust ノードが含まれていた行の後の垂直リストに再挿入されます。

ほとんどの場合、先頭に\vspace空白行または を置く必要があります\par

実際には、ドキュメント内に明示的な垂直スペース コマンドが存在することはほとんどないため、この違いは問題になりません。存在する場合は通常、クラスによって設定されたグローバル間隔が現在のドキュメントに適していないことを示しているため、個々の段落で間隔を調整するよりも、ソースで修正する方が適切です。

関連情報