hyphenation{} does not work in Index in the first line and in \texttt.
How can I switch it on?
How can we prevent new column when the hyphenation is switched on?
Only Index settings of hyphenation are preferable.
The problem is discussed on the base of the following MWE:
Remove (delete) unexpected new line when the word in index is long (hyphenation)
\documentclass{memoir}
\usepackage{imakeidx}
\usepackage{blindtext}
\makeindex[program=makeindex,
options=-s myindex.ist,
title={First},
name=first]
%https://tex.stackexchange.com/a/392783/44348
\usepackage{tempora} %TemporaLGCUni of Times type
\usepackage{newtxmath} %math font of Times type
% need to set the monospace=typewritter font
%https://tex.stackexchange.com/questions/213835/using-many-typewriter-fonts-in-a-single-document
\makeatletter %load fonts for cmtt
\providecommand{\EC@ttfamily}[5]{%
\DeclareFontShape{#1}{#2}{#3}{#4}{
<-8.5>#50800
<8.5-9.5>#50900
<9.5-10.5>#51000
<10.5-11.5>#51095
<11.5-13>#51200
<13-15.5>#51440
<15.5-18.5>#51728
<18.5-22>#52074
<22-27>#52488
<27-32>#52986
<32->#53583}{}}
\DeclareFontFamily{T2A}{cmtt}{\hyphenchar\font\m@ne}
\EC@ttfamily{T2A}{cmtt}{m}{n}{latt}
\EC@ttfamily{T2A}{cmtt}{m}{sl}{last}
\EC@ttfamily{T2A}{cmtt}{m}{it}{lait}
\EC@ttfamily{T2A}{cmtt}{m}{sc}{latc}
\DeclareFontShape{T2A}{cmtt}{bx}{n}%
{<->ssub*cmtt/m/n}{}
\DeclareFontShape{T2A}{cmtt}{bx}{it}%
{<->ssub*cmtt/m/it}{}
\makeatletter
\renewcommand{\ttdefault}{cmtt}
% https://tex.stackexchange.com/a/132415/44348
\makeatletter
% we don't want a page break before a subitem
\renewcommand\subitem{\@idxitem\nobreak\hspace*{20\p@}}
\makeatother
%does not work
%\hyphenation{foofoofoo-foofoofoo-foofoofoo-foofoofoofoofo-ofoofoofoo-foo}
\hyphenation{barbarbar-barbarbarbar-barbarbarbarbarbar-barbarbarbarbar}
\hyphenation{Diag-nos-tic-Tests-Sca-ling-And-In-fer-ring}
\begin{document}
Einstein\index[first]{Einstein\-EinsteinEinstein\-Einstein\-Einstein!NewLine}
Heisenberg\index[first]{Heisenberg} % Person index
\blindtext
barbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbar barbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbar
\blindtext[4]
Einstein\index[first]{Einstein\-EinsteinEinstein\-Einstein\-Einstein!NewLine}
\index[first]{foofoofoofoo\-foofoofoofoofoofoo\-foofoofoofoofoo\-foofoofoo}
\index[first]{barbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbar}
% \index[first]{algorithm!barbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbar}
%\index[first]{barbarbar\-barbarbarbar\-barbarbarbarbarbar\-barbarbarbarbar}
\index[first]{algorithm!\texttt{DiagnosticTestsScalingAndInferring}}
\blindtext
\printindex[first]
\end{document}
UDT
Additional question "How to force word Newline after Einstein not to go to the next column?" can be solved using this answer
https://tex.stackexchange.com/a/132415/44348
However with these commands "last" Einstein go to the new line.


!). You want to prevent breaks between item and subitem. The answer is here: https://tex.stackexchange.com/a/132415/2388. And please don't ask two questions at once. – Ulrike Fischer Oct 04 '17 at 08:56\texttt, you can comment it if you wish. The problem with\hyphenation{barbar...}still take place. – Vladimir Parkhomenko Oct 04 '17 at 09:04\textttworks fine with local hyphenation\-. – Vladimir Parkhomenko Oct 04 '17 at 09:08\relaxthis requirement? – Vladimir Parkhomenko Oct 04 '17 at 09:14\renewcommand{\@idxitem}{\par\hangindent40\p@\hspace{0pt}\ignorespaces}– egreg Oct 04 '17 at 10:40