1

I'm creating a songbook using the songspackage. I'm very new to LaTex and opted to use overleaf which has worked good, the only problem I really have is with the index. I'm using an older base template for the project which already had a working index-file which I can display, but the index won't update.

While searching the documentation I believe the solution is connected to the line:

texlua songidx.lua titlfile.sxd titlfile.sbx

But I can't seem to find anywhere to put that line in overleaf. Is there anyway to solve this or do I have to learn how to parse it locally on my computer?

Update: Added a MWE below. This example produces either an empty index with the text: "[Index not yet generated.]" or if I add the idxfile.sbx from an older version of the book, the whole register appears as it was years ago and not only the two songs in this example. So clearly the idxfile.sbx would have to be rewritten somehow. Now to the MWE that is splitted in two a min file (first block) and a included file with the songs themselves:

\documentclass[9pt,a6paper,openright,twoside]{extbook}
\usepackage[bookmarks]{hyperref}
\usepackage[top=15mm,bottom=15mm,left=15mm,right=10mm]{geometry}
%\addtolength{\oddsidemargin}{5mm}
\usepackage[lyric,noshading]{songs}
\usepackage{amsmath,amssymb}
\usepackage{amsfonts}
\usepackage{fancyhdr}   
\usepackage{enumitem}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[swedish]{babel}
\usepackage{calligra}
\usepackage{lmodern}
\usepackage{graphicx}
\usepackage{fancyhdr}
\usepackage{imakeidx}
\usepackage{tikz}

\usepackage{textcomp}

\hypersetup{
    colorlinks=false,
    pdfborder={0 0 0},
}

\setlength{\sbarheight}{0.2pt}

\renewcommand{\stitlefont}{\bf\large}
\renewcommand{\notefont}{\itshape\small}

\makeatletter

\renewcommand\showindex[3][0]{%
\@ifundefined{SB@idxsel@#3}{\SB@errnoidx{#3}}{%
\expandafter\let\expandafter\SB@temp\csname SB@idxsel@#3\endcsname%
\SB@cnt#1\relax%
\ifnum\SB@cnt<\@ne\SB@cnt\SB@temp232\relax\fi%
\expandafter\SB@temp%
\expandafter\SB@maketitleindex%
\expandafter\SB@makescripindex%
\expandafter\SB@makeauthorindex%
\expandafter{\the\SB@cnt}%
{#2}{#3}%
}%
}
\makeatother


%%%% index
\renewcommand{\idxtitlefont}{\sffamily\small}%\itshape}
\renewcommand{\idxlyricfont}{\itshape\small}%\mdseries}
\renewcommand{\idxheadfont}{\calligra\bfseries\Huge}

\noversenumbers
\nosongnumbers
\songcolumns{0}



%%% Don't try to fill up every page
\raggedbottom

\setcounter{secnumdepth}{-1}

%%%%%%% Index
\newindex{index}{idxfile}

\scriptureon

\title{\large Sångbok 
\vfill
\small Denna sångbok trycktes i 1000 exemplar. Detta är exemplar Nr. \rule{0.5cm}{0.5pt}
}
\date{}

\begin{document}
\maketitle
\indexsongsas{index}{\thepage}


\pagestyle{plain}

\newpage
\tableofcontents

\include{Text/bordsvisor}

\indexeson

\injectparagraph{%
\center Rak text: Sångtitel\ ~ \emph{Kursiv text: Första raden\\
\begin{center}
\line(1,0){250}
\end{center}}}

\showindex{Register}{index}

\end{document}

And the included songs (Text/bordvisor.tex) are here:

\songchapter{Bordsvisor}
\thispagestyle{empty}
 \begin{tikzpicture}[remember picture,overlay]
   \node at (current page.center) {\includegraphics[width=\paperwidth]{bilder/kapitel/kap_bord.JPG}};
 \end{tikzpicture}
\pagebreak

\begin{songs}{index}

