My custom enumerateoptional enumitem environment is putting a useless empty line in the middle of my enumeration list.
To reproduce this, you need to fill a line 100%. See this example I extracted from my full document, reproducing the problem:
\documentclass[12pt]{article}
\errorcontextlines 10000
\usepackage[shortlabels]{enumitem}
\def\renewenumerateoptionalitem{%
\let\itemenumerateoptional\item%
\renewcommand{\item}[1][]{%
\refstepcounter{enumerateoptionali}% increment the counter
\itemenumerateoptional[\bfseries##1~\theenumerateoptionali]%
}%
}
\newlist{enumerateoptional}{enumerate}{1}
\setlist[enumerateoptional]{
before=\renewenumerateoptionalitem,
label=\arabic*,
nosep,
align=left,
leftmargin=*,
after=\let\item\itemenumerateoptional,
}
\usepackage{hyperref}
\begin{document}
\begin{enumerateoptional}[1.]
\item[\bfseries test\_duplicatedContext] Detecção de contextos duplicados e
emissão de um erro semântico.
\item[\bfseries test\_duplicatedIncludes] Detecção de inclusões duplicadas e
emissão de um erro semântico.
\item[\bfseries test\_invalidRegexInput] Detecção de expressões regulares
inválidas e emissão de um erro semântico.
\item[\bfseries test\_missingIncludeDetection] Detecção da inclusão um bloco
inexistente.
\item[\bfseries test\_duplicatedGlobalNames] Detecção de múltiplas definições
do nome da gramática e
emissão de um erro semântico.
\item[\bfseries test\_missingScopeGlobalName] Detecção da falta da definição do
nome do escopo global da gramática e emissão de um erro semântico.
\end{enumerateoptional}
\end{document}
On the following image, the extra new line is between the 4th and 5th item. It is happening because the 4th line is filled 100% the maximum width and latex is putting a extra new line right after it I do not know why.
How can I stop this useless empty line popping up in the middle of my lists, depending on each item line size?


\itemdoes a\pareventually, but apparently at the time it does it's too late. Adding the\par(blank line) earlier works... – Phelype Oleinik Oct 21 '19 at 03:40\itemincluding the accented letters, but the typeset example doesn't inlcude them. Does the output look the same if you replace the text in the source code byDeteco da incluso um bloco inexistente.? – thymaro Oct 21 '19 at 03:46\itemand it was fixed. Thanks! – user Oct 21 '19 at 03:55hyperrefpackage only. There is something that is making this weird behaviour. Add a\parafter the item and the problem goes away. Add a%after the item and the problem also goes away. Comment out the\refstepcounterline and the problem goes away. Comment outhyperrefand, you guessed, the problem goes away. Looks like a bug (or at least a quite odd feature) to me... – Phelype Oleinik Oct 21 '19 at 04:54