# Terminal screenshot generator

I would like to document work in console while I also think that bitmap images are not the best way to do it. They do not scale well and after all what I am trying to document is text. Therefore I began to wonder whether there is something that could embed text provided into latex formatting which rendered would resemble terminal output.

My intention is to document interaction with a microcontroller using serial line terminal emulator. It typically means single line command followed by a few lines of response.

• You can treat terminal output just like verbatim text or code. Hence, packages like listings are what you want. It is even possible to have white text on a black background with the right settings. Apr 30 '16 at 10:59
• this is a question where a screenshot of what you want to emulate would be helpful. Apr 30 '16 at 12:22
• @barbarabeeton you are right. I want to document command line interaction with a device. Nothing fancy like ASCII art required here. Apr 30 '16 at 12:38
• Possible duplicate: How to render Terminal Output in LaTeX
– Werner
Apr 30 '16 at 19:00

Something like this? (Actually stolen from tcolorbox manual and slightly changed ;-))

A verbatim input environment is necessary in my point of view, so a listings etc. style approach might be very convenient.

The tcolorbox wrappers of listings provide nice features to improve the look of the surroundings of a listings environment.

Use the every listings line= option to provide some information like hostname or user name etc, depending on your special terminal style.

\documentclass{article}

\usepackage[most]{tcolorbox}

\newtcblisting{commandshell}{colback=black,colupper=white,colframe=yellow!75!black,
listing only,listing options={language=sh},
every listing line={\textcolor{red}{\small\ttfamily\bfseries DeathStar \$> }}} \begin{document} \begin{commandshell} ls -al cd /usr/lib rm -rf * \end{commandshell} \end{document}  • This is nice, but the command prompt is fake and fixed... do you know if there is a verbatim environment able to accept ANSI color codes and unicode char? Copying and pasting (even from a script log) this terminal will not work... Apr 30 '16 at 11:15 • @christianHupfer maybe he would like to have something like c:\> cd temp next line c:\temp> dir and all after > has another color....only guessed Apr 30 '16 at 11:22 • @PeterEbelsberger: Perhaps, but he might ... or he would or ... it could be that ... Interestingly you and Rmano complain about what my solution does not provide, but not about that the question is not clear at all ;-) – user31729 Apr 30 '16 at 11:24 • No, I do not complain. If you feel so I am sorry. I have tried to provide another solution....but it fits not my own needs. Apr 30 '16 at 11:33 Knitr can show not only outputs from R, but also from another engines. May be this is not the ideal approach to mimic a real screenshot, but can show the true outputs of a bash shell typing only the commands. \documentclass{article} \usepackage{xcolor} %\usepackage[black]{sourcecodepro} \begin{document} \section*{Top Linux utilities:} \subsection*{fortune} <<eval=F,background='lightyellow',>>= me@mypc$ fortune
@
\noindent\fcolorbox{green}{black}{
\parbox{\linewidth}{\color{white}\sffamily
<<engine='bash', echo=F, results="asis">>=
fortune fortunes
@
}}
\subsection*{apt-get moo}
<<engine='bash'>>=
apt-get moo
@
\subsection*{cowsay}
<<eval=F>>=
cowsay "Hello, World"
@
<<engine='bash', background='lightcyan', comment="",echo=F>>=
cowsay "Hello, World"
@
\end{document}

• This is wicked cool! Although bit of an overkill for my actual purpose, I have spent some time playing with knitr (another reason for moving from SAS to R ;) ). Thanks for expanding my horizons. May 25 '16 at 18:00
• @Mr.Tao You're welcome. LaTeX or R are both woderful , but discover that one can LaTeX+R turn both tools in invaluable resources.
– Fran
May 25 '16 at 23:10
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{listings}
\usepackage{listingsutf8}

\def\CS#1{\texttt{\textbackslash#1}}

\usepackage[most]{tcolorbox}
\newtcblisting{commandshell}{colback=black,colupper=white,colframe=yellow!75!black,
listing only,listing options={style=tcblatex,language=sh},
every listing line={\textcolor{red}{\small\ttfamily\bfseries DeathStar \\$> }}}

\begin{document}
\begin{commandshell}
ls -al
cd /usr/lib
rm -rf *
\end{commandshell}

\begin{lstlisting}[escapechar=ä,numbers=none,framerule=0.0pt]
ä\colorbox{black}{%
\parbox{5.7in}{\color{white} C:\CS{}>cd \CS{}Python27 \\ C:\CS{}Python27>cd scripts \\ C:\CS{}Python27\CS{}Scripts>easy\_install pygmentize}
}
\end{lstlisting}

\end{document}


The solution of Christian is still included.

• while well-intended, the example with "ordinary" serif type does not show up well at all on some monitors -- the thin strokes nearly disappear. (always worse with reverse video.) and although a proportionally spaced monowidth font would improve that situation, it's often the case with terminal output that the strict alignment in adjacent lines is very helpful (if not absolutely necessary) for quick comprehension. Apr 30 '16 at 12:27