我尝试使用 使文本包含在\verb
不同的行中\verb#<TITLE>*\\</TITLE>#
,但现在的结果正是我所期望的:
<TITLE>*\\</TITLE>
因为我想将其放入</TITLE>
下一行。那么如何解决这个问题呢?
verbatim
我尝试(在我的论文中)使用如下形式:
The first instruction searches an HTML document against a pattern
\begin{verbatim}
<TITLE>*
</TITLE>
\end{verbatim}
, that it looks for the first region which starts with \verb#<TITLE># and ends with \verb#</TITLE>#.
显示为:
The first instruction searches an HTML document against a pattern
<TITLE>*
</TITLE>
, that it looks for the first region which starts with <TITLE> and ends with </TITLE>.
但我希望<TITLE>*</TITLE>
在其中verbatim
拥有一些内联效果,因此它可能看起来像:
The first instruction searches an HTML document against a pattern <TITLE>*
</TITLE>, that it looks for the first region which starts with <TITLE>
and ends with </TITLE>.
那么该怎么做呢?
[编辑] 我最终通过使用解决了这个问题\ttfamily
。
答案1
为了适应逐字内的换行符,请使用以下verbatim
环境:
\documentclass{article}
\setlength{\parindent}{0pt}% For this example
\begin{document}
\verb|<TITLE> * </TITLE>|
\begin{verbatim}
<TITLE> *
</TITLE>
\end{verbatim}
{\ttfamily%
<TITLE> *
</TITLE>
}
\end{document}
另请参阅,作为参考,\verb
和之间有什么区别verbatim
?。
要在内联中插入强制换行符\verb
,您可以将其拆分为单独的\verb
命令:
\documentclass{article}
\setlength{\parindent}{0pt}% For this example
\begin{document}
The first instruction searches an HTML document against a pattern \verb|<TITLE>*|\\
\verb|</TITLE>|, that it looks for the first region which starts with \verb|<TITLE>|
and ends with \verb|</TITLE>|.
The first instruction searches an HTML document against a pattern {\ttfamily <TITLE>*
</TITLE>}, that it looks for the first region which starts with {\ttfamily <TITLE>}
and ends with {\ttfamily </TITLE>}.
\end{document}