# Making text appear in a box [duplicate]

Sorry if this is similar to previous questions, but I need to check if this is the best solution. My issue is that I am writing a document which contains HTTP messages for example of a snippet:

   message-header = field-name ":" [ field-value ]
field-name     = token
field-value    = *( field-content | LWS )
field-content  = <the OCTETs making up the field-value
and consisting of either *TEXT or combinations
of token, separators, and quoted-string>


much like when using this website the message appears in a grey box is there a best practice way to do this in latex? I have found the following link: Box or sidebar for additional text and was wondering whether this is the best solution. I was also hoping to omit the text from a wordcount if possible. Any ideas would be greatly appreciated - I am hoping for the following kind of effect:

• I really do not understand what are you after. Could you be a bit more specific? – yo' Aug 18 '15 at 17:08
• Perhaps this is a duplicate? Source code listing with frame around code? On the counting issue, word counting is really hard in TeX, but the texcount program does a pretty usable job and is able to selectively remove environments from the count. – Alan Munn Aug 18 '15 at 17:18
• @AlanMunn: The linked post seem to require the addition of a caption, which this question does not. But that might be splitting hairs. – Werner Aug 18 '15 at 17:24
• @Werner well caption or not the basic principle seems to be the same. Alternatively How to make a box containing LaTeX output? but I think the first one is better. – Alan Munn Aug 18 '15 at 17:27

Consider using tcolorbox's listings option:

\documentclass{article}

\usepackage[listings]{tcolorbox}

\begin{document}

\begin{tcblisting}{listing only}
message-header = field-name ":" [ field-value ]
field-name     = token
field-value    = *( field-content | LWS )
field-content  = <the OCTETs making up the field-value
and consisting of either *TEXT or combinations
of token, separators, and quoted-string>
\end{tcblisting}

\end{document}