If you're going to have to type up more of these tags, the listings
package may be well worth a try (employing colors for operators (or literals, or whatever) is tricky; if you'd like them, usually, one suggests the package minted
, which unfortunately does not do inline stuff! catch 22!):
\documentclass{article}
\usepackage{listings}
\begin{document}
\lstinline[language=xml]!<tag>!
\end{document}
Some remarks about the code:
!
is a delimiter for the code that goes between its two instances: so, this should be a symbol that does not appear in the code (cf. |
that appears in \verb
command in m0nhawk's solution). So,
\lstinline<<tag>< % wrong
\lstinline><tag>< % not wrong, but not what you want
\lstinline$<tag>$ % right
\lstinline+<tag>+ % right
\lstinline|<tag>| % right
The delimiter cannot be this [
unless you do the following:
\lstinline[][<tag>[
(What is happening is that, the \lstinline
looks for an optional list of key=value
pairs, when it first encounters [
.)
I am posting this answer, mostly for the reason that, using \verb
, you end up with different font family, which may well be your desire! In case, you'd like the same font family, this solution is open.
Output: