# How to shrink a listings box in two ways

by Anush   Last Updated August 13, 2019 20:23 PM

I am using listings to show some code:

\documentclass[11pt]{beamer}
\usepackage{tcolorbox}
\tcbuselibrary{listings,skins}
\lstdefinestyle{mystyle}{
numbers=none,
numberstyle=\small,
numbersep=8pt,
language=Python
}
\newtcblisting{mylisting}[2][]{
arc=0pt, outer arc=0pt,
listing only,
listing style=mystyle,
title=#2,
#1
}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, calc, matrix}
\usepackage{listings,newtxtt}
\lstset{basicstyle=\ttfamily, keywordstyle=\bfseries}
\begin{document}
\begin{frame}[fragile]
\frametitle{Title}
\begin{mylisting}[hbox]{}
def peak_recursive(A):
n = len(A)
if n == 1:
return 0
if n == 2:
return 0 if A[0]>=A[1] else 1
if A[n//2]>=A[n//2 + 1] and A[n//2]>=A[n//2 - 1]:
return n//2
elif A[n//2 - 1]>=A[n//2]:
return peak_recursive(A[0:n//2])
else:
return n//2+1+peak_recursive(A[n//2+1:])
\end{mylisting}
\end{frame}
\end{document}


I have two questions:

• The text runs off the right hand side. How can I shrink the text slightly so that it does not to do that?
• For a later slide I would like to shrink the whole box and place it in the top right of the slide so I can then talk about it without it taking up too much space. How can I do that?
Tags :

## Related Questions

Updated April 07, 2018 20:23 PM

Updated February 23, 2017 21:23 PM

Updated October 25, 2017 19:23 PM

Updated September 03, 2016 08:09 AM

Updated March 29, 2017 12:23 PM