如何设置上方的空间\mylisting
以及字体大小设置是否正确?谢谢
\documentclass[12pt,a4paper]{report}
\usepackage[most]{tcolorbox}
\newtcbinputlisting[auto counter,list inside=lol,list type={lstlisting}]{\mylisting}[3][]{%
listing file={#3},
title=Listing,
colback=white,
colframe=gray!75!black,
fonttitle=\bfseries,
listing only,
breakable,
title={Soubor \thetcbcounter: #2},
#1
}
\newcommand{\listingsfont}{\ttfamily}
\begin{document}
\begin{footnotesize}
\mylisting[label=h]{h}{h.txt}
\end{footnotesize}
\end{document}
答案1
中的字体listings
由等控制basicstyle
。由于问题使用了listings
的库tcolorbox
,因此必须将样式listing option={basicstyle={...}}
作为宏的选项给出\mylisting
。
\documentclass[12pt,a4paper]{report}
\usepackage{caption}
\newcommand{\lstlistingname}{Soubor}
\newcommand{\listingsfont}{\ttfamily}
\usepackage[most]{tcolorbox}
\newtcbinputlisting[auto counter,list inside=lol,list type={lstlisting}]{\mylisting}[3][]{%
listing file={#3},
listing options={basicstyle=\footnotesize\listingsfont},
colback=white,
colframe=gray!75!black,
listing only,
fonttitle=\bfseries,
breakable,
title={Soubor \thetcbcounter: #2},
#1
}
\begin{document}
\mylisting[label=foo]{Some caption}{helloworldexample.c}
\end{document}
该文件helloworldexample.c
可以找到这里(实际上,这个问题是一个后续问题!)