TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm writing a document about an XML schema, and I will be talking a lot of times about that <tag1> or that other <tag2>. Since I'm only mentioning them and not printing a whole XML file, it doesn't feel like a job for listings.

I suppose using $<tag1>$ wouldn't fit well either. So... which would be the best way of writing isolated XML tags in a document?

share|improve this question
up vote 9 down vote accepted

The definition of a new command would be the easiest way to go.


Use it in your document as \xml{tag}.

share|improve this answer

With listings you can do the following:


And then use it thus: |<tag1>| and it will be printed using the listings style, and syntax highlighting and so on. You could use a symbol other than | if you so wished.

share|improve this answer


I will be talking a lot of times about that \<tag1> or that other \<tag2>.

XML Tags

share|improve this answer
I don't deal with XML a lot, but I've never seen \langle and \rangle used for the pointy brackets < and >. While the former are prettier in many cases, I think the latter are the standard, most importantly because they are the ones you actually use in code. Furthermore, your sample uses the normal font for the brackets and teletype for the tag, which seems typographo-semantically imprecise. – doncherry Nov 30 '11 at 15:07
Well, \def\<#1>{\texttt{<#1>}} would fix that and you could still have a notation that is very close to the literal strings. I precisely like \langle and \rangle because they don't take up as much space as < and >. But I'll admit that using \langle in body text and < in listings would be wrong. – Christian Lindig Nov 30 '11 at 17:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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