Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm using the listings package and would like to translate the caption text displayed to Spanish, so instead of Listing 1: Dummy label it will display Listado 1: Dummy label.

This is my code:

\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}
share|improve this question
add comment

2 Answers 2

up vote 6 down vote accepted

We can redefine \lstlistingname which is the caption label for listings:

\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}

Listing

Hope it helps. :)

share|improve this answer
add comment

Try \newcaptionname from the scrbase package. Minimal example:

\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}

Using \newcaptionname, you can simultaneously provide translations for all languages supported by the babel package.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.