1

I can't manage to add linenumbers left of the boxes. Can anybody help me?

\documentclass{article}

\begin{document}

\fbox{\fbox{

\begin{minipage}{0.8\linewidth}

\textbf{def} mapper (key, value):

\hspace{7mm}\textbf{for} word \textbf{in} value.split():

\hspace{14mm}\textbf{yield} word, 1\\

\textbf{def} reducer (key , values):

\hspace{7mm}\textbf{yield} key, sum(values)\\


\textbf{if} name == "main":

\hspace{7mm}\textbf{import} dumbo

\hspace{7mm}dumbo.run (mapper, reducer, combiner=reducer )

\end{minipage}

}}

\end{document}

Thanks

  • I think this should probably be retitled? Not sure to what, though... perhaps "how to do line-numbered code listings?" – SamB Dec 25 '10 at 18:21
  • Btw, @user2678, I would suggest you fill in some sort of mnemonic in your profile -- whether it be some form of your name or just a pseudonym -- which make you look more like a particular person and less like some random luser. (Registering an account was a good start, though.) – SamB Dec 25 '10 at 18:30
4
\documentclass{article}
\usepackage{listings}

\lstset{numbers=left,numberstyle=\tiny,numbersep=1em,
  morekeywords={def,for,yield,if,import},
  keywordstyle=\bfseries,frame=TLBR}
\begin{document}


\begin{lstlisting}
def mapper (key, value):
  for word in value.split():
    yield word, 1
def reducer (key , values):
  yield key, sum(values)
  if name == "main":
    import dumbo
    dumbo.run (mapper, reducer, combiner=reducer )
\end{lstlisting}

\end{document}

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.