I am wondering the diffference between \verb and \tt.
For example
\verb|difference| appears the same with \tt{difference}
I am wondering the diffference between \verb and \tt.
For example
\verb|difference| appears the same with \tt{difference}
The difference is that \verb is an inline verbatim environment so that everything inside it is taken literally, even what would otherwise be considered a command. This also happens to use a monospace font because it is usually used to insert code snippets (so that special characters don't pose any issue).
On the other hand, \tt (and you really should be using \texttt{...}) simply switches the font to monospace font, but LaTeX commands remain as usual.
To illustrate the difference, consider these two:
\verb|\emph{hello} world|
\texttt{\emph{hello} world}
which produces:
As a last remark, you shouldn't use \tt and other related commands such as \bf and \it because they are clumsy to use and don't play well together. This is demonstrated well here. To take their place, we have two sets of commands: \bfseries, \ttfamily; and \textbf{...}, \texttt{...}.
\emph{\tt hello} and \emph{\texttt{hello}}. Only the second one produces emphasized typewriter style, the first only produces typewriter style without emphasis.
– Bakuriu
Apr 12 '16 at 18:43
{\tt hello} and not \tt{hello}. With the latter syntax the effects of \tt are not limited to the word hello.
– GuM
Apr 13 '16 at 06:07
$%#\\^as the argument. – Steven B. Segletes Apr 12 '16 at 13:00