2

I tried to make the text contained within \verb different line by using \verb#<TITLE>*\\</TITLE>#, but the result is now what I expected:

<TITLE>*\\</TITLE>

since I want to put </TITLE> into the next line. So how to solve the issue?

I tried to use verbatim (in my thesis) as:

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>#.

It displayed as:

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>.

But what I like to have <TITLE>*</TITLE> within verbatim to have some inline effect, so it may look like:

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>.

So how to do that?

[EDIT] I finally work this around by using \ttfamily.

4

To accommodate for line-breaks inside verbatim, use the verbatim environment:

enter image description here

\documentclass{article}
\setlength{\parindent}{0pt}% For this example
\begin{document}

\verb|<TITLE> * </TITLE>|

\begin{verbatim}
<TITLE> *
</TITLE>
\end{verbatim}

{\ttfamily%
<TITLE> *

</TITLE>
}

\end{document}

Also see, as reference, What are the differences between \verb and verbatim?.


To insert a forced line-break within an in-line \verb, you can break it up into separate \verb commands:

enter image description here

\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}
  • @daiyue: See my updated answer. I also include the use of {\ttfamily ...} to show there's no difference. Once should (for the sake of consistency) make a macro to address your font-specific requirements rather than setting things using the default \verb or \ttfamily or \texttt. – Werner Oct 9 '14 at 21:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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