Add matrix TOC with cross-reference columns
Replace the default LaTeX TOC with a table matching the Carmina Leonis style: song titles with columns for reference books (MO, PfLB) and the current songbook page number. Uses expl3 iow to write song data to a .songtoc file during compilation and reads it back on the second pass. Alternating row colors via rowcolors. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
6
Makefile
6
Makefile
@@ -11,13 +11,13 @@ $(OUTDIR):
|
||||
mkdir -p $(OUTDIR)
|
||||
|
||||
$(OUTDIR)/$(MAIN).pdf: $(MAIN).tex songbook-style.sty songs/*.tex | $(OUTDIR)
|
||||
TEXINPUTS=.:$(shell pwd): $(ENGINE) $(FLAGS) $(MAIN).tex
|
||||
TEXINPUTS=.:$(shell pwd): $(ENGINE) $(FLAGS) $(MAIN).tex
|
||||
TEXINPUTS=.:$(shell pwd):$(shell pwd)/$(OUTDIR): $(ENGINE) $(FLAGS) $(MAIN).tex
|
||||
TEXINPUTS=.:$(shell pwd):$(shell pwd)/$(OUTDIR): $(ENGINE) $(FLAGS) $(MAIN).tex
|
||||
|
||||
clean:
|
||||
rm -f $(OUTDIR)/*.aux $(OUTDIR)/*.log $(OUTDIR)/*.out \
|
||||
$(OUTDIR)/*.toc $(OUTDIR)/*.fls $(OUTDIR)/*.fdb_latexmk \
|
||||
$(OUTDIR)/*.sxd $(OUTDIR)/*.sxc
|
||||
$(OUTDIR)/*.sxd $(OUTDIR)/*.sxc $(OUTDIR)/*.songtoc
|
||||
|
||||
distclean: clean
|
||||
rm -f $(OUTDIR)/$(MAIN).pdf
|
||||
|
||||
@@ -14,8 +14,11 @@
|
||||
\RequirePackage[hidelinks]{hyperref}
|
||||
\RequirePackage{fancyhdr}
|
||||
\RequirePackage{xcolor}
|
||||
\RequirePackage{longtable}
|
||||
\RequirePackage{array}
|
||||
\RequirePackage{colortbl}
|
||||
\RequirePackage{rotating}
|
||||
\RequirePackage[minimal]{leadsheets}
|
||||
% Pre-mark musicsymbols as loaded to avoid missing musix11 font error
|
||||
\ExplSyntaxOn
|
||||
\cs_new:cpn {leadsheets-library-musicsymbols-loaded} {}
|
||||
\ExplSyntaxOff
|
||||
@@ -25,7 +28,11 @@
|
||||
\setmainfont{TeX Gyre Heros}
|
||||
\newfontfamily\frakfont{UnifrakturMaguntia-Book}[Path=fonts/,Extension=.ttf]
|
||||
|
||||
% --- Page style: page numbers at bottom-outer, large ---
|
||||
% --- Colors ---
|
||||
\definecolor{tocrowgray}{gray}{0.92}
|
||||
\definecolor{tocheadgray}{gray}{0.75}
|
||||
|
||||
% --- Page style ---
|
||||
\pagestyle{fancy}
|
||||
\fancyhf{}
|
||||
\fancyfoot[LE]{\large\bfseries\thepage}
|
||||
@@ -47,14 +54,104 @@
|
||||
chorus/named = false,
|
||||
chorus/numbered = false,
|
||||
after-song = \songendsection,
|
||||
disable-measuring,
|
||||
}
|
||||
|
||||
% --- Chord appearance: regular weight, black (matching reference style) ---
|
||||
\setchords{
|
||||
format = \small,
|
||||
}
|
||||
|
||||
% --- Command to render metadata at bottom of song ---
|
||||
% ==========================================================================
|
||||
% Song TOC matrix
|
||||
% ==========================================================================
|
||||
|
||||
\newcounter{songnumber}
|
||||
\newcounter{tocrowcount}
|
||||
|
||||
\ExplSyntaxOn
|
||||
\iow_new:N \g__sb_toc_iow
|
||||
\tl_new:N \l__sb_title_tl
|
||||
\tl_new:N \l__sb_mo_tl
|
||||
\tl_new:N \l__sb_pflb_tl
|
||||
\tl_new:N \l__sb_num_tl
|
||||
\bool_new:N \g__sb_toc_opened_bool
|
||||
|
||||
% Lazy-open: only truncate the file when first song writes to it
|
||||
% This ensures the TOC reads the PREVIOUS run's data before truncation
|
||||
\cs_new_protected:Npn \__sb_ensure_toc_open:
|
||||
{
|
||||
\bool_if:NF \g__sb_toc_opened_bool
|
||||
{
|
||||
\iow_open:Nn \g__sb_toc_iow { \c_sys_jobname_str .songtoc }
|
||||
\bool_gset_true:N \g__sb_toc_opened_bool
|
||||
}
|
||||
}
|
||||
|
||||
\AtEndDocument{
|
||||
\bool_if:NT \g__sb_toc_opened_bool
|
||||
{ \iow_close:N \g__sb_toc_iow }
|
||||
}
|
||||
|
||||
\cs_new_protected:Npn \writesongtoc
|
||||
{
|
||||
\__sb_ensure_toc_open:
|
||||
\stepcounter{songnumber}
|
||||
\tl_set:Nx \l__sb_num_tl { \int_use:N \c@songnumber }
|
||||
\label{song:\tl_use:N \l__sb_num_tl}
|
||||
\tl_set:Nx \l__sb_title_tl { \songproperty{title} }
|
||||
\tl_set:Nx \l__sb_mo_tl { \songproperty{mundorgel} }
|
||||
\tl_set:Nx \l__sb_pflb_tl { \songproperty{pfadfinderliederbuch} }
|
||||
\iow_now:Nx \g__sb_toc_iow
|
||||
{
|
||||
\exp_not:N \songtocrow
|
||||
{ \l__sb_title_tl }
|
||||
{ \l__sb_mo_tl }
|
||||
{ \l__sb_pflb_tl }
|
||||
{ \exp_not:N \pageref { song: \l__sb_num_tl } }
|
||||
}
|
||||
}
|
||||
\ExplSyntaxOff
|
||||
|
||||
% --- Render one TOC row ---
|
||||
\newcommand{\songtocrow}[4]{%
|
||||
#1 & #2 & #3 & \cellcolor{tocheadgray}\textbf{#4} \\
|
||||
\hline
|
||||
}
|
||||
|
||||
% --- Rotated column header ---
|
||||
\newcommand{\rotheader}[1]{%
|
||||
\begin{turn}{70}\footnotesize\textbf{#1}\end{turn}%
|
||||
}
|
||||
|
||||
% --- Print the song TOC table ---
|
||||
\newcommand{\printsongtoc}{%
|
||||
\thispagestyle{fancy}%
|
||||
{\Large\bfseries Inhaltsverzeichnis\par}%
|
||||
\vspace{5mm}%
|
||||
\footnotesize
|
||||
\rowcolors{2}{tocrowgray}{white}%
|
||||
\begin{longtable}{%
|
||||
>{\raggedright\arraybackslash}p{0.52\textwidth}|%
|
||||
>{\centering\arraybackslash}p{0.10\textwidth}|%
|
||||
>{\centering\arraybackslash}p{0.10\textwidth}|%
|
||||
>{\centering\arraybackslash\columncolor{tocheadgray}}p{0.12\textwidth}%
|
||||
}
|
||||
& \rotheader{MO} & \rotheader{PfLB}
|
||||
& \rotheader{\normalsize Lieder-\newline\normalsize buch} \\
|
||||
\hline
|
||||
\endfirsthead
|
||||
& \rotheader{MO} & \rotheader{PfLB}
|
||||
& \rotheader{\normalsize Lieder-\newline\normalsize buch} \\
|
||||
\hline
|
||||
\endhead
|
||||
\InputIfFileExists{\jobname.songtoc}{}{}%
|
||||
\end{longtable}%
|
||||
}
|
||||
|
||||
% ==========================================================================
|
||||
% Song end section
|
||||
% ==========================================================================
|
||||
|
||||
\newcommand{\songendsection}{%
|
||||
\vfill
|
||||
\ifsongproperty{note}{%
|
||||
@@ -74,7 +171,6 @@
|
||||
}{}%
|
||||
}%
|
||||
\endgroup
|
||||
% Reference book footer
|
||||
\vspace{3mm}%
|
||||
\begingroup\footnotesize
|
||||
\noindent
|
||||
@@ -92,9 +188,12 @@
|
||||
\newpage
|
||||
}
|
||||
|
||||
% --- Song title template: Fraktur title, metadata at bottom ---
|
||||
% ==========================================================================
|
||||
% Song title template
|
||||
% ==========================================================================
|
||||
|
||||
\definesongtitletemplate{songbook}{%
|
||||
{\LARGE\frakfont\songproperty{title}\par}%
|
||||
\addcontentsline{toc}{section}{\songproperty{title}}%
|
||||
\writesongtoc
|
||||
\vspace{4mm}%
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
\end{titlepage}
|
||||
|
||||
% --- Table of Contents ---
|
||||
\tableofcontents
|
||||
\printsongtoc
|
||||
\clearpage
|
||||
|
||||
% --- Songs (alphabetical) ---
|
||||
|
||||
Reference in New Issue
Block a user