\beginsong{Måltidssång}[sr={Fredmans sång nr 21},by={Text \& musik: Carl Michael Bellman},index={Så lunka vi så småningom}]
\beginverse
Så lunka vi så småningom
från Bacchi buller och tumult,
när döden ropar: Granne kom,
ditt timglas är nu fullt.
Du gubbe fäll din krycka ner,
och du, du yngling, lyd min lag,
den skönsta nymf som åt dig ler
inunder armen tag.
\endverse
\endsong


\beginsong{Spritbolaget}[by={Mel.: Du kära lille snickerbo'},index={Till spritbolaget ränner jag}]
\beginverse
Till spritbolaget ränner jag
och bankar på dess port.
Jag vill ha nå’t som bränner bra
och gör mig skitfull fort.
Expediten sade goddag,
hur gammal kan min herre va’?
Har du nå’t leg ditt fula drägg?
Kom hit igen när du fått skägg.
\endverse
\endsong

\end{songs}
1
  • 1
    Welcome. // Unfortunately hardly anybody can help you right now. Suggestion: What if you'd take your big songbook, boil it down using this checklist (tex.meta.stackexchange.com/questions/228/…) and post the code here, which is small yet complex enough to spot your problem? Thank you
    – MS-SPO
    Commented Jan 10 at 19:48

2 Answers 2

1

You could download and copy the songidx.lua file to your overleaf working directory (From ctan or other resource). And then use \write18 to run command texlua songidx.lua idxfile.sxd idxfile.sbx which will update and write the correct index file for you (idxfile.sbx). I have tested this, unfortunately, you need clear cached files or Recompile from scratch each time in order to make the file updated correctly. Someone may have better solution.

Add follow code before \begin{document}:

\write18{texlua songidx.lua idxfile.sxd idxfile.sbx}
0

Here's 90 % of a solution. And yes: the key problem is close to what you suspected.

Checking for similar problems

Who reported already problems with package songs and index? See here. Amongst them was a solution, which is also, more or less, described in ch. 10 of the songs manual:

  • key here is copying at least file songidx.lua to the working directory
  • opening a command shell, set to the documents directory
  • running pdflatex and texlua as desribed in the solution several times

Copying said file, and following said solution I could generate a songbook with the two indexes wanted.

Trying your example on my local installation

Preparations:

  • from previous analysis I disabled many parts of your code, which didn't contribute to the key problem of creating an index or might have contributed to the problem
  • I copied songidx.lua there, which on my distribution is at C:\...\MiKTeX2\scripts\songs (a link or setting the PATH variable might do as well)

Next I run:

  • ...\songBookIndex>pdflatex songBookIndex.tex
  • ...\songBookIndex>texlua songidx.lua idxfile.sxd
  • ...\songBookIndex>pdflatex songBookIndex.tex

There you go: resultLocal

songBookIndex.tex

\documentclass[9pt,a6paper,openright,twoside]{extbook}
\usepackage[bookmarks]{hyperref}
\usepackage[top=15mm,bottom=15mm,left=15mm,right=10mm]{geometry}
%\addtolength{\oddsidemargin}{5mm}
\usepackage[lyric,noshading]{songs}
%\usepackage{amsmath,amssymb}
%\usepackage{amsfonts}
\usepackage{fancyhdr}   
%\usepackage{enumitem}

%\usepackage[T1]{fontenc}
%\usepackage[utf8]{inputenc}
\usepackage[swedish]{babel}
%\usepackage{calligra}
%\usepackage{lmodern}
%\usepackage{graphicx}
%\usepackage{fancyhdr}
%\usepackage{imakeidx}
%\usepackage{tikz}

%\usepackage{textcomp}

\hypersetup{
    colorlinks=false,
    pdfborder={0 0 0},
}

\setlength{\sbarheight}{0.2pt}

\renewcommand{\stitlefont}{\bf\large}
\renewcommand{\notefont}{\itshape\small}

%\makeatletter
%
%\renewcommand\showindex[3][0]{%
%\@ifundefined{SB@idxsel@#3}{\SB@errnoidx{#3}}{%
%\expandafter\let\expandafter\SB@temp\csname SB@idxsel@#3\endcsname%
%\SB@cnt#1\relax%
%\ifnum\SB@cnt<\@ne\SB@cnt\SB@temp232\relax\fi%
%\expandafter\SB@temp%
%\expandafter\SB@maketitleindex%
%\expandafter\SB@makescripindex%
%\expandafter\SB@makeauthorindex%
%\expandafter{\the\SB@cnt}%
%{#2}{#3}%
%}%
%}
%\makeatother


%%%% index
\renewcommand{\idxtitlefont}{\sffamily\small}%\itshape}
\renewcommand{\idxlyricfont}{\itshape\small}%\mdseries}
\renewcommand{\idxheadfont}{\calligra\bfseries\Huge}

\noversenumbers
\nosongnumbers
\songcolumns{0}



%%% Don't try to fill up every page
\raggedbottom

\setcounter{secnumdepth}{-1}

%%%%%%% Index
\newindex{index}{idxfile}


\scriptureon

\title{\large Sångbok 
\vfill
\small Denna sångbok trycktes i 1000 exemplar. Detta är exemplar Nr. \rule{0.5cm}{0.5pt}
}
\date{}

\begin{document}
\maketitle
\indexsongsas{index}{\thepage}


\pagestyle{plain}

\newpage
\tableofcontents

%\include{Text/bordsvisor}
\input{bordsvisor}

%\indexeson

%\injectparagraph{%
%\center Rak text: Sångtitel\ ~ \emph{Kursiv text: Första raden\\
%\begin{center}
%\line(1,0){250}
%\end{center}}}

\showindex{Register}{index}

\end{document}

bordsvisor.tex:

\songchapter{Bordsvisor}
\thispagestyle{empty}
% \begin{tikzpicture}[remember picture,overlay]
%   \node at (current page.center) {\includegraphics[width=\paperwidth]{bilder/kapitel/kap_bord.JPG}};
% \end{tikzpicture}
\pagebreak

\begin{songs}{index}

\beginsong{Måltidssång}[sr={Fredmans sång nr 21},by={Text \& musik: Carl Michael Bellman},index={Så lunka vi så småningom}]
\beginverse
Så lunka vi så småningom
från Bacchi buller och tumult,
när döden ropar: Granne kom,
ditt timglas är nu fullt.
Du gubbe fäll din krycka ner,
och du, du yngling, lyd min lag,
den skönsta nymf som åt dig ler
inunder armen tag.
\endverse
\endsong


\beginsong{Spritbolaget}[by={Mel.: Du kära lille snickerbo'},index={Till spritbolaget ränner jag}]
\beginverse
Till spritbolaget ränner jag
och bankar på dess port.
Jag vill ha nå’t som bränner bra
och gör mig skitfull fort.
Expediten sade goddag,
hur gammal kan min herre va’?
Har du nå’t leg ditt fula drägg?
Kom hit igen när du fått skägg.
\endverse
\endsong

\end{songs}

Trying this on Overleaf

Creating a project and copying your (modified) files there is no problem. However, I didn't see, whether or not, and if so, how, I could run a command shell on Overleaf.

Just copying songidx.lua didn't do the trick, of course not.

So I tried copying the files created locally, and that worked (didn't inspect which ones are really needed). So at least this could be a bypass for you:

  • create the indices on a local installation
  • copy the result to your Overleaf project
  • not nice, the missing 10 %, but anyway ...

overleaf

Remaining problem to solve

How to run a command shell on Overleaf?

  • is that possible?
  • if so: how?
  • does it also work with the free account?
  • do you need to upgrade?
  • can the actions needed be automized (and adjusted to individual needs) with Overleaf?

Perhaps towards a solution?

Searching for command shell overleaf I hit this tweet:

tweet

latexmkrc ... what's that? At least it seems to be imprtant enough that Overleaf has an article about it How to use latexmkrc with Overleaf.

You can also find questions here on TeXSE ...

Ok, time for some more experienced users to join in :)

You must log in to answer this question.

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