This project is read-only.

Revisiting the possibilities to add references to the TOC

Dec 26, 2015 at 4:33 PM
At the moment I'm doing following in the document header:
Bibliography { data-hanging-indent: 2; tex-cmd-outer-before: "\let\chapnormal\chapter\renewcommand{\chapter}[2]{}%mdk&nl;"; tex-cmd-outer-after: "\let\chapter\chapnormal%mdk&nl;" }
Then I use a normal level 1 heading and disable the numbering:
# Literatur { - }

Is there an easier way by now? Thanks in advance! :)
Dec 26, 2015 at 6:37 PM
ha, I see you discovered "data-hanging-indent" already :-) Great. I added this while adding support for CSL style definitions. These are already working quite well -- you may well want to use such CSL for your thesis since they come with German localization.

Anyway, I don't have a great solution yet -- it is a bit of a troublesome thing that latex adds the references to the bibliography. Here is a rule that works around it:
@if tex {
  bibliography { 
    #sec-bibliography; @h1; 
    toc; toc-line:"&name-references;" 
I have been thinking of adding this to the prelude.mdk . It basically adds a TOC line to the bibliography instead of the reference heading. That way it shows up in Latex correctly.
Let me know if this works for you :-)

btw. I see you are also using tex-cmd-outer-after and friends: you are becoming a real Madoko TeXnician :-)
Dec 26, 2015 at 6:38 PM
Actually, I think the rule above should not increase the "@h1" perhaps. Just:
@if tex {
  bibliography { toc; toc-line:"&name-references;" }
is probably better?
Dec 26, 2015 at 7:07 PM
Edited Dec 26, 2015 at 9:07 PM
Oh yes, data-hanging-indent and the possibility to use csl styles were the reason that I compiled madoko myself today. ;) A big thank you for that! It works just fine.

Regarding your proposed solution –- I came up with sth like this myself but there is a problem with that: In the TOC the position (page number) of the references is not known:
Latexmk: List of undefined refs and citations:
  Reference `' on page 3 undefined on input line 153
I couldn't find a way to solve this problem which is why I chose the other way round and removed the heading. I'm not sure if this is a bug or just a limitation.
btw. I see you are also using tex-cmd-outer-after and friends: you are becoming a real Madoko TeXnician :-)
Yes, I was quite a lot digging in the madoko templates/styles to find solutions to what I want to accomplish. I'm still thinking too much in latex terms, totally neglecting the html part that is equally as big. At least I'm questioning myself nowadays every time I'm about to load "yet another" latex package and take a look if there isn't already a "madoko way" of doing it. ;) Thanks for all the work you put into madoko!
Dec 27, 2015 at 1:04 AM
ah, I think you need to add an identifier to the bibliography too, perhaps:
@if tex {
  bibliography { #sec-bibliography; toc; toc-line:"&name-references;" }
will do the trick?
(mmmm, Madoko should really generate such identifiers on the fly if needed)

Good to hear you get into the Madoko mindset :) In the end, it is really nice to be able to generate and distribute an HTML document too -- actually, most people find HTML much more pleasant to look at when reading on an electronic medium.
Dec 27, 2015 at 10:30 AM
Edited Dec 27, 2015 at 10:30 AM
Indeed, html output is very good to have, especially since tex2html transpilers are still quite bothersome to handle. You can also use an html document with ms word pretty easily which is sometimes a requirement if you want to send people who are not into tex/madoko editable text.

Your solution with the added identifier fixes the error message and makes the toc print a side number but interestingly it's the side number of the last page of the references. Though the linked text (toc-line:"&name-references;") correctly points to the first page of the references. Quite strange.
Dec 29, 2015 at 12:34 PM
Hmm, I tried different things to get the right page number for the references in the TOC but somehow I couldn't get it right. Any idea what I'm missing?
Dec 29, 2015 at 5:48 PM
Ah sorry for my late reply -- somehow missed your earlier remark. Strange behaviour -- I suspect the label is inserted at the end of the bibliography instead of the start... can you try to set tex-label-before="&id;" on the bibliography? That might fix it.
Dec 29, 2015 at 6:39 PM
no need to be sorry – I can be annoyingly insistent . ;) I just tried with tex-label-before="&id;" but now the displayed page number is exactly one side before the references start. :) My current document looks like this (perhaps it helps to see what I'm doing):
Title               : Title
Subtitle            : Untertitel noch zu bestimmen
Heading Base        : 1
Heading Endperiod   :
Doc Class           : [12pt, a4paper, portrait, oneside, BCOR=7mm, DIV=14, footinclude=false, headinclude=true, parskip=full, final] scrreprt
Bib Style           : ajs
Bib                 : literatur
Name References     : Literatur
@if tex {
  bibliography { data-hanging-indent: 2; toc; toc-line:"&name-references;"; #sec-bibliography; tex-label-before="&id;" }
Cite Style          : natural
Cite All            : true
ldquo               : „
Logo                : false
Name Contents       : Inhalt

Package     : [libertine] newtxmath
Package     : fontspec, xltxtra, xunicode, microtype
Package     : polyglossia
Package     : [strict=true, autostyle, german=quotes] csquotes
Package     : [headsepline, plainheadsepline, automark, autooneside=true] scrlayer-scrpage
Package     : setspace
Package     : hyperref

Tex Header :
    \setmainlanguage[variant=german, spelling=new, latesthyphen=true, babelshorthands=true]{german}
    \defaultfontfeatures{Ligatures=TeX, Mapping=tex-text, Language=German}
    \setmainfont[Ligatures=TeX]{Linux Libertine O}
    \setsansfont[Scale=MatchLowercase]{Helvetica Neue}


\KOMAoptions{DIV=last} % Satzspiegel neu berechnen wegen 1,5 fach Zeilenabstand

~ Abstract
Zusammenfassung ... 



# Einführung { @H1=1 #teil-einf }


# Kurzer historischer Diskurs

[INCLUDE="historischer diskurs"]


# Appendix { - }

# Syntax { tex-cmd-outer-before: "\begingroup\let\clearpage\relax%mdk&nl;"; tex-cmd-outer-after: "\endgroup%mdk&nl;"; @h1=A }

Syntax ...

# Erklärung des Autors

Text ...

Dec 30, 2015 at 12:28 AM
Darn -- that is what I feared -- now the label is a bit too soon and is put before the page break while it should be at the start of the inner bibliography environment. I need to add separate support for this... as a fix, this may work (I cannot test now as I a need to go), set for the bibliography:
ps. I will probably add a 'tex-label-placement' attribute; for headers you want them right before the header, for figures at the end of the body, and for bibliographies at the start of the body.
Dec 30, 2015 at 11:57 AM
@if tex {
  bibliography { data-hanging-indent: 2; toc; toc-line:"&name-references;"; #sec-bibliography; tex-inner-before="\label{&id;}" }
This show the last page of the references again. ;)
Dec 30, 2015 at 4:34 PM
Finally found a working solution:
@if tex {
  bibliography { data-hanging-indent: 2; toc; toc-line:"&name-references;"; tex-cmd-inner-before:"\label{&id;}%mdk&nl;" }
Of course I have no idea why the other didn't work. :)