Is it possible to display bash code in LaTeX? Like the next one:

Here is the code's format i want to show in latex

In LaTeX, in order to display bash code and any other code, you can use the listings package.

The \lstset command is used to control the basic appearance, including the language of code. Please see page 13 of listings documentation.

The code to be displayed may be part of the LaTeX file or may be an external file.




Code directly embedded in \LaTeX\ file.

  Here is the code's format i want to show in latex

Code from an external file.



Other possible/related options for tasks like the above are (not in any particular order):

| improve this answer | |
  • Thank you, I hadn't found an easy answer to this. Should it works for reportclass? – user134500 Aug 24 '17 at 4:41
  • 3
    @santimirandarp Yes, why not? Updated my answer for report class. Now you can accept my answer and upvote it. :-) – Masroor Aug 24 '17 at 4:46
  • Yes, i will try it and accept and upvote if it works...thank you again. – user134500 Aug 24 '17 at 4:51
  • you might add verbatim to that list. it doesn't have as many bells and whistles, but is simple, reliable, and maintained by the latex team so when something sneaky changes under the covers, it doesn't fall apart. – barbara beeton Aug 24 '17 at 16:56
  • @barbarabeeton Yes, of course. How could I miss that? – Masroor Aug 24 '17 at 16:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy