Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

How do I prevent LaTeX from inserting a new line?

Here's the code:

bla bla bla
\begin{verbatim}C:\Program Files\Product Name\Some other extensions\mail box name\end{verbatim} 

The output is:

bla bla bla
 
C:\Program Files\Product Name\Some other extensions\mail box name

That's my problem: I'm unable to prevent LaTeX from inserting a new line after "bla".

Is my problem somewhat related with the fact that I'm using verbatim?

share|improve this question

closed as unclear what you're asking by Jubobs, Jesse, Sean Allred, Marco Daniel, Andrew Swann Mar 3 at 10:13

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

5  
You might want \verb|C:\Program Files\Product Name\Some other extensions\mail box name| –  cgnieder Dec 15 '12 at 15:14
    
@cgnieder: Your comment worse an answer! –  m0nhawk Dec 15 '12 at 15:18
    
I must use verbatin not \verb –  g9999 Dec 15 '12 at 15:24
5  
\verbatim always starts a new line. –  barbara beeton Dec 15 '12 at 15:24
6  
Why do you have to use {verbatim}? It's to be used for displayed verbatim material whereas \verb is for inline material. –  cgnieder Dec 15 '12 at 16:27
show 5 more comments

1 Answer

Your question together with your comment

I must use verbatim not \verb

is a bit confusing. You apparently want inline verbatim material yet not want to use the command that produces it. Unless you can explain why \verb (or listings' \lstinline or minted's \mint or ...) doesn't work for you you're unlikely to get a better answer than what I already said in the comments.

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

\noindent
Some inline verbatim \verb|&%$_^| and some displayed material:
\begin{verbatim}
 &%$_^
\end{verbatim}
Some text after to show the spacing

\end{document}

enter image description here

If you insist in using an environment for inline verbatim material you could use fancyvrb's BVerbatim environment which puts its contents in a TeX box. It might still not be what you're looking for when you need more than one line, though:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{fancyvrb}

\begin{document}

Some text before
\begin{BVerbatim}[gobble=1]
 &%$_^ 
\end{BVerbatim}
\ Some text after to show the spacing

\bigskip

text
\begin{BVerbatim}
 two
 lines 
\end{BVerbatim}
\ text

\bigskip

bla bla bla
\begin{BVerbatim}
C:\Program Files\Product Name\Some other extensions\mail box name
\end{BVerbatim}

\end{document}

enter image description here

Note that the last example will cause an overfull \hbox.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.