1

I've been indexing latex with the imakeidx package. For this I have used the following code with a file .ist style.

Code

\documentclass[letterpaper,12pt,oneside]{book}
\usepackage{imakeidx}            
\usepackage{hyperref}
\usepackage{color}               % Requerido para colores específicos
\usepackage{colortbl}  
\usepackage[latin1]{inputenc}    % Teclado en español
\usepackage[spanish]{babel}      % Idioma del documento
\usepackage{calc}                     % espaciado en el index
\makeindex[options=-s StyleInd.ist] 

\begin{document}

the symbol \#\index{\#} should be in the the section "Símbolos".
And the number 9\index{9} should be in the sectiion "números"
Other index like tex\index{tex} was fine.


\addcontentsline{toc}{chapter}{Índice alfabético}
\printindex
\end{document}

StyleInd.ist:

delim_0 "\\dotfill\ "
delim_1 "\\dotfill\ "
headings_flag 1
heading_prefix "\\nopagebreak\n\\tikz\\node at (0pt,0pt) [draw=none,line width=1pt,inner sep=5pt]{\\parbox{\\linewidth-2\\fboxsep-2\\fboxrule-2pt}{\\centering\\large\\sffamily\\bfseries\\textcolor{white}{" heading_suffix "}}};\\vspace*{0.2cm}\\nopagebreak\n"

However, the name of the sections of the indexes appears in English and I need them in Spanish. As the other sections of the index appear with letters, I only need to change the language for the section name "symbols" and "numbers".

Thanks, and sorry for my english

  • 1
    Welcome to TeX.SE. By the way, the package hyperref had to be loaded lat in preamble (exceptional in some rare circumstances, which are not in your case). – Zarko Feb 13 '17 at 2:48
  • You example does not compile. – user31729 Feb 13 '17 at 6:58
  • By the way, I don't see sections, but try to load babel before imakeidx – user31729 Feb 13 '17 at 13:00
2

The names "Symbols" and "Numbers" are defined by the Makeindex style variables symhead_positive and symhead_negative. Add them to the .ist file:

symhead_positive "S\\'imbolos"
numhead_positive "N\\'umeros"

Also, the code sample of the question prints the headings with color white on the white default background. Maybe the contents of heading_prefix needs an update or the code sample is not complete.

Full example with some guessing and some fixes. In addition, the dependencies on packages tikz and calc are removed, and the calculation is performed using e-TeX's \dimexpr.

% The default definition of environment "filecontents" does not
% overwrite an existing file.
% package "filecontents" redefines the environment in a way that it
% always writes the file.

% \RequirePackage{filecontents}

\begin{filecontents*}{StyleInd.ist}
delim_0 "\\dotfill\ "
delim_1 "\\dotfill\ "
headings_flag 1
heading_prefix "
  \\begingroup
    \\setlength{\\fboxsep}{5pt}%
    \\colorbox{blue}{%
      \\color{white}\\large\\sffamily\\bfseries
      \\hbox to \\dimexpr\\linewidth-2\\fboxsep{%
        \\hfill "
heading_suffix "\\hfill
      }%
    }%
    \\nopagebreak\\vspace{2mm}%
  \\endgroup\n"
symhead_positive "S\\'imbolos"
numhead_positive "N\\'umeros"
\end{filecontents*}


\documentclass[letterpaper,12pt,oneside]{book}
\usepackage{imakeidx}
\usepackage{color}               % Requerido para colores específicos
\usepackage[utf8]{inputenc}    % Teclado en español
\usepackage[spanish]{babel}      % Idioma del documento
\usepackage{csquotes}
\usepackage{calc}                     % espaciado en el index
\makeindex[options=-s StyleInd.ist]
\usepackage{hyperref}

\begin{document}

\tableofcontents
\newpage

The symbol \#\index{\#} should be in the the section \enquote{Símbolos}
and the number 9\index{9} should be in the sectiion \enquote{números}.
Other index like tex\index{tex} was fine.

\clearpage
\phantomsection
\addcontentsline{toc}{chapter}{Índice alfabético}
\printindex
\end{document}

The index page:

Page 3

  • How do you change the \colorboxes to rounded corner? – xxx--- May 30 '17 at 3:38
  • 1
    @pushpen.paul In short, packages like tcolorbox or TikZ help. – Heiko Oberdiek May 30 '17 at 5:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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