Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

You can't cheat the phone company.


computers / comp.text.tex / Index formatting

SubjectAuthor
o Index formattingHolger Schieferdecker

1
Index formatting

<ulcfo0U5mqdL1@news.in-ulm.de>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=7863&group=comp.text.tex#7863

  copy link   Newsgroups: comp.text.tex
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!news.szaf.org!news.bawue.net!newsfeed.in-ulm.de!not-for-mail
From: spamless@gmx.de (Holger Schieferdecker)
Newsgroups: comp.text.tex
Subject: Index formatting
Date: Wed, 13 Dec 2023 15:40:02 +0100
Organization: [ posted via ] IN-Ulm
Lines: 91
Message-ID: <ulcfo0U5mqdL1@news.in-ulm.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.in-ulm.de 49119874DC965A4659407C283DBC2304
X-Mozilla-News-Host: news://news.in-ulm.de:119
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101
Thunderbird/52.9.1
 by: Holger Schieferdecke - Wed, 13 Dec 2023 14:40 UTC

Hi,

recently I tried to format an index created with makeindex. I wanted to
right align the page numbers and fill the gap with dots. For that I
found a solution at TeX stackexchange. Then I also wanted centered
capital letters (A, B, and so on) for each group in the index. I also
found a solution for that, but I had to try several ways. And I don't
fully understand why some ways don't work. Maybe someone can explain
that. A working example is below.

What I tried are the following alternatives.

\hfil\textbf{#1}\hfil% this is just indented
% \hfil\hfil\textbf{#1}\hfil% this is centered, but why
% \hfil\textbf{#1}% this is centered, but why?
% \hfill\textbf{#1}\hfill% this centered
% \hfill\textbf{#1}% right-aligned, as expected

I understand that \hfil and \hfill internally have different
glues/stretches (fil vs. fill). It seems that something else is adding a
fil after the heading, so effectively there is something like

fil "Letter" fil fil

But I don't see where that additional fil could come from. Removing
\belowpdfbookmark or nopagebreak didn't change anything.

As the line with \hfill\textbf{#1}\hfill works this question is more of
academic interest. :-)

Holger

%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass{scrreprt}
\KOMAoption{parskip}{half-}
\KOMAoption{index}{totoc}

\usepackage{xcolor}
\usepackage{makeidx}

\usepackage{hyperref}
\hypersetup{colorlinks}
\hypersetup{linkcolor=blue}
\usepackage{bookmark}
\bookmarksetup{numbered}
\bookmarksetup{open}
\bookmarksetup{openlevel=3}

% format settings for index
\begin{filecontents*}[overwrite]{\jobname.mst}
headings_flag 1
heading_prefix "\\IndexHeading{"
heading_suffix "}\\nopagebreak\n"
delim_0 "\\IndexFill "
delim_1 "\\IndexFill "
\end{filecontents*}

% format index heading and put it into bookmarks
\newcommand*{\IndexHeading}[1]{%
\hfil\textbf{#1}\hfil% this is just indented
% \hfil\hfil\textbf{#1}\hfil% this is centered, but why
% \hfil\textbf{#1}% this is centered, but why?
% \hfill\textbf{#1}\hfill% this centered
% \hfill\textbf{#1}% right-aligned, as expected
\belowpdfbookmark{#1}{#1}%
}

% right-align page numbers in index, fill with dots
\ExplSyntaxOn
\newcommand*{\IndexFill}{%
\leaders \hbox to .67em {\hss \textcolor{gray!55}{.} \hss}\hfill
} \ExplSyntaxOff

\makeindex

\begin{document}

\pdfbookmark[1]{\contentsname}{toc}
\tableofcontents % Inhaltsverzeichnis

\chapter{Fruits}
\index{Apple}
\index{Banana}
The topic is fruits.

\printindex

\end{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor