2

I did look at this answer to a similar question. It is about my bismon GPLv3+ free software project on github (commit b08143a1478f if that matters) whose LaTeX-ed documentation (partly generated) is under its doc/ sub-directory. My computer is running on Linux/Debian/Sid, and its LaTeX subsystem is texlive-full 2018.20190227.

For this draft report (in PDF, its §2.3.2 near figure 4 page 34) obtained with pdflatex, called from my build-bismon-doc.sh shell script, invoked by make latexdoc) obtained from LaTeX source files (under doc/ ) I need to have an index entry for the exact strings !( and !), preferably formatted in a fixed-width teletype looking font (so using \texttt in LaTeX parlance). This is in file doc/datapersist-bm.tex around line 640 where the current (not yet git commit-ed, of course) LaTeX code has:

\begin{quote}
\begin{small}

  The lines starting with \texttt{«} or \texttt{!(}
  \index{{!(}@\texttt{!(}} \index{«@\texttt{«}}
  and with \texttt{»} or \texttt{!)}
  \index{{!)}@\texttt{!(}} \index{»@\texttt{»}}
  are delimiting the object's persistent
  representation. Comments~\footnote{Once the persistence code -
    loading and dumping of the state - is mature enough, we will
    disable generation of comments in data files.} can start with a
  bar \texttt{|} till the following bar, or with two slashes
  \texttt{//} till the end of line.  {\verb+!~+} with matching
         {\verb+(~+} ... \verb+~)+ are for ``modifications'' (here, we
         set the \index{name}{\texttt{name}} of that object to
         \texttt{first\_test\_module}). Object payloads are also
         dumped in such ``modification'' form. \verb+!@+ puts the
         \index{mtime}{\emph{mtime}}. \verb+!$+ \textit{classobjid}
         sets the \index{class}{class} to the object of objid
         \textit{classobjid}. \verb+!:+ \textit{attrobj}
         \textit{valattr} put the attribute \textit{attrobj}
         associated with the value \textit{valattr}. \verb+!#+
         \textit{nbcomp} reserve the spaces for \textit{nbcomp}, and
         \verb/!&/~\textit{valcomp} appends the value \textit{valcomp}
         as a component.

%% next paragraph was removed for brevity on this LaTeX forum question
\end{small}
\end{quote}

What am I doing wrongly above?

And the suggested \index{"!"(@\texttt{!(}} does not work!

4
  • Did you try \index{"!"(@\texttt{!(}}?
    – egreg
    Commented Jul 3, 2019 at 12:56
  • Thanks, but it does not work... Commented Jul 3, 2019 at 12:58
  • Start my making a full (but minimal) example we can copy and test as is. Additionally, exactly which indexing programme are you using?
    – daleif
    Commented Jul 3, 2019 at 13:10
  • @greg I cannot get that to work either, but \index{"!"(@\texttt{"!(}} does work.
    – daleif
    Commented Jul 3, 2019 at 13:13

1 Answer 1

3

You need to quote the !, which is a special character for MakeIndex, both before and after @.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{imakeidx}

\makeindex

\begin{document}

\begin{quote}\small
The lines starting with \index{«@\texttt{«}}\texttt{«} or \index{"!(@\texttt{"!(}}\texttt{!(}
and with \index{»@\texttt{»}}\texttt{»} or \index{"!)@\texttt{"!(}}\texttt{!)}
are delimiting the object's persistent representation. 
Comments~\footnote{Once the persistence code---loading and dumping of the state---is mature 
enough, we will disable generation of comments in data files.} can start with a 
bar~\texttt{|} till the following bar, or with two slashes~\texttt{//} till the 
end of line.  
%
\verb+!~+ with matching \verb+(~+ ... \verb+~)+ are for ``modifications'' (here, we
set the \index{name}{\texttt{name}} of that object to \texttt{first\_test\_module}). 
Object payloads are also dumped in such ``modification'' form.
%
\verb+!@+ puts the \index{mtime}{\emph{mtime}}.
%
\verb+!$+ \textit{classobjid} sets the \index{class}{class} to the object of 
objid \textit{classobjid}.
%
\verb+!:+ \textit{attrobj} \textit{valattr} put the attribute \textit{attrobj}
associated with the value \textit{valattr}.
%
\verb+!#+ \textit{nbcomp} reserve the spaces for \textit{nbcomp}, and
%
\verb/!&/~\textit{valcomp} appends the value \textit{valcomp} as a component.
\end{quote}

\printindex

\end{document}

Here's the produced .ind file:

\begin{theindex}

  \item \texttt{!(}, 1
  \item \texttt{!(}, 1
  \item \texttt{\IeC {\guillemotleft }}, 1
  \item \texttt{\IeC {\guillemotright }}, 1

  \indexspace

  \item class, 1

  \indexspace

  \item mtime, 1

  \indexspace

  \item name, 1

\end{theindex}
8
  • Thanks a big lot. That worked. Commented Jul 3, 2019 at 13:20
  • Could you explain a bit more what exactly You need to quote the ! means. I don't know how in general should I quote something in LaTeX. I do know the role of quote or of ' in Scheme or Lisp (and the role of ' in C) Commented Jul 4, 2019 at 12:20
  • Concretely, I also need to index !| and Σ and I cannot adapt your answer. A general short explanation (or just some URL) about quotation in LaTeX is welcome. I only vaguely know about catcodes Commented Jul 4, 2019 at 12:26
  • @BasileStarynkevitch MakeIndex doesn't know Unicode/UTF-8 (as you see from «). The quote character for it is " and means “treat the following special character literally”.
    – egreg
    Commented Jul 4, 2019 at 12:29
  • So " is quoting a single byte, or potentially a single multi-byte UTF-8 character? Commented Jul 4, 2019 at 12:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .