4

I am currently doing a very long document in LaTeX (my thesis), and the structure of the document I'm writing the number Appendix fifteen, but as we know in Spanish the number letter fifteen is the ñ, then to compile I get an error, I tried have a minimum document if suddenly is a mistake of the document and I went out the same error. I am using TeX Live 2014

the error is:

Extra \ or. ... {\ 'E} index 15} {33} {Appendix.alph1.Alph15}
Something's wrong - Perhaps a missing \ item. ... {\ 'E} index 15} {33} {Appendix.alph1.Alph15}
Missing} inserted. ... {\ 'E} index 15} {33} {Appendix.alph1.Alph15}
Extra \ else. ... {\ 'E} index 15} {33} {Appendix.alph1.Alph15}
Something's wrong - Perhaps a missing \ item. ... {\ 'E} index 15} {33} {Appendix.alph1.Alph15}
Missing} inserted. ... {\ 'E} index 15} {33} {Appendix.alph1.Alph15}

and more detail that line is in the .toc

\ contentsline {chapter} {Ap \ '{e} index \ numberline {\ ~ N} ap \ IeC {\' e} index 15} {33} {Appendix.alph1.Alph15}

How do I remove this error because I need to do this appendix, I annex the minimum document also gives me error:

\documentclass[10pt,letterpaper,spanish]{book}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{babel}
\usepackage[title, titletoc,page]{appendix}
\usepackage{graphicx}
\usepackage{hyperref}
\begin{document}
\frontmatter
\tableofcontents
\mainmatter
\chapter{capitulo 1}
\appendix
\chapter{apéndice 1}
\chapter{apéndice 2}
\chapter{apéndice 3}
\chapter{apéndice 4}
\chapter{apéndice 5}
\chapter{apéndice 6}
\chapter{apéndice 7}
\chapter{apéndice 8}
\chapter{apéndice 9}
\chapter{apéndice 10}
\chapter{apéndice 11}
\chapter{apéndice 12}
\chapter{apéndice 13}
\chapter{apéndice 14}
\chapter{apéndice 15}
\end{document}
  • this is not tested, and it's a bit of a hack, but if you add one to the chapter counter just after appendix 14, that should skip over the ñ at the cost of having an odd result if you ever want to refer to the later appendices numerically instead of alphabetically. – barbara beeton Jan 6 '15 at 22:41
6

The problem is located in the redefinition of \numberline in spanish.ldf (2014/04/24 v5.0n):

\def\numberline#1{%
  \hb@xt@\@tempdima{%
    #1%
    \if&#1&\else.\fi
    \hfil
  }%
}

#1 contains a number (or not). The test \if&#1& expands the number. If #1 is empty or expands to nothing, then the following dot is suppressed. However this expansion is done the hard way without respecting LaTeX's protection mechanisms. Therefore the robust (in the LaTeX sense) macro \~ of the number \~N breaks in the hard expansion.

The following rewrite of the test expands the number inside \protected@edef, an expansion, which respects LaTeX's protection mechanisms. Then the defined macro \@temp@num is compared with the empty macro \@empty without further expansion.

\makeatletter
\renewcommand*{\numberline}[1]{%
  \hb@xt@\@tempdima{%
    #1%
    \protected@edef\@temp@num{#1}%
    \ifx\@temp@num\@empty\else .\fi
    \hfil
  }%
}   
\makeatother

The full example:

\documentclass[10pt,letterpaper,spanish]{book}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{babel}
\usepackage[title, titletoc,page]{appendix}
\usepackage{graphicx}
\usepackage{hyperref}

\makeatletter
\renewcommand*{\numberline}[1]{%
  \hb@xt@\@tempdima{%
    #1%
    \protected@edef\@temp@num{#1}% 
    \ifx\@temp@num\@empty\else .\fi
    \hfil
  }%
}
\makeatother

\begin{document}
\frontmatter
\tableofcontents
\mainmatter
\chapter{capitulo 1}
\appendix
\chapter{apéndice 1}
\chapter{apéndice 2}
\chapter{apéndice 3}
\chapter{apéndice 4}
\chapter{apéndice 5}
\chapter{apéndice 6}
\chapter{apéndice 7}
\chapter{apéndice 8}
\chapter{apéndice 9} 
\chapter{apéndice 10}
\chapter{apéndice 11}
\chapter{apéndice 12}
\chapter{apéndice 13}
\chapter{apéndice 14}
\chapter{apéndice 15}
\end{document}

There is room for improvements:

  • T1 encoding, see David's answer.
  • Font family Latin Modern, a successor of Computer Modern.
  • Package bookmark. Then the bookmarks are faster updated and more features.
  • The final example also uses numbered bookmarks.

The full example:

\documentclass[10pt,letterpaper,spanish]{book}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{babel}
\usepackage[title, titletoc,page]{appendix}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{bookmark}
\bookmarksetup{numbered, open}

\makeatletter
\renewcommand*{\numberline}[1]{%
  \hb@xt@\@tempdima{%
    #1%
    \protected@edef\@temp@num{#1}%
    \ifx\@temp@num\@empty\else .\fi
    \hfil
  }%
}
\makeatother

\begin{document}
\frontmatter
\tableofcontents
\mainmatter
\chapter{capitulo 1}
\appendix
\chapter{apéndice 1}
\chapter{apéndice 2}
\chapter{apéndice 3}
\chapter{apéndice 4}
\chapter{apéndice 5}
\chapter{apéndice 6}
\chapter{apéndice 7}
\chapter{apéndice 8}
\chapter{apéndice 9}
\chapter{apéndice 10}
\chapter{apéndice 11}
\chapter{apéndice 12}
\chapter{apéndice 13}
\chapter{apéndice 14}
\chapter{apéndice 15}
\end{document}
| improve this answer | |
  • I have sent a bug report to the maintainer of spanish.ldf. – Heiko Oberdiek Jan 6 '15 at 23:04
  • +1 nice digging (I just added T1 on a hunch and stopped there:-) – David Carlisle Jan 6 '15 at 23:43
  • thank you very much, charm me like you explained in the best way and besides being a complete explanation, all options served me, but Use of \usepackage[T1]{fontenc}. fontenc. Thanks for sending the bug to the packager. – carlitos9305 Jan 7 '15 at 1:45
  • Report received. Actually it's just a typo -- \if& should read \ifx& (no expansion intended here). But anyway using & as delimiter is not a good idea (very likely in this context it won't hurt, but it should be changed for something better). – Javier Bezos Jan 17 '15 at 18:42
4

You should probably report it to the babel maintainers but the error goes if you add

\usepackage[T1]{fontenc}

which is a good idea in any case as you will not get proper hyphenation of words with accented letters if you use the default OT1 encoding.

| improve this answer | |

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.