2

After adding a piece of code in text, I wish it could look like this: shell code in text.

Now I used \verb@@ to insert command, but it does not handle line break and indentation.

  • Welcome to TeX.SX! What have you done so far? Could you please add some working code? – Bobyandbob Apr 25 '18 at 9:00
  • @Bobyandbob Usually program developers use markdown to write document, but I would like to use tex to achieve the same effect. – Tiina Apr 26 '18 at 2:12
5

Here is a solution for your black box.

\documentclass{article}
\usepackage{tcolorbox}
\usepackage{fancyvrb}
\usepackage{xcolor}


\begin{document}
    \begin{tcolorbox}[colframe=black,colback=black,coltext=white]
\begin{Verbatim}[commandchars=\\\{\}]
$ svn log --xml | grep P \textcolor{yellow}{"^<author"} | sort u | \textbackslash
  perl -pe \textcolor{yellow}{'s/<author>(.*?)<\textbackslash/author>/$1 = /'} > users.txt
        \end{Verbatim}
    \end{tcolorbox}
\end{document}

enter image description here

  • perfect, the solution is very inspiring. – Tiina Apr 26 '18 at 2:28

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.