0

I defined a new command and want it to make sure that the following text or environment starts in a new line with some vertical space like the following:

\newcommand{\example}[1]{Somecommand\\*[1ex]}

This works perfectly fine for usual text, but when using environments that come with their own spacing (like itemize), the vertical space is too much.

So what I would like to see is that the 1ex-space is only added when there is no additional space defined for the following environment.

So basically I would like it to work like a section and it would be ideal to have the same amount of space regardless of the following environment.

Just not adding the additional space would be fine though.

Klumbe
  • 131
  • 1
    never end a paragraph with \\ that will produce underfull box warnings and very poor output use \par\addvspace{1ex} which will add the maximum of 1ex and the space added before the following environment – David Carlisle Sep 27 '21 at 13:08
  • Thanks David, actually using only \par is already doing exactly what I wanted to achieve here. Actually, I was always using \\ everywhere. Do you have any good source where the usage is explained? Do you just use it in math or tabular environments? You are right, the Underfull \hbox-errors go away, but I still got the Overfull \hbox ones. – Klumbe Sep 27 '21 at 15:17
  • https://tex.stackexchange.com/questions/82664/when-to-use-par-and-when-newline-or-blank-lines/82666#82666 and https://tex.stackexchange.com/a/334249/1090 – David Carlisle Sep 27 '21 at 15:20
  • Thx, as far as I can understand, it is ok to use it for simple line-breaks as long as I don't want to end a paragraph (or insert an empty line), right? – Klumbe Sep 27 '21 at 16:18
  • yes \\ is essentially a shorthand for \newline but the number of times that you want a forced line break in text is basically almost never. In the last 30 years of tex use I must have needed to use this somewhere once or twice but I can't actually recall needing that. – David Carlisle Sep 27 '21 at 16:21
  • I use it a lot, but it might be due to the lack of latex-expertise. – Klumbe Sep 27 '21 at 17:03

0 Answers0