0

I have a listing as follows:

\begin{lstlisting}[basicstyle=\scriptsize]
...
\end{lstlisting}

The listing is quite long (71 lines + caption), and I want it to fit on a single page. However, I currently get 70 lines on one page and the last line and caption appear on the next page. Is it possible to slightly change the font size in order to make the listing fit on one page? So I need some custom size that is slightly smaller than scriptsize. Tiny is too small. Or is there another way to make the listing fit on a single page?

bys1
  • 1
  • You could try \fontsize{<size>}{<baselineskip>}\selectfont to use another size. See the fntguide for more information. But do you really think that anyone would like to read a listing with such a small font size? Personally I'm usually not able to do so without headache and runny eyes. – cabohah Jun 17 '23 at 18:51
  • Welcome to tex.sx. What document class are you using? You might decrease the \baselineskip a bit, or \enlargethispage{2.5\baselineskip}, which would avoid changing the actual font size. But how this is done does depend on the document class. A small compilable example, beginning with \documentclass and ending with \end{document} would give potential helpers something to experiment with. – barbara beeton Jun 17 '23 at 18:55
  • @cabohah The listing in its current size is perfectly readable. Fitting two more lines would be a very small difference in size, so I don't think that is a problem. – bys1 Jun 17 '23 at 18:58
  • @barbarabeeton enlargethispage actually solved the problem already. Thanks! – bys1 Jun 17 '23 at 18:58
  • @bys1 You are either young and don't need reading glasses or you use a large basic font size. ;-) – cabohah Jun 17 '23 at 19:04

0 Answers0