0

I am trying to write a rather long index. But it does not split at the end of the page... It goes through the margin and even further.

Does any one know how to do this ?

Here is my code and the result :

enter image description here

\documentclass[12pt,twoside]{book}
\usepackage[paperheight=240mm,paperwidth=160mm, left=22mm, right = 20mm, top = 20mm, bottom = 22mm]{geometry}

\usepackage[cam,width=17.5truecm,height=25.54truecm,center,dvips,noinfo]{crop}
\usepackage[french]{babel}

\usepackage{fontspec}
\usepackage{xltabular}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{lipsum}
\usepackage[newparttoc]{titlesec}%
\usepackage{titletoc}
\usepackage{supertabular}
\usepackage{xcolor}
\definecolor{gray}{HTML}{BCBDC0}
\definecolor{white}{HTML}{FFFFFF}
\usetikzlibrary{positioning,shapes.misc}
\usepackage{emptypage}



\newcounter{subpara}
\setcounter{subpara}{0}
\newcommand\numsubpara[1]{\vspace{0.5cm}\par\refstepcounter{subpara} \fontsize{10}{12}\selectfont \thesubpara. \fontsize{12}{12}\selectfont \space#1\space\vspace{0.3cm}\\  \fontsize{12}{12}\selectfont}


\usepackage{multicol}
\setlength{\columnsep}{0.6cm}


\usepackage{imakeidx}
\indexsetup{othercode=\footnotesize}

\renewcommand*{\seename}{V.}
\renewcommand*{\alsoname}{V. aussi}

\makeatletter
\renewcommand\@idxitem{\par}
\renewcommand\subitem{}
\newcommand{\maybeadddot}{\@ifnextchar.{}{.}}
\newcommand{\Index}[1]{\imki@wrindexentry{MyIndex}{#1}{\thesubpara}}
\renewcommand{\indexname}{}
\makeatother

\makeindex[name=MyIndex, options= -s alphab.ist]%

\indexsetup{
  %level=\chapter,% <-- already default
  othercode={%
    \thispagestyle{alphab-title}%
    \small\raggedright}
}


\begin{document}

\numsubpara{title6}
\Index{É}
\Index{e23@é23}

\Index{B}
\Index{B1}
\Index{B2}
\Index{B3}
\Index{B4}
\Index{B5}
\Index{B6}
\Index{B7}
\Index{B8}
\Index{B9}
\Index{C1}\Index{C2}\Index{C3}\Index{C4}\Index{C5}
\Index{D1}\Index{D2}\Index{D3}\Index{C4}\Index{D5}
\Index{E1}\Index{E2}\Index{E3}\Index{E4}\Index{E5}
\Index{F1}\Index{F2}\Index{F3}\Index{F4}\Index{F5}
\Index{G1}\Index{G2}\Index{G3}\Index{G4}\Index{G5}
\Index{H1}\Index{H2}\Index{H3}\Index{H4}\Index{H5}
\Index{I1}\Index{I2}\Index{I3}\Index{I4}\Index{I5}
\Index{J1}\Index{J2}\Index{J3}\Index{J4}\Index{J5}
\Index{K1}\Index{K2}\Index{K3}\Index{K4}\Index{K5}
\Index{L1}\Index{L2}\Index{L3}\Index{L4}\Index{L5}

\newpage
\setlength{\columnsep}{-9.6cm}
\begin{multicols}{2}
\printindex[MyIndex]
\end{multicols}
\setlength{\columnsep}{0.6cm}

\end{document}

EDIT : my code displaying a unwanted newpage

\cleardoublepage
\newpage

\addtocontents{toc}{\fontsize{12.5}{12}\selectfont Table alphabétique \enspace\hfill \fontsize{8}{12}\selectfont \mdseries\thepage\vspace{0.2cm} \\}


\parbox{\linewidth}{\fontsize{18}{12}\selectfont \centerline{TABLE ALPHABÉTIQUE}~\\[-0.5cm]\centerline{\fontsize{7}{12}\selectfont \itshape{Les chiffres renvoient aux num\'eros de paragraphe}}}
\vspace{-3.5cm}

\printindex[MyIndex]



\cleardoublepage
\newpage
2
  • Negative \columnsep? And why multicols around \printindex?
    – egreg
    May 8, 2020 at 12:05
  • I do not precisely remember why I've used multicols... I guess it was because at first my index was not displayed with 2 columns? And then the negative \columnsepwas the value in order to get a well looking index with two proper columns... But yes it might not be the best solution at all !
    – Guliup
    May 8, 2020 at 12:56

1 Answer 1

1

I'm not sure why you would do multicols around \printindex.

Change the code

\newpage
\setlength{\columnsep}{-9.6cm}
\begin{multicols}{2}
\printindex[MyIndex]
\end{multicols}
\setlength{\columnsep}{0.6cm}

into

\printindex[MyIndex]

and you'll be OK.

enter image description here

In order to set the title of the index, you don't want to do it by hand:

\documentclass[12pt,twoside]{book}
\usepackage[
  paperheight=240mm,
  paperwidth=160mm,
  left=22mm,
  right = 20mm,
  top = 20mm,
  bottom = 22mm,
]{geometry}

\usepackage[cam,width=17.5truecm,height=25.54truecm,center,dvips,noinfo]{crop}
\usepackage[french]{babel}

\usepackage{fontspec}
\usepackage{xltabular}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{lipsum}
\usepackage[newparttoc]{titlesec}
\usepackage{titletoc}
\usepackage{supertabular}
\usepackage{xcolor}
\usepackage{multicol}
\usepackage{emptypage}
\usepackage{imakeidx}

\definecolor{gray}{HTML}{BCBDC0}
\definecolor{white}{HTML}{FFFFFF}
\usetikzlibrary{positioning,shapes.misc}

\newcounter{subpara}
\setcounter{subpara}{0}
\newcommand\numsubpara[1]{%
  \par\addvspace{0.5cm}
  \refstepcounter{subpara}%
  {\small\thesubpara.}#1\par
  \addvspace{0.3cm}%
}

\setlength{\columnsep}{0.6cm}


\renewcommand*{\seename}{V.}
\renewcommand*{\alsoname}{V. aussi}

\makeatletter
\renewcommand\@idxitem{\par}
\renewcommand\subitem{}
\newcommand{\maybeadddot}{\@ifnextchar.{}{.}}
\newcommand{\Index}[1]{\imki@wrindexentry{MyIndex}{#1}{\thesubpara}}
\renewcommand{\indexname}{}
\makeatother

\makeindex[name=MyIndex, options= -s alphab.ist,title=Table Alphabétique,intoc]

\indexsetup{othercode=\small\raggedright}


\begin{document}

\numsubpara{title6}
\Index{É}
\Index{e23@é23}

\Index{B}
\Index{B1}
\Index{B2}
\Index{B3}
\Index{B4}
\Index{B5}
\Index{B6}
\Index{B7}
\Index{B8}
\Index{B9}
\Index{C1}\Index{C2}\Index{C3}\Index{C4}\Index{C5}
\Index{D1}\Index{D2}\Index{D3}\Index{C4}\Index{D5}
\Index{E1}\Index{E2}\Index{E3}\Index{E4}\Index{E5}
\Index{F1}\Index{F2}\Index{F3}\Index{F4}\Index{F5}
\Index{G1}\Index{G2}\Index{G3}\Index{G4}\Index{G5}
\Index{H1}\Index{H2}\Index{H3}\Index{H4}\Index{H5}
\Index{I1}\Index{I2}\Index{I3}\Index{I4}\Index{I5}
\Index{J1}\Index{J2}\Index{J3}\Index{J4}\Index{J5}
\Index{K1}\Index{K2}\Index{K3}\Index{K4}\Index{K5}
\Index{L1}\Index{L2}\Index{L3}\Index{L4}\Index{L5}

\printindex[MyIndex]

\end{document}

If you want to modify the appearance of the index title, use titlesec features. But I see no reason for it to be different from the other chapters.

5
  • Hello @egreg, thank you for your help. It's working great! The only thing is that the index is now starting on a new page, would it be possible to avoid this with your solution?
    – Guliup
    May 8, 2020 at 12:53
  • @Guliup Didn't you have \newpage? I don't understand. In the book class the index always starts on a new page, because it is a chapter of its own.
    – egreg
    May 8, 2020 at 13:09
  • No \newpage... See my code on my initial post, I have edited it accordingly.
    – Guliup
    May 8, 2020 at 17:54
  • @Guliup I added how to properly set the title.
    – egreg
    May 8, 2020 at 20:18
  • I have been using a specific parbox because my title was on two lines with different font sizes, that is why I have not directly used title=Table Alphabétique,intoc !
    – Guliup
    May 8, 2020 at 21:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .