# Replacing en-dash for hyphen in the index (makeindex)

I need to make a change in the index (not contents) of my book: I need to change the en-dash ("long" dash) for the hyphen ("short" dash) when an entry of the index covers a group of pages (I mean, from page A to page B). What I have is this

and I need to replace that dashes (long dashes) for hyphens (short dashes).

How can I do it?

EDIT: this is my preamble

\documentclass[reqno,twoside]{book}
\usepackage{imakeidx}
\usepackage[spanish,es-nosectiondot,es-lcroman]{babel}
\usepackage[utf8]{inputenc}
\usepackage{fontspec}
\usepackage{infwarerr}
\usepackage{xcolor}
\usepackage{geometry}
\usepackage{amssymb,amsmath,amsthm}
\usepackage{epsfig,graphicx,psfrag,float}
\usepackage[format=hang,labelsep=quad]{caption}%Configura el caption de las figuras
\usepackage{geometry}
\usepackage{ltxcmds}
\usepackage[all]{xy}
\usepackage{fancyhdr}
\usepackage[explicit,compact]{titlesec}
\usepackage{titlesec}
\usepackage{sectsty}
\usepackage{enumerate}
\usepackage{enumitem}%Paquete para crear listas (enumerate, itemize) personalizadas
\usepackage{hyperref}
\usepackage{multicol}
\usepackage[many]{tcolorbox}
\usepackage{lettrine}
\usepackage{caption}
\usepackage{pdfpages}
\usepackage{setspace}
\usepackage[titletoc,toc,page]{appendix}
\usepackage{titletoc}
\usepackage[titles]{tocloft}%"titles" permite cambiar tocloft con los comandos latex estándar para los títulos
\usepackage{natbib}%Paquete para citaciones
\usepackage{emptypage}
%\usepackage{etoolbox}
\makeindex%[name=Índice analítico,columns=2]
%\makeindex[columns=2]
.
.
.
\begin{document}
.
.
.
\include{Index}
\printindex
.
.
.
\end{document}


As you can see, I tried to use the imakeidx package but I didn't do it.

• Typographically, this is heresy! B;t.w. the long dash is the emdash, not the endash. – Bernard Sep 10 '17 at 22:30
• Ok, Bernard. I'm sorry for my mistake. I need to change that "long" dash for the "short" dash. How can I do it? – Fabio Sep 10 '17 at 23:08
• You should post a minimal working example. In particular which tools do you use for your index? Makeindex, xindy? Which packages? – Bernard Sep 10 '17 at 23:36
• having both \include{Index} and \printindex would duplicate the index, assuming that the file named Index.tex is present. but it wouldn't be created by imakeidx. what imakeidx does create is an .idx file, which is then sent through the makeindex program to create an .ind file, which is read in directly with the \printindex command. the -- is inserted into the page spans by the makeindex program. i believe this can be modified by an .ist file, but you haven't provided any real data that can be used to experiment. – barbara beeton Sep 11 '17 at 1:20
• Dear Barbara. What kind of data could I give you for experimenting? I mean, if the index is made of the references that I put in the whole book (each chapter in a different .tex file), how could provide to you something that you can use for experimenting? I'm asking for a way to print the hyphen instead of em-dash in the index. How could I do it with an .ist file and how do I create that file? – Fabio Sep 11 '17 at 3:00

You have to use an index style file. This usually has the extension .ist. There you can set the range delimiter with delim_r. For simpler processing I use imakeidx.

\begin{filecontents*}{\jobname.ist}
delim_r "-"
\end{filecontents*}

\documentclass{article}

\usepackage{imakeidx}
\makeindex[options=-s \jobname.ist]

\begin{document}

Hello World!\index{Foo}\newpage
Hello World!\index{Foo}\newpage
Hello World!\index{Foo}\newpage
Hello World!\index{Foo}\newpage

\printindex

\end{document}


• Hi, Henry. I did what you suggested and I got an error message: '! LaTeX Error: Missing \begin{document}. See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ... l.468 \makeindex[ program=makeindex,name=Índice analítico,options=-s Algebr... You're in trouble here. Try typing <return> to proceed. If that doesn't work, type X <return> to quit.' I don't understand why. – Fabio Sep 11 '17 at 3:34
• @Fabio Did this happen with the exact example I posted? (it doesn't look like it) If you have a follow-up question, just make a minimal working example (MWE) and ask a new question. – Henri Menke Sep 11 '17 at 3:57
• No, it doesn't happend with your example. What I mean is that I included the options for \makeindex and I got the error message. If I don't use the options for \makeindex the error message doesn't appear. In both cases I loaded the imakeidx package. I don't understand why is this happening. – Fabio Sep 11 '17 at 4:18
• Hi, Henry. Finally I could solve the problem. The problem was that I put the option name=whatever. When I erased it, the code worked perfectly!!!! Thanks for your help. – Fabio Sep 11 '17 at 5:21