Latex中的列表样式列表

时间:2015-09-04 00:04:53

标签: latex


我尝试在我的乳胶文档

中创建列出我的代码片段的列表
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{minted}
\usepackage{listings}
\renewcommand\lstlistingname{Code}
\renewcommand\lstlistlistingname{List of code snippets}

\title{Code Listing}

\begin{document}

\maketitle

\section{Code examples}

\begin{listing}
\begin{minted}
[
frame=lines,
framesep=2mm,
baselinestretch=1.2,
fontsize=\footnotesize,
linenos
]
{python}
import numpy as np

def incmatrix(genl1,genl2):
    m = len(genl1)
    n = len(genl2)
    M = None #to become the incidence matrix
    VT = np.zeros((n*m,1), int)  #dummy variable

    #compute the bitwise xor matrix
    M1 = bitxormatrix(genl1)
    M2 = np.triu(bitxormatrix(genl2),1) 

    for i in range(m-1):
        for j in range(i+1, m):
            [r,c] = np.where(M2 == M1[i,j])
            for k in range(len(r)):
                VT[(i)*n + r[k]] = 1;
                VT[(i)*n + c[k]] = 1;
                VT[(j)*n + r[k]] = 1;
                VT[(j)*n + c[k]] = 1;

                if M is None:
                    M = np.copy(VT)
                else:
                    M = np.concatenate((M, VT), 1)

                VT = np.zeros((n*m,1), int)

    return M
\end{minted}
\caption{Example of code}
\label{lst:code1}
\end{listing}

\clearpage

\lstlistoflistings

\end{document}

我不知道为什么我的列表看起来像这样:

enter image description here

我的标题应该更改为代码1:代码示例

字幕解决方案

取代: \ renewcommand \ lstlistingname {代码}

的 \ renewcommand {\ listingscaption} {代码}

我看过很多帖子但仍未找到解决方案.. :(

我将不胜感激任何帮助

1 个答案:

答案 0 :(得分:2)

首先,应该在tex.stackexchange上询问这样的问题。

至于问题本身,你在这里混合两个包。 mintedlistings是分开的,因此后者的命令在前者的环境中奇怪地工作(从技术上讲,它们根本不应该工作,但我们正在谈论的是TeX)。根据{{​​1}}的{​​{3}},这就是你应该做的:

minted

结果:

docs

相关问题