ttfamily 用法(换行失败)

ttfamily 用法(换行失败)

使用时我无法插入新行\ttfamily。有什么原因\ttfamily阻止我这样做吗?

我的问题(这是代码):

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}

\newline我反复尝试在单词后插入命令is以获得输出:

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

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

但不幸的是,它不起作用...我没有得到新的线路。

另外,如何插入空格以使文本向前移动?

例如:

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

我希望输出是:

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

如果\ttfamily不允许做我需要的事情,还有其他方法可以解决问题吗?

答案1

\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}

在此处输入图片描述

但是如果你要写一个 url 地址,最好使用urlpackage。这里的好处是,如果和 一起使用hyperref,可以让 url 可点击。

\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}

相关内容