带有西班牙语标题图例的列表包

带有西班牙语标题图例的列表包

我正在使用该listings包,并希望将显示的标题文本翻译成西班牙语,因此Listing 1: Dummy label它将显示Listado 1: Dummy label

这是我的代码:

\documentclass[11pt]{article}   % list options between brackets
\usepackage[spanish]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{hyperref} %Links
\usepackage{verbatim}
\usepackage{listings}
\lstset{ %
%  language=Octave,                % the language of the code
  basicstyle=\scriptsize,           % the size of the fonts that are used for the code
  frame=single,                   % adds a frame around the code
  breaklines=true,                % sets automatic line breaking
  breakatwhitespace=false,        % sets if automatic breaks should only happen at whitespace
  escapeinside={\%*}{*)},            % if you want to add LaTeX within your code
  extendedchars=true,
}



\begin{document}

\begin{lstlisting}[caption=Evento celebrado en días no consecutivos]
{
"identificador" : "22587"
"nombre" : "Visita guiada para conocer las aves del Botanico"
"descripcion" : "... Los domingos 8 de julio, 12 de agosto y 9 de septiembre (a las 10.30 horas) ..."
"dia-de-inicio" : "2012-07-08 10:30:00 +0200"
"dia-de-fin" : "2012-09-09 10:30:00 +0200"
}
\end{lstlisting}


\end{document}

答案1

我们可以重新定义\lstlistingname列表的标题标签:

\documentclass[11pt]{article}   % list options between brackets

\usepackage[spanish]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{hyperref} %Links
\usepackage{verbatim}
\usepackage{listings}

\renewcommand{\lstlistingname}{Listado}

\lstset{ %
%  language=Octave,                % the language of the code
  basicstyle=\scriptsize,           % the size of the fonts that are used for the code
  frame=single,                   % adds a frame around the code
  breaklines=true,                % sets automatic line breaking
  breakatwhitespace=false,        % sets if automatic breaks should only happen at whitespace
  escapeinside={\%*}{*)},            % if you want to add LaTeX within your code
  extendedchars=true,
}  

\begin{document}

\begin{lstlisting}[caption=Evento celebrado en días no consecutivos]
{
"identificador" : "22587"
"nombre" : "Visita guiada para conocer las aves del Botanico"
"descripcion" : "... Los domingos 8 de julio, 12 de agosto y 9 de septiembre (a las 10.30 horas) ..."
"dia-de-inicio" : "2012-07-08 10:30:00 +0200"
"dia-de-fin" : "2012-09-09 10:30:00 +0200"
}
\end{lstlisting}

\end{document}

清单

希望能帮助到你。:)

答案2

尝试\newcaptionnamescrbase包。最小示例:

\documentclass{article}

\usepackage[spanish]{babel}

\usepackage[utf8]{inputenc}

\usepackage{scrbase}

\usepackage{listings}

\newcaptionname{spanish}{\lstlistingname}{Listado}

\begin{document}

\begin{lstlisting}[caption={Evento celebrado en días no consecutivos}]
\end{lstlisting}

\end{document}

使用\newcaptionname,您可以同时提供该包支持的所有语言的翻译babel

相关内容