Text FormattingUnderline Verbatim Text

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
User avatar
thefleche
Posts: 5
Joined: Mon Nov 08, 2010 5:56 pm

Underline Verbatim Text

Post by thefleche »

Hello all,

I would like to be able to underline an verbatim environment. What I would like to do is something like this.

Code: Select all

\underline{\verb|$$verbatim&&|}
But it gives me this error:
! Misplaced alignment tab character &.
<argument> \verb |$$verbatim&&|
Hope someone will have the answer to my problem. Thanks!

thefleche-->
thefleche-->

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Underline Verbatim Text

Post by localghost »

The \verb command cannot be used as argument to another command. You will have to search for alternatives.


Thorsten
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Underline Verbatim Text

Post by cgnieder »

You could define your own underlined \verb command:

Code: Select all

\documentclass{article}
\usepackage{xparse}
\usepackage[normalem]{ulem}

\NewDocumentCommand\ulverb{v}{\uline{\ttfamily#1}}

\begin{document}

\ulverb|$$verbatim&&|

\end{document}
site moderator & package author
User avatar
thefleche
Posts: 5
Joined: Mon Nov 08, 2010 5:56 pm

Re: Underline Verbatim Text

Post by thefleche »

Thanks cgnieder,, but it still doesn't work.
I'll find another way to get the result I want.
thefleche-->
Post Reply