¿Un \vspace colocado al final de un párrafo es una mala codificación LaTeX?

¿Un \vspace colocado al final de un párrafo es una mala codificación LaTeX?

Después de un comentario de@DavidCarlisleen unpreguntasobre \vspaceel uso, intenté averiguar si, cuándo y por qué \vspacese debe evitar agregar un comando como último comando de un párrafo para agregar o eliminar espacios entre párrafos, como:

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

This is the text of the next paragraph.

@DavidCarlisle respondió en un comentario mío que:

"La línea en blanco debe estar antes del vspace. Usar vspace en modo horizontal está bien definido pero es extraño, casi siempre es conveniente evitarlo".

Entonces, la "corrección" propuesta (hasta donde puedo entender) es:

This is the text of a paragraph here.

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

Pero probé muchos ejemplos y no encontré uno que diera un resultado inesperado (en orden de espaciado vertical, pero también en general). Además, en mis primeros pasos con LaTeX estaba usando este estilo:

This is the text of a paragraph here.

\vspace{1cm}

This is the text of the next paragraph.

Eso ahora me parece horrible, pero podría considerarse una mejor codificación LaTeX de mi primer ejemplo (el estilo que estoy usando actualmente).

Entonces, mi pregunta es:

  1. ¿Debo evitar el estilo de codificación del primer ejemplo por alguna razón?
  2. ¿Hay algún ejemplo de que mi estilo fallará en el espaciado esperado? (o esto es sólo sobre el estilo del código)

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}

y salida de MWE:

ingrese la descripción de la imagen aquí

Respuesta1

si lo usa \vspaceal final de un párrafo, probablemente dé el mismo resultado visual que usarlo en la siguiente lista vertical, pero a través de una ruta de código tremendamente diferente y más complicada. Si usa vspace en vmode, simplemente agrega directamente el nodo de pegamento a la lista vertical actual. Si lo usa en modo h, entonces el pegamento vertical se agrega a un nodo vadjust en la lista horizontal actual que, después del salto de línea, migrará a la lista vertical actual y se volverá a insertar en la lista vertical después de la línea que contenía el vadjust. nodo.

Casi siempre debes anteponerlo \vspacea una línea en blanco o \par.

En la práctica, la diferencia no debería ser un problema ya que casi nunca debería haber comandos explícitos de espacio vertical dentro del documento. Si lo hay, suele ser una señal de que el espaciado global establecido por la clase no es adecuado para el documento actual y es mejor arreglarlo en el origen en lugar de ajustar el espaciado en cada párrafo individual.

información relacionada