Skip to content

Commit

Permalink
LaTeX generator upgrades (#49).
Browse files Browse the repository at this point in the history
  • Loading branch information
oskarr committed Aug 22, 2023
1 parent 63d893c commit 053ab88
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 27 deletions.
81 changes: 55 additions & 26 deletions public/tex/blad.cls
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
% Filename: blad.cls
% Author: Arno Lepisk (2003, v 1.0)
% Oskar Rune (2021, v 1.2.0)
% Author: Arno Lepisk (v1.0, 2003)
% Oskar Rune (v1.2.0, 2021 & v1.2.1, 2023)
%
% Version: 1.2.0. Not backwards-compatible with versions 1.0 and 1.1.x
% Version: 1.2.1. Not backwards-compatible with versions 1.0-1.1.x.
% Compatible with 1.2.0 when song indices are disabled. (I.e. use \newcommand{\songindex}[1]{})

% This is a LaTeX2e document class.

Expand All @@ -16,6 +17,9 @@

\LoadClass[a4paper]{article}

%
% Packages
%
\RequirePackage[swedish]{babel}
\RequirePackage[utf8]{inputenc}
\RequirePackage[T1]{fontenc}
Expand All @@ -25,11 +29,13 @@
\RequirePackage{xspace}
\RequirePackage{ifthen}
\RequirePackage{quoting}

\RequirePackage{verbatim}
\RequirePackage{comment}

\RequirePackage{amsmath,amsfonts,amssymb,bm}
\RequirePackage{graphicx,svg}
\RequirePackage{fancyhdr}

\RequirePackage{amsmath,amsfonts,amssymb,graphicx}
\RequirePackage{svg}

%
% Layout
Expand Down Expand Up @@ -59,41 +65,43 @@
\setlength{\paperwidth}{.5\paperwidth}

\setlength{\textwidth}{.96\paperwidth}
\setlength{\textheight}{.95\paperheight}
\setlength{\textheight}{.95\paperheight-10mm} % One may want to remove the "-10mm" when not using page-numbering

%
% Booklet setup
%
\usepackage[print]{booklet}
\RequirePackage[print]{booklet}
\source{\magstep1}{\paperwidth}{\paperheight}
\target{\magstep1}{2\paperwidth}{\paperheight}

%
% Page numbering
%
\pagestyle{fancy} % May be set to "empty" if not using numbering
\pagenumbering{arabic} % May be set to "none" if not using numbering
\renewcommand{\headrulewidth}{0pt} % Removes the horizontal line from the header
\fancyhead{} % Clear default header
\fancyfoot[C]{\thepage} % Set footer (C = center) to display page numbers

\pagestyle{empty}

%
% Song template
%
\newcommand{\songtitle}[1]{
\newcommand{\songindex}[1]{#1. } % Extracted so that it can be overridden.
\newcommand{\songtitle}[2][]{
\begin{flushleft}
\subsection*{#1}
\subsection*{\boldmath\songindex{#1}#2\unboldmath}
\end{flushleft}
% \nopagebreak
}
\newcommand{\melody}[1]{
% \nopagebreak
\vspace*{0.1cm}
\begin{quoting}[leftmargin=6mm]
\small{\textit{#1}}
\end{quoting}
\begin{quoting}[leftmargin=6mm]\small{\textit{#1}}\end{quoting}
\vspace*{-3mm}
% \nopagebreak
}
\newenvironment{lyrics}{
% \nopagebreak
\vspace*{1mm}
\begin{verse}
}{
\end{verse}
% \nopagebreak
}
\newcommand{\auth}[1]{
% \nopagebreak
\vspace*{0.1cm}
Expand All @@ -103,25 +111,39 @@
\end{flushright}
\end{verse}
}
\newenvironment{lyrics}{
% \nopagebreak
\vspace*{1mm}
\begin{verse}
}{
\end{verse}
% \nopagebreak
}

% fkm* logo
\newcommand{\fkm}{\mbox{{\raisebox{-0.2ex}
{\rotatebox{22}{\bf{f}}}\hspace{-0.16em}\raisebox{0.2ex}
{\rotatebox{-15}{\bf{k}}}\hspace{-0.17em}\bf{m}\hspace{-0.15em}\raisebox{0.6ex}
{\scalebox{0.6}{\bf{*}}}}}\xspace}

\pagenumbering{none}
\pagestyle{empty}

%
% Special character handling
% Special character handling (TODO: Add all greek letters)
%
\DeclareUnicodeCharacter{0394}{$\Delta$} % Δ
\DeclareUnicodeCharacter{03A9}{$\Omega$} % Ω
\DeclareUnicodeCharacter{03B1}{$\alpha$} % α
\DeclareUnicodeCharacter{03B2}{$\beta$} % β
\DeclareUnicodeCharacter{03B3}{$\gamma$} % γ
\DeclareUnicodeCharacter{03B4}{$\delta$} % δ
\DeclareUnicodeCharacter{03B5}{$\varepsilon$} % ε
\DeclareUnicodeCharacter{03B6}{$\zeta$} % ζ
\DeclareUnicodeCharacter{03BA}{$\kappa$} % κ
\DeclareUnicodeCharacter{03BB}{$\lambda$} % λ
\DeclareUnicodeCharacter{03B7}{$\eta$} % η
\DeclareUnicodeCharacter{03B8}{$\theta$} % θ
\DeclareUnicodeCharacter{03B9}{$\iota$} % ι
\DeclareUnicodeCharacter{03BC}{$\mu$} % μ
\DeclareUnicodeCharacter{03BD}{$\nu$} % ν
\DeclareUnicodeCharacter{03C0}{$\pi$} % π
\DeclareUnicodeCharacter{03C1}{$\rho$} % ρ
\DeclareUnicodeCharacter{03C3}{$\sigma$} % σ
Expand All @@ -138,6 +160,11 @@

\DeclareUnicodeCharacter{1E8D}{$\ddot{x}$} %
\DeclareUnicodeCharacter{1E8B}{$\dot{x}$} %
\DeclareUnicodeCharacter{2124}{$\mathbb{Z}$} %
\DeclareUnicodeCharacter{2200}{$\forall$} %
\DeclareUnicodeCharacter{2208}{$\in$} %
\DeclareUnicodeCharacter{2297}{$\otimes$} %
\DeclareUnicodeCharacter{221E}{$\infty$} %
\DeclareUnicodeCharacter{2205}{$\emptyset$} %
\DeclareUnicodeCharacter{2229}{$\cap$} %
\DeclareUnicodeCharacter{222A}{$\cup$} %
Expand All @@ -147,4 +174,6 @@
\DeclareUnicodeCharacter{27F8}{$\Leftarrow$} %
\DeclareUnicodeCharacter{2202}{$\partial$} %
\DeclareUnicodeCharacter{2260}{$\neq$} %
\DeclareUnicodeCharacter{2228}{$\lor$} %
\DeclareUnicodeCharacter{2228}{$\lor$} %
\DeclareUnicodeCharacter{230A}{$\lfloor$} %
\DeclareUnicodeCharacter{230B}{$\rfloor$} %
2 changes: 1 addition & 1 deletion src/utils/export/contentTeX.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default function getContentTeX(songs: Song[], gs: GeneralSettings, ss: Sp
'\\pagebreak[3]\n',
// Try to get everything else on the same page
'\\begin{samepage}\n',
`\\songtitle{${escapeAll(song.title)}}\n`,
`\\songtitle[${escapeAll(song.index)}]{${escapeAll(song.title)}}\n`,
...getMelodyContent(gs, song),
'\\begin{lyrics}\n'
)
Expand Down
12 changes: 12 additions & 0 deletions src/utils/export/generalSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ export type GeneralSettings = {
title: StringSetting,
showLogo: BoolSetting,
showDate: BoolSetting,
showPageNumbers: BoolSetting,
showMelody: BoolSetting,
showIndices: BoolSetting,
showAuthor: BoolSetting,
showSheetMusicNotice: BoolSetting
}
Expand All @@ -27,11 +29,21 @@ export const generalSettings: GeneralSettings = {
type: 'bool',
value: true
},
showPageNumbers: {
text: 'Inkludera sidnummer',
type: 'bool',
value: true
},
showMelody: {
text: 'Inkludera melodi',
type: 'bool',
value: true
},
showIndices: {
text: 'Inkludera index',
type: 'bool',
value: false
},
showAuthor: {
text: 'Inkludera författare',
type: 'bool',
Expand Down
2 changes: 2 additions & 0 deletions src/utils/export/mainTeX.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export default function getMainTeX(gs: GeneralSettings): string {
`${gs.showDate.value ? '%' : ''}\\date{}\t%Ta bort kommentaren om du inte vill ha med datum.`,
`${gs.showAuthor.value ? '%' : ''}\\renewcommand{\\auth}[1]{}\t%Ta bort kommentaren om du inte vill ha med upphovspersons-angivelse.`,
`${gs.showMelody.value ? '%' : ''}\\renewcommand{\\melody}[1]{}\t%Ta bort kommentaren om du inte vill ha med melodier.`,
`${gs.showIndices.value ? '%' : ''}\\renewcommand{\\songindex}[1]{}\t%Ta bort kommentaren om du inte vill ha med index.`,
`${gs.showPageNumbers.value ? '%' : ''}\\fancyfoot{}\\setlength{\\textheight}{.95\\paperheight} \t%Ta bort kommentaren om du inte vill ha med sidnummer.`,
'\n\n\\begin{document}\n\\maketitle\n\\input{content.tex}\n\\end{document}'
)
return out.join('\n')
Expand Down

0 comments on commit 053ab88

Please sign in to comment.