2

This question already has an answer here:

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 Oct 10 '17 at 12:25

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

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

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: basic 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].

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