Issues related to listings
pi8027 opened this issue · 0 comments
pi8027 commented
Description
I experienced several issues related to listings, such as:
- the wide listing (
listing*
) environment is not available (should eventually be fixed in #225), - the caption and the listing are overlapping in the
marginlisting
environment (as noted in Sect. 3.5 of the documentation: "Unfortunately, the space between the caption and the listing must be adjusted manually; if you find a better way, please let me know."), - the captions of the
lstlisting
environment are counted within chapter, but the captions of thelisting
environment are not (also they are counted independently,marginlisting
uses the former, and thus currently there is no way to make the counter ofmarginlisting
consistent with minted), and - hyphens are printed before and after each margin listing (not only in listings but also in figures and tables, fixed in #235).
I'm preparing a PR to fix (most of) them. I provide a test case for my fix below.
Minimal Working Example
\documentclass{kaobook}[twoside=true]
\usepackage[english]{babel}
\usepackage{lipsum}
\usepackage{kaobiblio}
\usepackage{minted}
\usepackage{listings}
\begin{document}
\setchapterstyle{kao}
\chapter{First Chapter}
\begin{listing}[h]
\caption{Hello world in C (minted, normal listing).}
\begin{minted}{c}
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}
\end{minted}
\end{listing}
\lipsum[1]
\begin{listing*}[h]
\caption{Hello world in C (minted, wide listing).}
\begin{minted}{c}
#include <stdio.h>
int main() { printf("Hello, World!"); return 0; }
\end{minted}
\end{listing*}
\begin{marginlisting}
\caption{Hello world in C (minted, margin listing).}
\begin{minted}{c}
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}
\end{minted}
\end{marginlisting}
\lipsum[1]
\newpage
\begin{listing}[h]
\caption{Hello world in C (minted, normal listing).}
\begin{minted}{c}
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}
\end{minted}
\end{listing}
\lipsum[1]
\begin{listing*}[h]
\caption{Hello world in C (minted, wide listing).}
\begin{minted}{c}
#include <stdio.h>
int main() { printf("Hello, World!"); return 0; }
\end{minted}
\end{listing*}
\begin{marginlisting}
\caption{Hello world in C (minted, margin listing).}
\begin{minted}{c}
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}
\end{minted}
\end{marginlisting}
\lipsum[1]
\newpage
\begin{listing}[h]
\caption{Hello world in C (listings, normal listing).}
\begin{lstlisting}[language=C]
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}
\end{lstlisting}
\end{listing}
\lipsum[1]
\begin{listing*}[h]
\caption{Hello world in C (listings, wide listing).}
\begin{lstlisting}[language=C]
#include <stdio.h>
int main() { printf("Hello, World!"); return 0; }
\end{lstlisting}
\end{listing*}
\begin{marginlisting}
\caption{Hello world in C (listings, margin listing).}
\begin{lstlisting}[language=C]
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}
\end{lstlisting}
\end{marginlisting}
\lipsum[1]
\newpage
\begin{listing}[h]
\caption{Hello world in C (listings, normal listing).}
\begin{lstlisting}[language=C]
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}
\end{lstlisting}
\end{listing}
\lipsum[1]
\begin{listing*}[h]
\caption{Hello world in C (listings, wide listing).}
\begin{lstlisting}[language=C]
#include <stdio.h>
int main() { printf("Hello, World!"); return 0; }
\end{lstlisting}
\end{listing*}
\begin{marginlisting}
\caption{Hello world in C (listings, margin listing).}
\begin{lstlisting}[language=C]
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}
\end{lstlisting}
\end{marginlisting}
\lipsum[1]
\end{document}
Expected behavior:
Actual behavior: