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.

I'm unable to insert a new line while using \ttfamily. Is there any reason why \ttfamily prevents to do that?

My problem (here's the code):

Let's consider an e-commerce web application whose address is:
\begin{ttfamily} https://website-test.com/scripts/GetEBook.aspx?file=ebook7.pdf \end{ttfamily}

I repeatedly tried to insert the \newline command after the word is in order to get the output:

Let's consider an e-commerce web application whose address is:

https://website-test.com/scripts/GetEBook.aspx?file=ebook7.pdf

But unfortunately it doesn't work...I get no new line.

Also, how do I insert spaces in order to move the text forward?

For example:

\begin{ttfamily} \verb https://website-test.com/scripts/GetEBook.aspx?file= \end{ttfamily}
\begin{ttfamily} \verb ..\..\windows\repair\sam \end{ttfamily}

I'd like the output to be:

https://website-test.com/scripts/GetEBook.aspx?file=
                            ..\..\windows\repair\sam

If \ttfamily doesn't allow to do what I need, is there any other way to solve the problem?

share|improve this question
    
possible duplicate of Verbatim environment that can break too long lines? –  Martin Schröder Dec 8 '12 at 13:01
add comment

1 Answer 1

up vote 5 down vote accepted
\documentclass{article}
\usepackage{url}

\begin{document}
\noindent Let's consider an e-commerce web application whose address is:
\vspace{.5cm}
\par\noindent
\begin{ttfamily}%
https://website-test.com/scripts/GetEBook.aspx?file=ebook7.pdf
\end{ttfamily}
\par\noindent
\begin{ttfamily}%
https://website-test.com/scripts/GetEBook.aspx?file=
\end{ttfamily}
\par\noindent
\begin{ttfamily}%
\hspace{5.2cm}\verb|..\..\windows\repair\sam|
\end{ttfamily}

\end{document}

enter image description here

However, if you are trying to write a url address, it is better to use url package. Here the advantage is, if used with hyperref, you can make the url click-able.

\documentclass{article}
\usepackage{url}

\begin{document}
\noindent Let's consider an e-commerce web application whose address
is:\\[.5cm]
\url{https://website-test.com/scripts/GetEBook.aspx?file=ebook7.pdf}
\par\noindent
\url{https://website-test.com/scripts/GetEBook.aspx?file=}\\
\hspace*{5.2cm}\verb|..\..\windows\repair\sam|
\end{document}
share|improve this answer
    
thanks very much..but if I'm not wrong after the phrase "whose address is:" there's no space..While the solution to the other problem (horizontal space) works perfectly.. –  g9999 Dec 8 '12 at 9:49
    
@ Harish Kumar I mean I should get a new line..as I stated ..I used the command \\ as you did now..thanks –  g9999 Dec 8 '12 at 10:02
    
Perfectly..Thanks –  g9999 Dec 8 '12 at 10:24
    
@g9999 We say thanks here in TeX.SX by upvoting and accepting the most useful answer (by clicking the green check mark below the votecount) so that the question may be considered as answered. This is the tradition followed here. You may wait for some time before accepting the answers, though. –  Harish Kumar Dec 8 '12 at 10:26
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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