# How to put some commands written by a software's codes into Latex beamer? [duplicate]

I prepared a program written in GAP's envirounment. I'd like to put them all in one of my beamer pages exactly as follows:

gap> z:=CyclicGroup(IsPermGroup,10);; n:=CyclicGroup(IsPermGroup,15);;
s:=DirectProduct( z, n );;
e:=Elements(s);;
r:=Filtered(e,t->Order(t)=10);;
Size(r);;


What can I do? I used \text{} to get the result as it is shown above but it's useless. Thanks for any help.

## marked as duplicate by Ignasi, diabonas, Troy, Stefan Pinnow, user36296 beamer StackExchange.ready(function() { if (StackExchange.options.isMobile) return; $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() { var$hover = $(this).addClass('hover-bound'),$msg = $hover.siblings('.dupe-hammer-message');$hover.hover( function() { $hover.showInfoMessage('', { messageElement:$msg.clone().show(), transient: false, position: { my: 'bottom left', at: 'top center', offsetTop: -7 }, dismissable: false, relativeToBody: true }); }, function() { StackExchange.helpers.removeMessages(); } ); }); }); Oct 10 '17 at 12:25

• Welcome to TeX.SX! You may want to have a look at the listings or minted packages. – greyshade Aug 30 '14 at 17:39
• Make sure you use the [fragile] option for the frame containing the verbatim text. – Nicola Talbot Aug 30 '14 at 17:58

You may wish to look into the listings package which was designed for exactly that task.

A minimal example would look like so:

\documentclass{beamer}
\usepackage{listings}
\begin{document}
\begin{frame}[fragile]{Example with listings}
Code can be included and formatted with the \lstinline{listings} package:
\begin{lstlisting}
gap> z:=CyclicGroup(IsPermGroup,10);; n:=CyclicGroup(IsPermGroup,15);;
s:=DirectProduct( z, n );;
e:=Elements(s);;
r:=Filtered(e,t->Order(t)=10);;
Size(r);;
\end{lstlisting}
\end{frame}
\end{document}


and produce this output:

listings comes with a host of formatting options, including line breaking, font size and selection as well as syntax based highlighting of code - see the package documentation as well as these answers here on TeX.SX: [1], [2].