TransWikia.com

How to break a listing?

TeX - LaTeX Asked on March 1, 2021

For my listings of LaTeX I use the low key approach exemplified in the code below. The problem is, the input and output together must fit inside a page or else it messes up the layout and is cut short.

The idea is to split the listings that are too big into small ones. Splitting the In: (verbatim) part is not a problem. How would I do so for the Out: part? In this example, is there a way to grab the low level TeX code generated by lipsum[1-8]?

PS I looked at the Listings package, which does support splitting, but apparently is only for showcasing the input.

documentclass[full]{l3doc}
usepackage{mwe} % TEST
usepackage{float} % DOC
usepackage{cleveref} % DOC

floatstyle{ruled}
newfloat{Listing}{h}{lop}

begin{document}

vspace*{fill}
begin{Listing}
  textbf{In:}

  verb|lipsum[1-8]|

  textbf{Out:}

  lipsum[1-8]

end{Listing}

end{document}

enter image description here enter image description here

One Answer

Based on the comments.

documentclass[full]{l3doc}
usepackage{mwe}
usepackage{tcolorbox}

tcbuselibrary{listings,breakable}

begin{document}

newtcblisting[auto counter]
{listing}[2][]{
  noparskip,
  breakable,
  colback=white,
  colframe=black,
  opacitybacktitle=.8,%
  fonttitle=bfseries,
  title=Listing~thetcbcounter,
%  listing only,
  arc=0pt,
  outer arc=0pt,
  boxrule=0pt,
}

%tcbsubtitle[before skip=baselineskip]{My subtitle}

begin{listing}{}
  lipsum[1-8]
end{listing}

end{document}

enter image description here

Answered by Erwann on March 1, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP