gpoore / minted

minted is a LaTeX package that provides syntax highlighting using the Pygments library. Highlighted source code can be customized using fancyvrb.
1.75k stars 126 forks source link

Suggestion : a `longlisting` environment. #189

Open EmmanuelCharpentier opened 6 years ago

EmmanuelCharpentier commented 6 years ago

The current listing environment is handy for code snippets and small extracts. But it cannot (obviously) typeset programs more than one page long (if you try it, you get a truncated listing).

This is inconvenient for "verbose" languages, such as C++ or Stan, or for long programs. For such lengthy code, one does not need a float environment, but a caption and a label are useful.

inspired by the answer to this StackExchange question, the following one liner is handy :

\newenvironment{longlisting}{\captionsetup{type=listing}}{}

and allows this đź‘Ť

\begin{longlisting}
  \inputminted{stan}{IRT.stan}
  \caption[Modèle IRT multiniveaux]{Modèle IRT modélisant des
    discriminations et des sévérités variant par juge et par critère}
 \label{lst:IRT}
\end{longlisting}

But this solution can be enhanced :

An example of similar output can be obtained by the longtable environment. But its implementation seems quite different of what can be easily done with minted.

Do you think it is worthwhile to pursue this idea ?

gpoore commented 6 years ago

It would be good to have a longlisting environment. The minted documentation FAQ actually links to the same StackExchange discussion with the one-line solution. The main reason there isn't a longlisting is that there would really need to be some of the enhanced options you mentioned. If you can figure out a way to get something equivalent to longtable, I would be happy to include that in minted. Otherwise, maybe I will get around to working on a proper longlisting someday.

goyalyashpal commented 1 year ago

i am not getting a truncated listing (taking from a file)

is this issue still valid?

xNaCly commented 1 year ago

i am not getting a truncated listing (taking from a file) is this issue still valid?

I am including a 171 lines long snippet in the appendix of my thesis, at the page break the rest is still truncated:

grafik

goyalyashpal commented 1 year ago

I am including a 171 lines long snippet in the appendix of my thesis, at the page break the rest is still truncated:

MWE??

ive-just-been-asked-to-write-a-minimal-working-example-mwe-what-is-that https://tex.meta.stackexchange.com/questions/228/

xNaCly commented 1 year ago

I am including a 171 lines long snippet in the appendix of my thesis, at the page break the rest is still truncated:

MWE??

ive-just-been-asked-to-write-a-minimal-working-example-mwe-what-is-that https://tex.meta.stackexchange.com/questions/228/

I fixed it with the longlisting example, but i can provide a minimal example once i ripped out everything else