minted
minted copied to clipboard
Suggestion : a `longlisting` environment.
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 :
- For such listings, the caption should be typeset on top of the program.
- Better : repeat the caption on the top of every page, followed by a mention such as "(continued)".
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 ?
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.
i am not getting a truncated listing (taking from a file)
is this issue still valid?
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:
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 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