[tex-eplain] Correct format for \indexsee and \indexseealso
geolsoft at mail.ru
geolsoft at mail.ru
Fri Aug 19 20:27:42 CEST 2005
Please refer to the old thread from February 2005
http://tug.org/pipermail/tex-eplain/2005-February/000202.html
John Culleton suggested to change the format for index items
to match one of the `official' styles.
I attach the patch provided by Karl Berry corrected as per
suggestions from Dan Luecking.
It is actually impossible to convince MakeIndex to omit the
comma in front of \indexsee... commands, because these
commands are treated just like any other page number.
However, the small sed script I attach (trimsee) can be used
as a filter to eliminate these commas. You can run it,
e.g., like this:
$ tex myfile && cat myfile.idx | makeindex | ./trimsee > myfile.ind && tex myfile
I doubt the patch should go into xeplain.tex as it requires
the script to get it straight. The patch is just an example
of how the \indexsee... commands should be redefined. But
if the script is OK, I think it could go into Eplain distro,
together with some description of how and why it should be
used, in the documentation. What do you think?
--
Best regards,
Oleg Katsitadze
-------------- next part --------------
*** /backup/archive/tug/home/ftp/tex/eplain/ORIG/xeplain.tex Tue Aug 31 13:40:15 2004
--- /backup/archive/tug/home/ftp/tex/eplain/xeplain.tex Tue Feb 1 14:52:47 2005
***************
*** 2248,2257 ****
% \indexsee{TERM}{PAGENO} ignores PAGENO, and says `See TERM'.
\def\seevariant{\it}%
! \def\indexseeword{See}%
! \def\indexsee#1#2{{\seevariant \indexseeword\ }#1}%
%
% \indexseealso{TERM}{PAGENO} is similar.
! \def\indexseealsowords{see also}%
! \def\indexseealso#1#2{{\seevariant \indexseealsowords\ }#1}%
%
%
--- 2248,2257 ----
% \indexsee{TERM}{PAGENO} ignores PAGENO, and says `See TERM'.
\def\seevariant{\it}%
! \def\indexseeword{see}%
! \def\indexsee#1#2{({\seevariant \indexseeword\/ }#1)}%
%
% \indexseealso{TERM}{PAGENO} is similar.
! \def\indexseealsowords{see also}%
! \def\indexseealso#1#2{({\seevariant \indexseealsowords\/ }#1)}%
%
%
-------------- next part --------------
#!/bin/sh
help ()
{
cat <<EOF
Usage: $0 [-h] [-s SEE] [-i IS] [-o OS]
Removes commas (or other page list separators) in front
of see / see also commands in the output of MakeIndex.
Input is read from stdin, output is directed to stdout.
-h print this help message
-s use SEE as a regular expression matching start of
see / see also commands (default: '$DEFAULT_SEE')
-i use IS as a regular expression matching separator
in front of see / see also commands in the input
(default: '$DEFAULT_IS')
-o use OS as a separator to replace IS in front of
see / see also commands (default: '$DEFAULT_OS')
EOF
}
missing_arg ()
{
echo "Missing argument to option '$1'" 1>&2
exit 1
}
DEFAULT_SEE='\\indexsee'
DEFAULT_IS=', \+'
DEFAULT_OS=' '
SEE=$DEFAULT_SEE
IS=$DEFAULT_IS
OS=$DEFAULT_OS
while [ $# != 0 ]
do
case "$1" in
-s)
if (( $# < 2 )); then
missing_arg "$1"
fi
SEE=$2
shift
;;
-i)
if (( $# < 2 )); then
missing_arg "$1"
fi
IS=$2
shift
;;
-o)
if (( $# < 2 )); then
missing_arg "$1"
fi
OS=$2
shift
;;
-h)
help
exit 0
;;
*)
echo "Unknown option '$1'" 1>&2
exit 1
;;
esac
shift
done
# The idea is to implement line output delayed by one line. When we
# read next line, we check if it starts with a see/see also entry, and
# if it does, we remove the comma at the end of the previous line
# before printing it. We keep previous lines in the hold buffer.
sed -n '
# Remove all commas in front of see/see also inside each line.
s/'"$IS$SEE/$OS$SEE"'/g
# If this line does not start with see/see also, we will print the
# previous line intact. NOTE: There are two characters inside the
# brackets: a space and a tab.
/^[ ]*'"$SEE"'/! { x; b PRINT; }
# This line starts with see/see also, so remove comma at the end of
# the previous line before we print it.
x
s/'"$IS"'$/'"$OS"'/
# Print the previous line.
:PRINT
1! p
# At the end of the input, print the last line.
$ { x; p; }
'
More information about the tex-eplain
mailing list