2

With the command \showindexmarks the memoir class permits to show index marks in the margin of the document. With long index names, overlap of the mark with the document text occurs. Here is a MWE. How to avoid this overlap? Thank you!

\documentclass{memoir} \makeindex \showindexmarks \begin{document} Here is a minimal working example\index{MinimalWorkingExample@Example!Working!Minimal}. Here is a minimal working example. Here is a minimal working example. \newpage Here is a minimal working example\index{MinimalWorkingExample@Example!Working!Minimal}. Here is a minimal working example. Here is a minimal working example. \printindex \end{document} 

1 Answer 1

3

This uses \tiny but even that is not small enough so I use xurl package so that the string linebreaks to the margin width,

enter image description here

enter image description here

\documentclass{memoir} \usepackage{xurl} \makeindex \showindexmarks \makeatletter \renewcommand{\@showidx}[1]{% \insert\@indexbox{% \@sanitizeat \the\indexmarkstyle \hsize\marginparwidth \hangindent\marginparsep \parindent\z@ \everypar{}\let\par\@@par \parfillskip\@flushglue \lineskip\normallineskip \baselineskip .8\normalbaselineskip\sloppy \raggedright \leavevmode \vrule \@height .7\normalbaselineskip \@width \z@\relax \tiny\path{#1}\relax \vrule \@height \z@ \@depth .3\normalbaselineskip \@width \z@\relax }% \ifhmode\penalty\@M \hskip\z@skip\fi} \makeatother \begin{document} Here is a minimal working example\index{MinimalWorkingExample@Example!Working!Minimal}. Here is a minimal working example. Here is a minimal working example. \newpage Here is a minimal working example\index{MinimalWorkingExample@Example!Working!Minimal}. Here is a minimal working example. Here is a minimal working example. \printindex \end{document} 

A version that works with non-ascii characters and just breaks lines at ! and @

enter image description here

\documentclass{memoir} \usepackage{xurl} \usepackage[T1]{fontenc} \makeindex \showindexmarks \makeatletter \renewcommand{\@showidx}[1]{% \insert\@indexbox{% \@sanitizeat \the\indexmarkstyle \hsize\marginparwidth \hangindent\marginparsep \parindent\z@ \everypar{}\let\par\@@par \parfillskip\@flushglue \lineskip\normallineskip \baselineskip .8\normalbaselineskip\sloppy \raggedright \leavevmode \vrule \@height .7\normalbaselineskip \@width \z@\relax \catcode`\@\active\lccode`\~`\@\lowercase{\def~}{\string @\penalty10\relax}% \catcode`\!\active\lccode`\~`\!\lowercase{\def~}{\string !\penalty10\relax}% \tiny\scantokens{#1}\relax \vrule \@height \z@ \@depth .3\normalbaselineskip \@width \z@\relax }% \ifhmode\penalty\@M \hskip\z@skip\fi} \makeatother \begin{document} Here is a minimal working example\index{MinimalWörkingExamplé@Example!Working!Minimal}. Here is a minimal working example. Here is a minimal working example. \newpage Here is a minimal working example\index{MinimalWörkingExamplé@Example!Working!Minimal}. Here is a minimal working example. Here is a minimal working example. \printindex \end{document} 
4
  • Your solution is working fine with usual characters. But as I'm writing in french, I notice that if I use for example \index{Modele@Modèle!du point matériel}, I get "Modele@Modôlle!du point matÃl’riel" instead of "Modele@Modèle!du point matériel". Any idea how to correct this new error? Commented Jun 9 at 17:23
  • @Christophe ah utf-8 You could remove the \path command, and just keep the \tiny otherwise you would need a utf-8 safe way of linebreaking an arbitrary string, there are questions on site about that or I may answer later (I'll be driving in a bit, so coding tex linebreaking at the same time probably isn't legal) Commented Jun 9 at 18:22
  • @Christophe see update Commented Jun 9 at 21:24
  • Second solution is working fine as well. Commented Jun 10 at 8:41

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.