2

I want to use listing inside a frame. I know that I have to specify:

begin{frame}[fragile]

.....

However my code has not the row elements i.e. on the left the numbers related to the rows are truncated. Here there is the screen. screen How could I obtain these numbers?

EDIT

A section of my code is :

\begin{frame}[fragile]
\begin{lstlisting}[
basicstyle=\tiny]
direction = 4 + 1;

BuscherR[BB, G, Dil, CCC, direction];
CCC = CCCTemp;
G = GTemp;
BB = BBTemp;
Dil = Diltemp;
DS = Simplify[SetVariable.G.SetVariable];
\end{lstlisting}
\end{frame}

EDIT_2

\documentclass[pdf,default]{beamer}

\usepackage{graphicx}
% \usepackage{a4wide}
% \usepackage{bbold}
% \usepackage{amsmath,amssymb,bbm}
%\usepackage{rotating}
 \usepackage{multirow}
%\usepackage{youngtab}
% \usepackage{comment}
 \usepackage{pstricks}
% \usepackage{graphicx}
\usepackage{longtable}
\usepackage{dsfont}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
% \usepackage{multirow}
% \usepackage{pstricks,pst-node,pst-text,pst-3d}
\usepackage{amsmath,amssymb,bbm}
% Definition of new colors
% \newrgbcolor{LemonChiffon}{1. 0.98 0.8}
% \newrgbcolor{LightBlue}{0.68 0.85 0.9}
\usepackage{comment}
\usepackage[verbose]{wrapfig}
\usepackage{listings}




