0

I would like to know how to print the first letter of index from the available index items of the current page in the right hand of the book (for odd page) and left hand of the book (for the even page).

The example is https://tex.stackexchange.com/a/94753/226890 (pages 433-468)

enter image description here

In addition, is it possible to print the first and the last index items of the current page on the very top (outside of margin, for instance)?

Below is the MWE I prepared:

\documentclass[twoside,openright]{book}

\usepackage{hyperref}
\hypersetup{colorlinks=true}
\usepackage{lipsum}
\usepackage{makeidx}
\makeindex

\begin{document}

\chapter[Introduction]{Introduction\footnote{taken from \url{https://en.wikipedia.org/wiki/LaTeX}}}
LaTeX\index{LaTeX} is\index{is} a\index{a} software\index{software} system\index{system} for\index{for} document\index{document} preparation\index{preparation}. When\index{When} writing\index{writing}, the\index{the} writer\index{writer} uses\index{uses} plain\index{plain} text\index{text} as\index{as} opposed\index{opposed} to\index{to} the\index{the} formatted\index{formatted} text\index{text} found\index{found} in\index{in} "What\index{What} You\index{You} See\index{See} Is\index{Is} What\index{What} You\index{You} Get\index{Get}" word\index{word} processors\index{processors} like\index{like} Microsoft\index{Microsoft} Word\index{Word}, LibreOffice\index{LibreOffice} Writer\index{Writer} and\index{and} Apple\index{Apple} Pages\index{Pages}. The\index{The} writer\index{writer} uses\index{uses} markup\index{markup} tagging\index{tagging} conventions\index{conventions} to\index{to} define\index{define} the\index{the} general\index{general} structure\index{structure} of\index{of} a\index{a} document\index{document} (such\index{such} as\index{as} article\index{article}, book\index{book}, and\index{and} letter\index{letter}), to\index{to} stylise\index{stylise} text\index{text} throughout\index{throughout} a\index{a} document\index{document} (such\index{such} as\index{as} bold\index{bold} and\index{and} italics\index{italics}), and\index{and} to\index{to} add\index{add} citations\index{citations} and\index{and} cross-references\index{cross-references}. A\index{A} TeX\index{TeX} distribution\index{distribution} such\index{such} as\index{as} TeX\index{TeX} Live\index{Live} or\index{or} MiKTeX\index{MiKTeX} is\index{is} used\index{used} to\index{to} produce\index{produce} an\index{an} output\index{output} file\index{file} (such\index{such} as\index{as} PDF\index{PDF} or\index{or} DVI\index{DVI}) suitable\index{suitable} for\index{for} printing\index{printing} or\index{or} digital\index{digital} distribution\index{distribution}.

LaTeX\index{LaTeX} is\index{is} widely\index{widely} used\index{used} in\index{in} academia\index{academia} for\index{for} the\index{the} communication\index{communication} and\index{and} publication\index{publication} of\index{of} scientific\index{scientific} documents\index{documents} in\index{in} many\index{many} fields\index{fields}, including\index{including} mathematics\index{mathematics}, statistics\index{statistics}, computer\index{computer} science\index{science}, engineering\index{engineering}, physics\index{physics}, economics\index{economics}, linguistics\index{linguistics}, quantitative\index{quantitative} psychology\index{psychology}, philosophy\index{philosophy}, and\index{and} political\index{political} science\index{science}. It\index{It} also\index{also} has\index{has} a\index{a} prominent\index{prominent} role\index{role} in\index{in} the\index{the} preparation\index{preparation} and\index{and} publication\index{publication} of\index{of} books\index{books} and\index{and} articles\index{articles} that\index{that} contain\index{contain} complex\index{complex} multilingual\index{multilingual} materials\index{materials}, such\index{such} as\index{as} Sanskrit\index{Sanskrit} and\index{and} Greek\index{Greek}. LaTeX\index{LaTeX} uses\index{uses} the\index{the} TeX\index{TeX} typesetting\index{typesetting} program\index{program} for\index{for} formatting\index{formatting} its\index{its} output\index{output}, and\index{and} is\index{is} itself\index{itself} written\index{written} in\index{in} the\index{the} TeX\index{TeX} macro\index{macro} language\index{language}.

LaTeX\index{LaTeX} can\index{can} be\index{be} used\index{used} as\index{as} a\index{a} standalone\index{standalone} document\index{document} preparation\index{preparation} system\index{system}, or\index{or} as\index{as} an\index{an} intermediate\index{intermediate} format\index{format}. In\index{In} the\index{the} latter\index{latter} role\index{role}, for\index{for} example\index{example}, it\index{it} is\index{is} sometimes\index{sometimes} used\index{used} as\index{as} part\index{part} of\index{of} a\index{a} pipeline\index{pipeline} for\index{for} translating\index{translating} DocBook\index{DocBook} and\index{and} other\index{other} XML\index{XML}-based\index{based} formats\index{formats} to\index{to} PDF\index{PDF}. The\index{The} typesetting\index{typesetting} system\index{system} offers\index{offers} programmable\index{programmable} desktop\index{desktop} publishing\index{publishing} features\index{features} and\index{and} extensive\index{extensive} facilities\index{facilities} for\index{for} automating\index{automating} most\index{most} aspects\index{aspects} of\index{of} typesetting\index{typesetting} and\index{and} desktop\index{desktop} publishing\index{publishing}, including\index{including} numbering\index{numbering} and\index{and} cross\index{cross}-referencing\index{referencing} of\index{of} tables\index{tables} and\index{and} figures\index{figures}, chapter\index{chapter} and\index{and} section\index{section} headings\index{headings}, the\index{the} inclusion\index{inclusion} of\index{of} graphics\index{graphics}, page\index{page} layout\index{layout}, indexing\index{indexing} and\index{and} bibliographies\index{bibliographies}.

Like\index{Like} TeX\index{TeX}, LaTeX\index{LaTeX} started\index{started} as\index{as} a\index{a} writing\index{writing} tool\index{tool} for\index{for} mathematicians\index{mathematicians} and\index{and} computer\index{computer} scientists\index{scientists}, but\index{but} even\index{even} from\index{from} early\index{early} in\index{in} its\index{its} development\index{development}, it\index{it} has\index{has} also\index{also} been\index{been} taken\index{taken} up\index{up} by\index{by} scholars\index{scholars} who\index{who} needed\index{needed} to\index{to} write\index{write} documents\index{documents} that\index{that} include\index{include} complex\index{complex} math\index{math} expressions\index{expressions} or\index{or} non\index{non}-Latin\index{Latin} scripts\index{scripts}, such\index{such} as\index{as} Arabic\index{Arabic}, Devanagari\index{Devanagri} and\index{and} Chinese\index{Chinese}.

LaTeX\index{LaTeX} is\index{is} intended\index{intended} to\index{to} provide\index{provide} a\index{a} high\index{high}-level\index{level}, descriptive\index{descriptive} markup\index{markup} language\index{language} that\index{that} accesses\index{accesses} the\index{the} power\index{power} of\index{of} TeX\index{TeX} in\index{in} an\index{an} easier\index{easier} way\index{way} for\index{for} writers\index{writers}. In\index{In} essence\index{essence}, TeX\index{TeX} handles\index{handles} the\index{the} layout\index{layout} side\index{side}, while\index{while} LaTeX\index{LaTeX} handles\index{handles} the\index{the} content\index{content} side\index{side} for\index{for} document\index{document} processing\index{processing}. LaTeX\index{LaTeX} comprises\index{comprises} a\index{a} collection\index{collection} of\index{of} TeX\index{TeX} macros\index{macros} and\index{and} a\index{a} program\index{program} to\index{to} process\index{process} LaTeX\index{LaTeX} documents\index{documents}, and\index{and} because\index{because} the\index{the} plain\index{plain} TeX\index{TeX} formatting\index{formatting} commands\index{commands} are\index{are} elementary\index{elementary}, it\index{it} provides\index{provides} authors\index{authors} with\index{with} ready\index{ready}-made\index{made} commands\index{commands} for\index{for} formatting\index{formatting} and\index{and} layout\index{layout} requirements\index{requirements} such\index{such} as\index{as} chapter\index{chapter} headings\index{headings}, footnotes\index{footnotes}, cross\index{cross}-references\index{references} and\index{and} bibliographies\index{bibliographies}.

LaTeX\index{LaTeX} was\index{was} originally\index{originally} written\index{written} in\index{in} the\index{the} early\index{early} 1980s\index{1980s} by\index{by} Leslie\index{Leslie} Lamport\index{Lamport} at\index{at} SRI\index{SRI} International\index{International}. The\index{The} current\index{current} version\index{version} is\index{is} LaTeX2e\index{LaTeX2e} (stylised\index{stylised} as\index{as} LATEX2\index{LATEX2}), released\index{released} in\index{in} 1994\index{1994}, but\index{but} updated\index{updated} in\index{in} 2020\index{2020}. LaTeX3\index{LaTeX3} (LATEX3\index{LATEX3}) has\index{has} been\index{been} under\index{under} long\index{long}-term\index{term} development\index{development} since\index{since} the\index{the} early\index{early} 1990s\index{1990s}. LaTeX\index{LaTeX} is\index{is} free\index{free} software\index{software} and\index{and} is\index{is} distributed\index{distributed} under\index{under} the\index{the} LaTeX\index{LaTeX} Project\index{Project} Public\index{Public} License\index{License} (LPPL\index{LPPL}).

\printindex

\end{document}

And here is the output example from one page in the index:

enter image description here

Any help would be greatly appreciated!

0

I don't know about your thumb index but with the memoir class (a superset of book, report and article) you can head the index pages with the first and last entries on the page, although it is not particularly straightforward.

enter image description here

% indexprob.tex  SE 583368

%\documentclass[twoside,openright]{book}
\documentclass[twoside,openright]{memoir}
\usepackage{comment}

\makepagestyle{index}
  \makeheadrule{index}{\textwidth}{\normalrulethickness}
  \makeevenhead{index}{\rightmark}{}{\leftmark}
  \makeoddhead{index}{\rightmark}{}{\leftmark}
  \makeevenfoot{index}{\thepage}{}{}
  \makeoddfoot{index}{}{}{\thepage}

\newcommand{\idxmark}\[1\]{#1\markboth{#1}{#1}}
\newcommand{\pdfbookmark}[2][]{}

\providecommand{\doidxbookmark}[1]{}
\renewcommand{\doidxbookmark}[1]{{\def\@tempa{Symbols}\def\@tempb{#1}%
  \centering\bfseries 
  \ifx\@tempa\@tempb %
    Analphabetics
    \pdfbookmark\[0\]{Analphabetics}{Analphabetics-idx}%
  \else
    #1%
    \phantomsection%
  \fi
  \vskip\onelineskip\par}}

\begin{comment}
\usepackage{hyperref}
\hypersetup{colorlinks=true}
\end{comment}

\usepackage{url}

\usepackage{lipsum}
\usepackage{makeidx}
\makeindex

\begin{document}

\chapter[Introduction]{Introduction\footnote{taken from \url{https://en.wikipedia.org/wiki/LaTeX}}}
LaTeX\index{LaTeX} is\index{is} a\index{a} software\index{software} system\index{system} for\index{for} document\index{document} preparation\index{preparation}. When\index{When} writing\index{writing}, the\index{the} writer\index{writer} uses\index{uses} plain\index{plain} text\index{text} as\index{as} opposed\index{opposed} to\index{to} the\index{the} formatted\index{formatted} text\index{text} found\index{found} in\index{in} "What\index{What} You\index{You} See\index{See} Is\index{Is} What\index{What} You\index{You} Get\index{Get}" word\index{word} processors\index{processors} like\index{like} Microsoft\index{Microsoft} Word\index{Word}, LibreOffice\index{LibreOffice} Writer\index{Writer} and\index{and} Apple\index{Apple} Pages\index{Pages}. The\index{The} writer\index{writer} uses\index{uses} markup\index{markup} tagging\index{tagging} conventions\index{conventions} to\index{to} define\index{define} the\index{the} general\index{general} structure\index{structure} of\index{of} a\index{a} document\index{document} (such\index{such} as\index{as} article\index{article}, book\index{book}, and\index{and} letter\index{letter}), to\index{to} stylise\index{stylise} text\index{text} throughout\index{throughout} a\index{a} document\index{document} (such\index{such} as\index{as} bold\index{bold} and\index{and} italics\index{italics}), and\index{and} to\index{to} add\index{add} citations\index{citations} and\index{and} cross-references\index{cross-references}. A\index{A} TeX\index{TeX} distribution\index{distribution} such\index{such} as\index{as} TeX\index{TeX} Live\index{Live} or\index{or} MiKTeX\index{MiKTeX} is\index{is} used\index{used} to\index{to} produce\index{produce} an\index{an} output\index{output} file\index{file} (such\index{such} as\index{as} PDF\index{PDF} or\index{or} DVI\index{DVI}) suitable\index{suitable} for\index{for} printing\index{printing} or\index{or} digital\index{digital} distribution\index{distribution}.

LaTeX\index{LaTeX} is\index{is} widely\index{widely} used\index{used} in\index{in} academia\index{academia} for\index{for} the\index{the} communication\index{communication} and\index{and} publication\index{publication} of\index{of} scientific\index{scientific} documents\index{documents} in\index{in} many\index{many} fields\index{fields}, including\index{including} mathematics\index{mathematics}, statistics\index{statistics}, computer\index{computer} science\index{science}, engineering\index{engineering}, physics\index{physics}, economics\index{economics}, linguistics\index{linguistics}, quantitative\index{quantitative} psychology\index{psychology}, philosophy\index{philosophy}, and\index{and} political\index{political} science\index{science}. It\index{It} also\index{also} has\index{has} a\index{a} prominent\index{prominent} role\index{role} in\index{in} the\index{the} preparation\index{preparation} and\index{and} publication\index{publication} of\index{of} books\index{books} and\index{and} articles\index{articles} that\index{that} contain\index{contain} complex\index{complex} multilingual\index{multilingual} materials\index{materials}, such\index{such} as\index{as} Sanskrit\index{Sanskrit} and\index{and} Greek\index{Greek}. LaTeX\index{LaTeX} uses\index{uses} the\index{the} TeX\index{TeX} typesetting\index{typesetting} program\index{program} for\index{for} formatting\index{formatting} its\index{its} output\index{output}, and\index{and} is\index{is} itself\index{itself} written\index{written} in\index{in} the\index{the} TeX\index{TeX} macro\index{macro} language\index{language}.

LaTeX\index{LaTeX} can\index{can} be\index{be} used\index{used} as\index{as} a\index{a} standalone\index{standalone} document\index{document} preparation\index{preparation} system\index{system}, or\index{or} as\index{as} an\index{an} intermediate\index{intermediate} format\index{format}. In\index{In} the\index{the} latter\index{latter} role\index{role}, for\index{for} example\index{example}, it\index{it} is\index{is} sometimes\index{sometimes} used\index{used} as\index{as} part\index{part} of\index{of} a\index{a} pipeline\index{pipeline} for\index{for} translating\index{translating} DocBook\index{DocBook} and\index{and} other\index{other} XML\index{XML}-based\index{based} formats\index{formats} to\index{to} PDF\index{PDF}. The\index{The} typesetting\index{typesetting} system\index{system} offers\index{offers} programmable\index{programmable} desktop\index{desktop} publishing\index{publishing} features\index{features} and\index{and} extensive\index{extensive} facilities\index{facilities} for\index{for} automating\index{automating} most\index{most} aspects\index{aspects} of\index{of} typesetting\index{typesetting} and\index{and} desktop\index{desktop} publishing\index{publishing}, including\index{including} numbering\index{numbering} and\index{and} cross\index{cross}-referencing\index{referencing} of\index{of} tables\index{tables} and\index{and} figures\index{figures}, chapter\index{chapter} and\index{and} section\index{section} headings\index{headings}, the\index{the} inclusion\index{inclusion} of\index{of} graphics\index{graphics}, page\index{page} layout\index{layout}, indexing\index{indexing} and\index{and} bibliographies\index{bibliographies}.

Like\index{Like} TeX\index{TeX}, LaTeX\index{LaTeX} started\index{started} as\index{as} a\index{a} writing\index{writing} tool\index{tool} for\index{for} mathematicians\index{mathematicians} and\index{and} computer\index{computer} scientists\index{scientists}, but\index{but} even\index{even} from\index{from} early\index{early} in\index{in} its\index{its} development\index{development}, it\index{it} has\index{has} also\index{also} been\index{been} taken\index{taken} up\index{up} by\index{by} scholars\index{scholars} who\index{who} needed\index{needed} to\index{to} write\index{write} documents\index{documents} that\index{that} include\index{include} complex\index{complex} math\index{math} expressions\index{expressions} or\index{or} non\index{non}-Latin\index{Latin} scripts\index{scripts}, such\index{such} as\index{as} Arabic\index{Arabic}, Devanagari\index{Devanagri} and\index{and} Chinese\index{Chinese}.

LaTeX\index{LaTeX} is\index{is} intended\index{intended} to\index{to} provide\index{provide} a\index{a} high\index{high}-level\index{level}, descriptive\index{descriptive} markup\index{markup} language\index{language} that\index{that} accesses\index{accesses} the\index{the} power\index{power} of\index{of} TeX\index{TeX} in\index{in} an\index{an} easier\index{easier} way\index{way} for\index{for} writers\index{writers}. In\index{In} essence\index{essence}, TeX\index{TeX} handles\index{handles} the\index{the} layout\index{layout} side\index{side}, while\index{while} LaTeX\index{LaTeX} handles\index{handles} the\index{the} content\index{content} side\index{side} for\index{for} document\index{document} processing\index{processing}. LaTeX\index{LaTeX} comprises\index{comprises} a\index{a} collection\index{collection} of\index{of} TeX\index{TeX} macros\index{macros} and\index{and} a\index{a} program\index{program} to\index{to} process\index{process} LaTeX\index{LaTeX} documents\index{documents}, and\index{and} because\index{because} the\index{the} plain\index{plain} TeX\index{TeX} formatting\index{formatting} commands\index{commands} are\index{are} elementary\index{elementary}, it\index{it} provides\index{provides} authors\index{authors} with\index{with} ready\index{ready}-made\index{made} commands\index{commands} for\index{for} formatting\index{formatting} and\index{and} layout\index{layout} requirements\index{requirements} such\index{such} as\index{as} chapter\index{chapter} headings\index{headings}, footnotes\index{footnotes}, cross\index{cross}-references\index{references} and\index{and} bibliographies\index{bibliographies}.

LaTeX\index{LaTeX} was\index{was} originally\index{originally} written\index{written} in\index{in} the\index{the} early\index{early} 1980s\index{1980s} by\index{by} Leslie\index{Leslie} Lamport\index{Lamport} at\index{at} SRI\index{SRI} International\index{International}. The\index{The} current\index{current} version\index{version} is\index{is} LaTeX2e\index{LaTeX2e} (stylised\index{stylised} as\index{as} LATEX2\index{LATEX2}), released\index{released} in\index{in} 1994\index{1994}, but\index{but} updated\index{updated} in\index{in} 2020\index{2020}. LaTeX3\index{LaTeX3} (LATEX3\index{LATEX3}) has\index{has} been\index{been} under\index{under} long\index{long}-term\index{term} development\index{development} since\index{since} the\index{the} early\index{early} 1990s\index{1990s}. LaTeX\index{LaTeX} is\index{is} free\index{free} software\index{software} and\index{and} is\index{is} distributed\index{distributed} under\index{under} the\index{the} LaTeX\index{LaTeX} Project\index{Project} Public\index{Public} License\index{License} (LPPL\index{LPPL}).

\pagestyle{index}
\providecommand{\doidxbookmark}[1]{#1}
\providecommand{\idxmark}[1]{#1}
\printindex

\end{document}

You might also need to use

% MakeIndex style file memman.ist

% @ is a valid character in some entries
actual '?' % ? instead of @

% output main entry <entry> as: \item \idxmark{<entry>}, 
item_0  "\n\\item \\idxmark{"
delim_0 "}, "
% not forgetting the subitem case%    added 2008
item_x1 "} \n \\subitem "

% Wrap and uppercase head letters
headings_flag 1 
heading_prefix "\\doidxbookmark{"
heading_suffix "}"

As in makeindex -s memman.ist indexprob

before your final processing.

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.