I would ask if it is possible to set a global option to prevent line break before a specific character, in my case – (especially in the index).
In my index formatted in a single paragraph I use – as a delimiter and it is often printed at the beginning of the line.
I refer to the index as defined in the answer to this question: idxlayout customized delimiters.
Here is an MWE:
\documentclass{article}
\usepackage{fontspec}
\setmainfont{times.ttf}
\usepackage{imakeidx}
\usepackage{polyglossia}
\begin{filecontents*}{colon.ist}
delim_0 ": "
delim_1 ": "
delim_2 ": "
\end{filecontents*}
\usepackage[itemlayout=singlepar]{idxlayout}
\makeatletter
\def\@idxitem{\par\addvspace{5\p@ \@plus 5\p@ \@minus 3\p@}\hangindent 40\p@}
\def\subitem{\par\hangindent 40\p@ \hspace*{20\p@}}
\def\subsubitem{\par\hangindent 40\p@ \hspace*{30\p@}}
\def\indexspace{}
\patchcmd\theindex{\indexname}{\indexname\vspace{12pt}}{}{}
\makeatother
\makeatletter
\newif\iffirstsubitem
\newif\iffirstsubsubitem
\renewcommand{\indexsubsdelim}{ }
\newcommand*{\indexsubsdelimb}{\iffirstsubsubitem\unskip\firstsubsubitemfalse\ \else --- \fi}
\renewcommand{\subitem}{\iffirstsubitem\unskip\firstsubitemfalse, \else --- \fi\firstsubsubitemtrue}%
\renewcommand{\subsubitem}{\indexsubsdelimb}%
\renewcommand{\@idxitem}{\par\setlength{\hangindent}{\ila@hangindent}\firstsubitemtrue}
\makeatother
\makeindex[options=-s colon]
\begin{document}
test
\index{Author!Work1!1,11}
\index{Author!Work1!9,31}
\index{Author!Work2!2,21}
\index{Author!Work2!5,12}
\index{Author!Work1!1,11}
\index{Author!Work1!9,34}
\index{Author!Work2!2,22}
\index{Author!Work2!5,15}
\index{Author!Work1!1,17}
\index{Author!Work1!9,38}
\index{Author!Work2!2,27}
\index{Author!Work2!5,14}
\index{Author2!2,45}
\index{Author2!4,34}
\index{Author2!6,12}
\index{Author2!9,4}
\index{Author2!2,41}
\index{Author2!4,32}
\index{Author2!6,13}
\index{Author2!9,5}
\index{Author2!2,46}
\index{Author2!4,37}
\index{Author2!6,18}
\index{Author2!9,9}
\printindex
\end{document}
I think that it muset be changed here:
\newcommand*{\indexsubsdelimb}{\iffirstsubsubitem\unskip\firstsubsubitemfalse\ \else --- \fi}
and here:
\newcommand*{\indexsubsdelimb}{\iffirstsubsubitem\unskip\firstsubsubitemfalse\ \else --- \fi}
Thank you!
~(unbreakable space) be feasible? – barbara beeton Apr 08 '20 at 20:33.istfile involved, that's where I would look, but I'm not sufficiently experienced in that to be much help. If you put that information, at least the link to the earlier question, in the question itself, someone else can pick it up. – barbara beeton Apr 08 '20 at 22:29\newcommand*{\indexsubsdelimb}{ — }use a non break space\newcommand*{\indexsubsdelimb}{~— }– David Carlisle Apr 08 '20 at 23:03