\def\de{\partial}
% \def\ket{\rangle}
\def\alphap{{\alpha'}}
\def\Zbf{{\bf Z}}
\def\coeff#1#2{\frac{#1}{#2}}
\def\2{\frac12}
\def\4{\frac14}
\def\ie{{\it i.e.}}
\newcommand{\abs}[1]{\lvert #1\rvert}
\newcommand{\zb}{\bar{z}}
\newcommand{\ab}{\bar{a}}
\DeclareMathOperator{\trace}{Tr}
\newcommand{\ket}[1]{\lvert \, #1 \, \rangle}
\newcommand{\bra}[1]{\langle \, #1 \, \rvert}
\newcommand{\be}{\begin{equation}}
\newcommand{\ee}{\end{equation}}
\newcommand{\bea}{\begin{eqnarray}}
\newcommand{\eea}{\end{eqnarray}}
\def\a{\alpha}
\def\b{\beta}
\def\g{\gamma}
\def\G{\Gamma}
\def\d{\delta}
\def\e{\epsilon}
\def\z{\zeta}
\def\h{\eta}
\def\th{\theta}
\def\k{\kappa}
\def\l{\lambda}
\def\L{\Lambda}
\def\m{\mu}
\def\n{\nu}
\def\x{\xi}
\def\X{\Xi}
\def\p{\pi}
\def\P{\Pi}
\def\r{\rho}
\def\s{\sigma}
\def\S{\Sigma}
\def\t{\tau}
\def\f{\phi}
\def\F{\Phi}
\def\c{\chi}
\def\W{\Omega}
\newcommand {\vv} {\vspace{0.5cm}}
\newcommand{\vvv}{\vspace{0.24cm}}
\newcommand{\w}{\wedge}
%
\lstset{frame=tb,
   language=Mathematica,
   basicstyle={\small\ttfamily},
   numberstyle=\tiny\color{gray},
   keywordstyle=\color{blue},
   commentstyle=\color{green},
   stringstyle=\color{red},
   tabsize=2
   }



\def\de{\partial}

\usetheme{CambridgeUS}

\title{Supertubes and duality}

%\author{Capocci Damiano}

\begin{document}

\begin{frame}
\begin{center}
SUPERTUBES AND DUALITY
\end{center}
\vspace{0.5cm}
\begin{center}
Why exotic states are so important.
\end{center}
\end{frame}


\section{Contestualizzazione}


\begin{frame}[fragile]
\begin{lstlisting}[
basicstyle=\tiny,numbers=left]
BeginPackage["conversionfirst`"]
Begin["Global`"]

ConversionTensor[CCC_]:=
Module[{qqqqq},
Clear[TensorCCC];
Clear[ListaIndici];
Clear[ListaIndicidue];
Clear[PermutazioniTensore];
variables={x[0],x[1],x[2],x[3],x[4],x[5],x[6],x[7],x[8],x[9]};

If[CCC=!=0,
ListaCCC=MonomialList[CCC,variables];

Do[
Do[
If[D[ListaCCC[[t]],x[q]]*(x[q]/ListaCCC[[t]])==1,ListaIndici[q+1]=1,
ListaIndici[q+1]=0],{q,0,9}];  
Evaluate[TensorCCC@@Flatten[Position[Array[ListaIndici,10,1],1]]]=
 ListaCCC[[t]]/Product[x[k-1],{k,Flatten[Position[Array[ListaIndici,10,1],1]]}]; 
ListaIndicidue[t]=Flatten[Position[Array[ListaIndici,10,1],1]]
,{t,1,Length[ListaCCC]}];



Do[
PermutazioniTensore=Permutations[ListaIndicidue[tt]];
Do[

Activate @ Inactive[Set][ Inactive[TensorCCC]@@Flatten[  PermutazioniTensore[[g]]  ], TensorCCC@@Flatten[PermutazioniTensore[[1]]]*Signature[PermutazioniTensore[[g]]]],  
{g,1,Dimensions[PermutazioniTensore][[1]] } ];
,{tt,1,Length[ListaCCC]} ];

C6=0;

Do[
If[ Dimensions[ListaIndicidue[s]]=={6},C6 +=ListaCCC[[s]] ] 

,{s,1,Length[ListaCCC]} ];



]
]
End[]
EndPackage[]


\end{lstlisting}
\end{frame}
\vv
\vv
\vv
\vv
\vv
\vspace{2cm}





\end{document}
  • How did you produce this image? If you have complete code for the slide (a MWE), that would help a lot. – whatisit Dec 15 '18 at 0:23
  • As for the text not having numbers on the left side, I believe you want something like \lstset{numbers=left, numberstyle=\small} before your \begin{lstlisting}...\end{lstlisting} environment. – whatisit Dec 15 '18 at 0:26
  • 5
    Please make a minimal working example (MWE) – samcarter Dec 15 '18 at 0:50
  • From the looks of it, the numbers might just be cut off by the left hand boarder. But without seeing the code it is impossible to fix – samcarter Dec 15 '18 at 13:38
  • Sorry i thought it was a general problem. Now in the question there is an edit. – siderius Dec 15 '18 at 22:35
3

The crucial information that you withheld is that you are using the CambridgeUS theme. This theme uses very small margins which don't provide enough room for the line numbers. Therefore you need to adjust the margin to make them full visible.

Some other comments concerning your code

  • The documentclass options pdf,default don't make much sense

  • you don't need \usepackage{graphicx} with beamer

  • better not use \usepackage[verbose]{wrapfig} with beamer. If you want to place things besides each other, use beamers own column mechanism

  • Why do you define \def\de{\partial} several times?

  • redefinitions like \newcommand{\be}{\begin{equation}} etc. are bad style. If you don't want to type the full name, better use an editor with a good autocompletion and/or shortcuts instead of obfuscating your code like this

  • definitions like \def\a{\alpha} beg for trouble, better use a good editor, see comment above

  • Even with tiny font, your listings will not fit on a single frame. Make sure to use breaklines to avoid cutoff lines and either split it over multiple slides or, better, only show the relevant part of your code

  • Manually adding spaced outside of frames, e.g. with \vv \vv \vv \vv \vv \vspace{2cm} does not make any sense at all!


\documentclass{beamer}

\usepackage{listings}

\lstset{frame=tb,
   language=Mathematica,
   basicstyle={\small\ttfamily},
   numberstyle=\tiny\color{gray},
   keywordstyle=\color{blue},
   commentstyle=\color{green},
   stringstyle=\color{red},
   tabsize=2,
   breaklines=true,
   xleftmargin=0.5cm
   }

\usetheme{CambridgeUS}

\begin{document}

\begin{frame}[fragile]
\begin{lstlisting}[
basicstyle=\tiny,numbers=left]
BeginPackage["conversionfirst`"]
Begin["Global`"]

ConversionTensor[CCC_]:=
Module[{qqqqq},
Clear[TensorCCC];
Clear[ListaIndici];
Clear[ListaIndicidue];
Clear[PermutazioniTensore];
variables={x[0],x[1],x[2],x[3],x[4],x[5],x[6],x[7],x[8],x[9]};

If[CCC=!=0,
ListaCCC=MonomialList[CCC,variables];

Do[
Do[
If[D[ListaCCC[[t]],x[q]]*(x[q]/ListaCCC[[t]])==1,ListaIndici[q+1]=1,
ListaIndici[q+1]=0],{q,0,9}];  
Evaluate[TensorCCC@@Flatten[Position[Array[ListaIndici,10,1],1]]]=
 ListaCCC[[t]]/Product[x[k-1],{k,Flatten[Position[Array[ListaIndici,10,1],1]]}]; 
ListaIndicidue[t]=Flatten[Position[Array[ListaIndici,10,1],1]]
,{t,1,Length[ListaCCC]}];



Do[
PermutazioniTensore=Permutations[ListaIndicidue[tt]];
Do[

Activate @ Inactive[Set][ Inactive[TensorCCC]@@Flatten[  PermutazioniTensore[[g]]  ], TensorCCC@@Flatten[PermutazioniTensore[[1]]]*Signature[PermutazioniTensore[[g]]]],  
{g,1,Dimensions[PermutazioniTensore][[1]] } ];
,{tt,1,Length[ListaCCC]} ];

C6=0;

Do[
If[ Dimensions[ListaIndicidue[s]]=={6},C6 +=ListaCCC[[s]] ] 

,{s,1,Length[ListaCCC]} ];



]
]
End[]
EndPackage[]

\end{lstlisting}
\end{frame}

\end{document}

enter image description here

  • Thankl you for the answer, I've used the numbers=left option but I have the same problem. In the question there is another edit: it is a mwe. Maybe the problem is in the setting of Mathematica i.e. in \lstset – siderius Dec 16 '18 at 10:28

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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