如何使 \verb 中的内容出现在不同的行

如何使 \verb 中的内容出现在不同的行

我尝试使用 使文本包含在\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}

相关内容