# Suppress newline after macro

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}

• Welcome to TeX.SX! Can you be more specific about what your end-goal is? This seems to be an odd request. There is a way to do this, but I'm not sure this is the right way to go about what you need to do. – Sean Allred Jan 1 '14 at 19:55
• I am just curious if its possible, since somebody asked a question about something that would probably be solveable by this, so I am wondering if this approach would work, therefor i think an "ignore the newline, even if the next macro is telling you that this will be a new paragraph"-command is something worth trying out. And before I invest time trying to research/bruteforce something impossible I thought it would be wiser to ask here first – user2567875 Jan 1 '14 at 20:08
• Without some context the problem is ill posed. – egreg Jan 1 '14 at 20:32

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:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{enumitem}
\usepackage{fancyvrb}
\begin{document}

\begin{itemize}
\item[first]
\begin{BVerbatim}[baseline=t]
foo
bar
\end{BVerbatim}

\item[second] more text
\end{itemize}
\end{document}


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 as

\item[] first


I put first as the optional argument; do as you prefer. If you want a labelless itemize, it's easier to say

\begin{itemize}[label={}]


and simply use \item, since you're using enumitem.

Here's the modified list, with no label:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{enumitem}
\usepackage{fancyvrb}
\begin{document}

\begin{itemize}[label={}]
\item first
\begin{BVerbatim}[baseline=t]
foo
bar
\end{BVerbatim}

\item second more text
\end{itemize}
\end{document}


• thanks, i will try it, i used "item {first}" because "first" is a text with spaces (which should be set in bold while the other text gets the nice typewriter font) and yes, the indent was on purpose (monospaced font, to be put under the "foo"-part of the sentence) – user2567875 Jan 1 '14 at 21:15
• another question: can you modify it so that the f from "first" and the s from "second" both starting at the beginning at the line? – user2567875 Jan 1 '14 at 21:24
• @user2567875 Sure, there it is. – egreg Jan 1 '14 at 21:35
• perfect, i didnt expect such an elegant solution! thanks a lot again – user2567875 Jan 1 '14 at 21:42