[Tex/LaTex] Inserting LaTeX code into LaTeX


I have a problem with adding text into a LaTeX document. I have a LaTeX document about LaTeX and I need to insert some code snippets. I need to add "\usepackage{musixtex}" as a text, which should be displayed as a text. Do you know how?

Best Answer

You can use \verb like this:

Example: \verb!\usepackage{musixtex}!

Edits by Speravir and Sam Whited:

There is also a starred version, which makes the spaces visible:

\verb|\LaTeX vs. \LaTeX\ or \LaTeX{} \dots|

\verb*|\LaTeX vs. \LaTeX\ or \LaTeX{} \dots|

\LaTeX vs. \LaTeX\ or \LaTeX{} \dots


If you end up with more than a short, one line, phrase you might also try the verbatim (built in) or Verbatim (an improved version located in the fancyvrb package) environments.


  Some LaTeX code here
  Which can be multiple lines