有没有办法改变列表中标题的样式,而无需caption
包(使其更小且不加粗)?我正在使用它\lstnewenvironment
来创建自己的自定义环境,然后通过这个新环境使用列表。
我尝试使用带有caption
包的方法来做这\captionsetup[lstlisting]{font={scriptsize,tt}}
件事,并且成功了,但问题是我不能使用caption
包,因为它会弄乱文档其余部分的标题(只要我“包含”它),所以我必须使用预定义的类。
感谢您的帮助!
(编辑)类别:http://www.acm.org/sigs/publications/sig-alternate.cls
(编辑)MEW:
\documentclass{sig-alternate}
%\usepackage{caption}
\usepackage{listings}
\begin{document}
\title{The Title}
\numberofauthors{1}
\author{
\alignauthor
John Doe\\
\affaddr{Lorem ispum}\\
\affaddr{Lorem ispum}\\
\affaddr{Lorem ipsum}\\
\email{[email protected]}
}
\date{30 July 1999}
\maketitle
\lstnewenvironment{mycode}[1][]
{
\minipage[b]{0.3\textwidth}
\lstset{
captionpos=b,
language=C,
numbers=left,
basicstyle=\tiny\ttfamily,
columns=fullflexible,
showstringspaces=false,
numbersep=3pt,
#1
}
}
{
\endminipage
}
%\captionsetup[lstlisting]{font={small,tt}}
\begin{mycode}[title=Awesome C program,label=code:AwesomeC]
int main(int argc, char* argv[]) {
return 0;
}
\end{mycode}
If I use "caption" package, caption of the figure changes style (it is no longer bold). Otherwise I cannot change caption of the code...
\begin{figure}
\centering
This is a figure
\caption{Caption of the figure}
\end{figure}
\end{document}
答案1
一种可能性是使用caption
包,但以表单形式加载
\usepackage[font=bf,skip=\baselineskip]{caption}
以保留sig-alternate
文档类实现的默认标题样式。然后您可以调用
\captionsetup[lstlisting]{font={small,tt}}
更改列表标题格式。完整示例:
\documentclass{sig-alternate}
\usepackage{listings}
\usepackage[font=bf,skip=\baselineskip]{caption}
\captionsetup[lstlisting]{font={small,tt}}
\lstnewenvironment{mycode}[1][]
{
\minipage[b]{0.3\textwidth}
\lstset{
captionpos=b,
language=C,
numbers=left,
basicstyle=\tiny\ttfamily,
columns=fullflexible,
showstringspaces=false,
numbersep=3pt,
#1
}
}
{
\endminipage
}
\begin{document}
\title{The Title}
\numberofauthors{1}
\author{
\alignauthor
John Doe\\
\affaddr{Lorem ispum}\\
\affaddr{Lorem ispum}\\
\affaddr{Lorem ipsum}\\
\email{[email protected]}
}
\date{30 July 1999}
\maketitle
\begin{mycode}[title=Awesome C program,label=code:AwesomeC]
int main(int argc, char* argv[]) {
return 0;
}
\end{mycode}
\begin{figure}
\centering
This is a figure
\caption{Caption of the figure}
\end{figure}
\begin{table}
\centering
This is a table
\caption{Caption of the table}
\end{table}
\end{document}