How can I suppress a newline that will be inserted afterwards by a macro?
Is there any command that turns off newlines for exactly one time and turns it back on after the skipped one?
Like ignoring that the following macro starts by making a new paragraph before writing out text.
So only the text will be printed, but not the linefeed starting the paragraph.
Is such a command possible?
As requested an example:
writes: "first linebreak spaces foo"
wanted: "first spaces foo"
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{enumitem}
\begin{document}
\begin{itemize}
\item[]{first} \begin{verbatim} foo
bar
\end{verbatim} \item[] {second} more text
\end{itemize}
\end{document}
Best Answer
The case of
verbatim
is “tricky”: by default this environment issues a line break command and typesets its contents on the whole line length (taking into account, here, of being in a list).You can use facilities from
fancyvrb
for boxing the verbatim environment:Notice that you should not indent the contents of a verbatim environment, unless you want indented output.
You usage of
\item[] {first}
is dubious: the command\item
only has an optional argument and no mandatory one, so you get exactly the same output asI put
first
as the optional argument; do as you prefer. If you want a labellessitemize
, it's easier to sayand simply use
\item
, since you're usingenumitem
.Here's the modified list, with no label: