4

In my document I need to work with the package imakeidx because I need two indexes. I like to have defined a list (if possible directly in the preamble) which lists the index entries in this non-alphabetical order:

Lukas\\ 
Johannes\\  
Römer\\
1. Korinther\\
2. Korinther\\ 
Galater\\
1. Johannes\\
2. Johannes\\

Remark: Not all elements of this list have been used.

The non-alphabetical is needed because the entries above are so called Bible books which are listed in the Bible according chrononically to a specific structure and not alphabetically.

The code I'd like to use with the non-alphabetical list:

\documentclass[a4paper,latin,fontsize=11pt,headsepline,parskip=half-,index=totoc,BCOR=5mm,DIV=15]{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[ansinew]{inputenc}
\usepackage{babel}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\usepackage[normalem]{ulem}
\usepackage{fancybox,calc,etoolbox,lipsum,multicol}
\usepackage[osf,sc]{mathpazo}
\usepackage[intoc]{nomencl}
\renewcommand{\nomname}{Glossar}
\makenomenclature
\usepackage{scrlayer-scrpage}% scrpage2 is obsolete
  \pagestyle{scrheadings}
  \clearpairofpagestyles% \clearscrheadings, \clearscrplain are deprecated
  \automark[chapter]{chapter}
  \ihead[]{\headmark}
  \ohead[\pagemark]{\pagemark}
  \renewcommand*\partpagestyle{empty} % removes the pagenumbers of all part pages
\usepackage{imakeidx} % must always be loaded before the hyperref package, otherwise it can cause problems!
\makeindex[name=stichwort,title=Stichwortverzeichniss,options=-s ./main]
\makeindex[name=bibel,title=Bibelstellen,options=-s ./main]

\usepackage[colorlinks,pdfpagelabels,pdfstartview = FitH,bookmarksopen = true,bookmarksnumbered = true,linkcolor = black,plainpages = false,hypertexnames = false,citecolor = black] {hyperref}

\title{Einführung}
\author{Autor}
\date{1.Oktober 2014}

\newcommand{\nobreakword}[1]{\mbox{#1}}

\makeatletter
  \def\@idxitem{\par\addvspace{10\p@ \@plus 5\p@ \@minus 3\p@}\hangindent 40\p@}
  \def\subitem{\par\hangindent 40\p@ \hspace*{20\p@}}
  \def\subsubitem{\par\hangindent 40\p@ \hspace*{30\p@}}
  \def\indexspace{}
  \patchcmd\theindex{\indexname}{\indexname\vspace{12pt}}{}{}
\makeatother

% glossar
\renewcommand{\nompreamble}{\vspace*{-3mm}...Introducing Thoughts...\vspace*{4mm}} %text before glossar!
\makenomenclature % is obligatory to create the glossar!
\newcommand{\auferstehungtext}{Auferstehungstext} % is used for long glossar entries!

\begin{document}

\begin{titlepage}% if you need a custom layout - otherwise, use \maketitle
  \centering
  Titelseite
\end{titlepage}

\renewcommand{\contentsname}{Inhaltsverzeichnis}
\clearpage\pdfbookmark{\contentsname}{toc}
\tableofcontents\thispagestyle{empty}

\chapter{Gottes Liebe zu den Menschen(Seine Geschöpfe)}

\begin{flushright}\footnotesize\textit{ursprünglicher Beitrag vom 6. April 2014 überarbeitet}\end{flushright}

The text in the index

\doublebox{\begin{minipage}[t]{1\columnwidth}%
    "Denn so hat Gott die Welt geliebt, dass er seinen eingeborenen Sohn gab, damit jeder, der an ihn glaubt, nicht verloren geht, sondern ewiges Leben hat." \index[bibel]{Johannes!Johannes 3,16}\nobreakword{(Johannes 3,16)}%
    \end{minipage}}

    \section*{Gottes Liebe zu den Menschen}

    "Und wir haben die Liebe erkannt und geglaubt, die Gott zu uns hat. Gott ist Liebe, und wer in der Liebe bleibt, der bleibt in Gott und Gott in ihm" \index[bibel]{1. Johannes!1. Johannes 4,16}\nobreakword{(1. Johannes 4,16)}
    \index[stichwort]{Wachstum im Glauben!Glaube}

    "Der HERR ist mir erschienen von ferne: Ich habe dich je und je geliebt, darum habe ich dich zu mir gezogen aus lauter Güte."
    (Jeremia 31,3)

    "Denn so hat Gott die Welt geliebt, dass er seinen eingeborenen Sohn gab, damit jeder, der an ihn glaubt, nicht verloren geht, sondern ewiges Leben hat." \index[bibel]{Johannes!Johannes 3,16}\nobreakword{(Johannes 3,16)}

    "Gott aber erweist seine Liebe zu uns darin, dass Christus, als wir noch Sünder waren, für uns gestorben ist." \index[bibel]{Römer!Römer 5,8}\nobreakword{(Römer 5,8)}

    "Du kennst die Gebote: »Du sollst nicht töten; du sollst nicht ehebrechen; du sollst nicht stehlen; du sollst nicht falsch
    Zeugnis reden; du sollst niemanden berauben; ehre Vater und Mutter.« Er aber sprach zu ihm: Meister, das habe ich alles gehalten von meiner Jugend auf. Und Jesus sah ihn an und gewann ihn lieb und sprach zu ihm: Eines fehlt dir. Geh hin, verkaufe alles, was du hast, und gib's den Armen, so wirst du einen Schatz im Himmel haben, und komm und folge mir nach!" \index[bibel]{Markus!Markus 10,19-21}\nobreakword{(Markus 10,19-21)}
    \index[stichwort]{Lebensveränderung!Reden/Schweigen}

    "Gnade, Barmherzigkeit, Friede von Gott, dem Vater, und von Jesus Christus, dem Sohn des Vaters, sei mit uns in Wahrheit und in Liebe!" \index[bibel]{2. Johannes!2. Johannes 1,3}\nobreakword{(2. Johannes 1,3)}


    \section*{Liebe unter den Menschen}

    "Furcht ist nicht in der Liebe, sondern die vollkommene Liebe treibt die Furcht aus; denn die Furcht rechnet mit Strafe. Wer
    sich aber fürchtet, der ist nicht vollkommen in der Liebe. Lasst uns lieben, denn er hat uns zuerst geliebt. Wenn jemand spricht: Ich liebe Gott, und hasst seinen Bruder, der ist ein Lügner. Denn wer seinen Bruder nicht liebt, den er sieht, der kann nicht Gott lieben, den er nicht sieht. Und dies Gebot haben wir von ihm, dass, wer Gott liebt, dass der auch seinen Bruder liebe." \index[bibel]{1. Johannes!1. Johannes 4,18-21}\nobreakword{(1. Johannes 4,18-21)}
    \index[stichwort]{Lebensveränderung!Nächstenliebe}

    "Daran wird jedermann erkennen, dass ihr meine Jünger seid, wenn ihr Liebe untereinander habt." \index[bibel]{Johannes!Johannes 13,35}\nobreakword{(Johannes 13,35)}

    "Wie mich mein Vater liebt, so liebe ich euch auch. Bleibt in meiner Liebe!" \index[bibel]{Johannes!Johannes 15,9}\nobreakword{(Johannes 15,9)}

    "Ich beschwöre euch, ihr Töchter Jerusalems: Erregt und erweckt nicht die Liebe, Bis es ihr gefällt!" \index[bibel]{Hoheslied!Hoheslied 8,4}\nobreakword{(Hoheslied 8,4)}

    "Alle eure Dinge lasst in der Liebe geschehen!"
    (1. Korinther 16,14)

    "Die Frucht des Geistes aber ist Liebe, Freude, Friede,Langmut, Freundlichkeit, Güte, Treue, Sanftmut, Selbstbeherrschung."
    (Galater 5,22)

    \index[stichwort]{Bleibendes!Liebe}
    \index[stichwort]{Lebensveränderung!Freude}\index[stichwort]{Lebensveränderung!Friede}
    \index[stichwort]{Lebensveränderung!Freundlichkeit}
    \index[stichwort]{Begriffe!Treue}


\addtocontents{toc}{\textbf{\sffamily \textcolor{white}{.}}\protect\par} %gives an empty line between Appendy and last chapter
\shorthandon{"}

\cleardoublepage
\thispagestyle{empty}
\vspace*{\fill}
\begin{center}
    \Huge Anhang
    \addtocontents{toc}{%
        \protect\addvspace{0.5pc}% <------------- adjust to suit
        \textbf{\sffamily Anhang}\protect\par
    }
\end{center}
\vspace*{\fill}
\clearpage


\nomenclature{Begriff2}{Begriffserklärung2}
\nomenclature{Begriff3}{Begriffserklärung3}
% Glossar (define specifications and introducing text in preamble)
\printnomenclature[2.5 cm] % width of first column

% Index (define specifications and introducing text here)


\printindex[bibel]

\clearpage
\printindex[stichwort]

\end{document}

I know that my code is not perfect (I used latin, because loading \usepackage[babel]{ngerman} with \shorthandoff{"} didn't work). However this code works in my TeXstudio editor with: pdflatex -synctex=1 -interaction=nonstopmode %.tex|makeindex %.nlo -s nomencl.ist -o %.nls -t %.nlg|pdflatex -synctex=1 -interaction=nonstopmode %.tex|"C:/Program Files (x86)/Adobe/Reader 11.0/Reader/AcroRd32.exe" %.pdf (It works when I close after each translation the PDF viewer)

This question is a continuation of my old question: How to have text inside round brackets on a line and also be added to a second index with predefined index search keys?

laminin
  • 307
  • Does that command work at all? You are piping the output from each command into the next one as input but that doesn't make any sense. – cfr Apr 16 '15 at 20:22
  • By the way, using geometry after areaset completely destroys the layout configured by KOMA, as I said before. Using \areaset is pointless if you plan to override the trouble KOMA goes to to lay things out nicely. And are you really writing your thesis in Latin? I used that in an answer only because the lipsum package produces Latin and the hyphenation is wrong otherwise. You don't want Latin hyphenation patterns unless you are using Latin. – cfr Apr 16 '15 at 20:33
  • I tried without areaset but then I got problems because the index entries are so long(without.space.so.that.the.line.is.overriding.the.next.column). I deleted now theareaset and lipsum. – laminin Apr 16 '15 at 20:42
  • It would be better to not use geometry and to use KOMA's configuration options, as I said before. It would also be better to use one of KOMA's commands for creating the part. It is just asking for trouble continually adding manual spacing and formatting commands. – cfr Apr 16 '15 at 20:46
  • About the compiling using a single command: You might want to take a look at latexmk – JBantje Apr 16 '15 at 21:11
  • @laminin You are copying code from multiple questions without really understanding the code you are pasting. You should read some of the documentation for the class and packages you are using so that you understand the code. Especially, you should look at the documentation for the class you are using so that you do not load packages you don't need and so that you can use proper markup rather than manual formatting. You may, in the end, need some manual formatting to conform to your institution's formatting guidelines, but this should be a last resort rather than the first thing you try. – cfr Apr 16 '15 at 22:23
  • You have code, from a previous answer of mine, in your preamble which prevents the page number! And you will automatically get vertical space before the title of the part. If it is not sufficient, you need to customise the formatting of parts. Again, start with the documentation for the class you are using. (Which also explains how to eliminate the page numbers - that's where I got that command in your preamble from in the first place.) – cfr Apr 16 '15 at 22:26
  • @cfr: You mean your code from: http://tex.stackexchange.com/questions/237336/how-to-add-explanatory-text-to-an-index-page-without-page-number-troubles ? – laminin Apr 16 '15 at 22:29
  • Yes, but that's a horrible way to write the contents line. – cfr Apr 16 '15 at 22:32
  • @laminin Believe me: I am the last person you want correcting your code! – cfr Apr 16 '15 at 22:50
  • @cfr Okay I understand. No problem. Can you explain me concerning the pdflatex -synctex=1 -interaction=nonstopmode %.tex | makeindex %.nlo -s nomencl.ist -o %.nls -t %.nlg | txs:///makeindex | pdflatex -synctex=1 -interaction=nonstopmode %.tex | txs:///view-pdf-internal command what's wrong with that? I tried long time until I get a PDF with a nice index this variant worked when I was using no "main.ist" file. – laminin Apr 16 '15 at 22:53
  • 1
    @laminin I have no idea. I guess this is in an editor? Normally a | b pipes the output from a to b which makes no sense. So if it compiles at all, I guess it is right but just some syntax I'm not familiar with. – cfr Apr 16 '15 at 22:57
  • the pipes | there make no sense, probably they sort of work as the commands are not taking any input, but you just want ; (if it is a unix commandline) why txs:///makeindex (that looks very strange) – David Carlisle Apr 16 '15 at 23:01
  • @DavidCarlisle The pipes comes from the editor TeXstudio. Removing txs:////makeindex which comes also from the editor doesn't help. – laminin Apr 16 '15 at 23:15
  • @DavidCarlisle Shouldn't it usually be makeindex <something>? Iaminin: what do you mean things 'come from the editor'? Where did you find this command? – cfr Apr 16 '15 at 23:18
  • @cfr: TeXstudio> Options> Configure> Generate> User commands> Settings> and you can add your commands as you want. I think in my code I still need to use somehow makeindex. makeindex gives txs:///makeindex – laminin Apr 16 '15 at 23:24
  • Your question is massively unclear. You say you want to have the index in a predefined order (which is a very strange thing to want, but OK) but then you say you want to use makeindex. the only thing makeindex does is to sort the entries into alphabetic order you say in your comment "I think I still need to use makeindex" why do you think that? – David Carlisle Apr 17 '15 at 07:28
  • @DavidCarlisle Because the entries are "subbooks" from the book The Bible, the entries are ordered in chronological order. I thought because of generation of the needed main.ist file I may be need to change something for the command makeindex. Are you able to obtain a PDF out of my given code? If yes, can you write me which full commands you wrote in the command line from beginning up to the end when I got the PDF? – laminin Apr 17 '15 at 09:24
  • Is this a translation problem, do you want a "table of contents" (a list usually at the front of the document that lists all the main sections in order (called index in some European languages) or do you want an "index" an alphabetical index of the use of specific words throughout the document, usually at the end of the document. makeindex is just about making the alphabetic index of words. – David Carlisle Apr 17 '15 at 09:28
  • Well, it's all of it. Because of an answer (http://tex.stackexchange.com/questions/238382/how-to-have-text-inside-round-brackets-on-a-line-and-also-be-added-to-a-second-i/238962?noredirect=1#comment567649_238962) I needed so switch to imakeidx package. Therefore I get into some problems. Now I use the code for my editor I've written in my question which works without problems. So, I've updated my question: I only need to have a non-alphabetical index list. – laminin Apr 17 '15 at 13:38
  • if you need your index to be in an order other than strictly sorted as ascii, you need to provide a sort field for each entry that forces that order. for example, \index(01@Lukas}, \index{02@Johannes}, etc. – barbara beeton Apr 17 '15 at 19:03
  • @barbarabeeton Is it possible to define such a list in the preamble? – laminin Apr 17 '15 at 20:11
  • 1
    @laminin -- i don't know of any such way. imakeidx uses makeindex as its sorting mechanism, so the rules for inputting \index entries are the same. – barbara beeton Apr 17 '15 at 20:36

1 Answers1

8

You can define a non-standard sorting by using numbers for it, using the @ sintax; I solve the problem with a command for Bible indexing, whose first argument is an abbreviation for the book name and the second argument is the verse.

I have removed from the following code all the inessential parts. You have to supply the full list of Bible books (at least those that you cite).

\documentclass[
  a4paper,
  fontsize=11pt,
  headsepline,
  parskip=half-,
%  index=totoc,
  BCOR=5mm,
DIV=15]{scrreprt}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}

\usepackage{imakeidx}
\makeindex[name=stichwort,title=Stichwortverzeichniss,intoc]
\makeindex[name=bibel,title=Bibelstellen,intoc]

\usepackage[
  colorlinks,
  pdfpagelabels,
  pdfstartview = FitH,
  bookmarksopen = true,
  bookmarksnumbered = true,
  linkcolor = black,
  plainpages = false,
  hypertexnames = false,
  citecolor = black
] {hyperref}

\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}

\newcommand{\nobreakword}[1]{\mbox{#1}}

\makeatletter
  \def\@idxitem{\par\addvspace{10\p@ \@plus 5\p@ \@minus 3\p@}\hangindent 40\p@}
  \def\subitem{\par\hangindent 40\p@ \hspace*{20\p@}}
  \def\subsubitem{\par\hangindent 40\p@ \hspace*{30\p@}}
  \def\indexspace{}
  \patchcmd\theindex{\indexname}{\indexname\vspace{12pt}}{}{}
\makeatother

\makeatletter
\def\book@Mar{1@Markus!Markus}
\def\book@Luk{2@Lukas!Lukas}
\def\book@Joh{3@Johannes!Johannes}
\def\book@Rom{4@\detokenize{Römer}!\detokenize{Römer}}
\@namedef{book@1Kor}{5@1. Korinther!1. Korinther}
\@namedef{book@2Kor}{6@2. Korinther!2. Korinther}
\def\book@Gal{7@Galater!Galater}
\@namedef{book@1Joh}{8@1. Johannes!1. Johannes}
\@namedef{book@2Joh}{9@2. Johannes!2. Johannes}
\newcommand{\bibelindex}[2]{\index[bibel]{\@nameuse{book@#1}, #2}}
\makeatother

\title{Einführung}
\author{Autor}
\date{1.Oktober 2014}

\begin{document}

\tableofcontents

\chapter{Gottes Liebe zu den Menschen (Seine Geschöpfe)}

"`Denn so hat Gott die Welt geliebt, dass er seinen eingeborenen Sohn gab,
damit jeder, der an ihn glaubt, nicht verloren geht, sondern ewiges Leben hat."'%
\bibelindex{Joh}{3,16} \nobreakword{(Johannes 3,16)}

\section*{Gottes Liebe zu den Menschen}

"`Und wir haben die Liebe erkannt und geglaubt, die Gott zu uns hat. Gott ist 
Liebe, und wer in der Liebe bleibt, der bleibt in Gott und Gott in ihm"'%
\bibelindex{1Joh}{4,16} \nobreakword{(1. Johannes 4,16)}%
\index[stichwort]{Wachstum im Glauben!Glaube}

"`Der HERR ist mir erschienen von ferne: Ich habe dich je und je geliebt, 
darum habe ich dich zu mir gezogen aus lauter Güte."' (Jeremia 31,3)

"`Denn so hat Gott die Welt geliebt, dass er seinen eingeborenen Sohn gab, 
damit jeder, der an ihn glaubt, nicht verloren geht, sondern ewiges Leben 
hat."'\bibelindex{Joh}{3,16} \nobreakword{(Johannes 3,16)}

"`Gott aber erweist seine Liebe zu uns darin, dass Christus, als wir noch 
Sünder waren, für uns gestorben ist."'\bibelindex{Rom}{5,8}
\nobreakword{(Römer 5,8)}

"`Du kennst die Gebote: »Du sollst nicht töten; du sollst nicht ehebrechen; 
du sollst nicht stehlen; du sollst nicht falsch Zeugnis reden; du sollst 
niemanden berauben; ehre Vater und Mutter.« Er aber sprach zu ihm: Meister, 
das habe ich alles gehalten von meiner Jugend auf. Und Jesus sah ihn an und 
gewann ihn lieb und sprach zu ihm: Eines fehlt dir. Geh hin, verkaufe alles, 
was du hast, und gib's den Armen, so wirst du einen Schatz im Himmel haben, 
und komm und folge mir nach!"'%
\bibelindex{Mar}{10,19-21}\nobreakword{(Markus 10,19-21)}%
\index[stichwort]{Lebensveränderung!Reden/Schweigen}

\index[stichwort]{Bleibendes!Liebe}
\index[stichwort]{Lebensveränderung!Freude}\index[stichwort]{Lebensveränderung!Friede}
\index[stichwort]{Lebensveränderung!Freundlichkeit}
\index[stichwort]{Begriffe!Treue}

% Index (define specifications and introducing text here)

\printindex[bibel]

\printindex[stichwort]

\end{document}

Here is the produced index.

enter image description here

egreg
  • 1,121,712
  • Very cool! Is it also possible a) to enlarge the horizontal spacing betweend the reference and the page number; b) to have all page numbers starting at the same tab stop (starting for each column on the same width position)? – laminin Apr 19 '15 at 10:06
  • @laminin That's completely unrelated; it's a question about a proper .ist file. – egreg Apr 19 '15 at 10:09
  • Ok. Is it correct to write: \@namedef\book@1Kon{11@\detokenize{1. Könige}!\detokenize{1. Könige}} for 1. Könige? – laminin Apr 19 '15 at 10:18
  • 1
    @laminin Yes, special characters need to be protected. – egreg Apr 19 '15 at 11:03
  • I'd like to use somewhat like \bibelindex{Römer}{88,8} in the text and in the beginning somewhat like \def\book@\detokenize{Römer}{06@\detokenize{Römer}!\detokenize{Römer}}. How must I modify the code so I don't get an error? – laminin Apr 19 '15 at 20:36
  • @laminin Sorry, not possible. Or, at least, very fragile. – egreg Apr 19 '15 at 20:38
  • no problem. In my text I still have a lot of \index[bibel]{45@Römer!Rö 77,7} which I don't want to exchange. Since your idea, I'd like for future to write in the text \bibelindex{Rom}{88,8} with a command in the beginning somewhat like: \def\book@Rom{45@\detokenize{Römer}!\detokenize{Rö}} plus the modified \newcommand{\bibelindex}[2]{\index[bibel]{\@nameuse{book@#1} #2}}. This also perfectly works, but there is one problem: – laminin Apr 19 '15 at 20:57
  • The two subentries Rö 77,7 and Rö 88,8 are listed under two separateRömer entries. Is it possible to combine this, that I have only one entry Römer plus the two subentries Rö 77,7 and Rö 88,8 inside? Or should I open a new question for clarity? – laminin Apr 19 '15 at 20:57
  • @laminin DON'T use special characters in the abbreviations for the first argument. Moreover, mixing the two styles is a sure source of problems. I'm sorry if this solution forces you to change all indexing, but I see no other way. – egreg Apr 19 '15 at 21:00
  • Do you mean in the text \bibelindex{Rom}{88,8} or in the definition \def\book@Rom{45@\detokenize{Römer}!\detokenize{Rö}}? – laminin Apr 19 '15 at 21:01
  • 1
    @laminin In the argument of \bibelindex (and hence also in \def\book@Rom (in the replacement text it is OK, provided \detokenize is used). Using \def\book@Röm is out of question. – egreg Apr 19 '15 at 21:11