unbuch icon indicating copy to clipboard operation
unbuch copied to clipboard

How does one render the footnote number in References / Bibliography (PDF output)?

Open lvanbever opened this issue 2 years ago • 1 comments

Hi Moritz,

First off, thanks a lot for unbuch! I've been playing with it lately and I'm thinking of using it for typesetting my lecture notes for the upcoming semester.

One thing I'm currently struggling with relates to the way the bibliography is rendered in PDF. While the bib entries themselves are rendered correctly, they somehow miss the footnote number corresponding to the citation (I'm trying to replicate the setup of the mlstory book where each entry is preceded by the corresponding superscript):

Screenshot 2022-12-12 at 13 06 17

Any chance you could share the relevant part of the setup? I've been exploring pandoc and citeproc, but no luck thus far. (Is that something one is supposed to adapt the .csl for?).

In case it helps, here is the relevant output of my pandoc --version:

pandoc 2.14
Compiled with pandoc-types 1.22, texmath 0.12.3, skylighting 0.10.5.1,
citeproc 0.4, ipynb 0.1.0.1

lvanbever avatar Dec 12 '22 12:12 lvanbever

Hi Laurent,

I'm sorry I missed this comment. The mlstory setup is indeed a bit different from the basic unbuch version. Here is the part of the Makefile that sets the book.

## Step 1: Give each markdown file a chapter heading.
## Step 2: Compile markdown sources into tex using pandoc
## Step 3: Compile tex sources using pdflatex
publish/pdf/$(bookfilename).pdf: $(CHAPTERS) templates/book.tex templates/references.md Makefile $(FILTERS) templates/shared-macros.tex references.bib sources/preface.md sources/acknowledgments.md
	$(foreach chapter,$(CHAPTERS),\
      pandoc --template templates/chapter.md $(chapter) \
      --id-prefix=$(notdir $(chapter)) \
      --output tmp-$(notdir $(chapter));) \
    pandoc \
    --natbib \
    --metadata link-citations=false \
    --filter ./filters/whitespace.py \
    --filter ./filters/numenvs.py \
    --filter ./filters/crossrefs.py \
    --filter ./filters/svgimagext.py \
    --filter ./filters/sidenote.py \
    --template templates/book.tex \
    --variable book-layout=true \
    --variable booktitle="${booktitle}" \
    --variable booksubtitle="${booksubtitle}" \
    --variable bookauthors="${bookauthors}" \
    --variable lastupdate="`date`" \
    --variable titlepagefootnote="${titlepagefootnote}" \
    --variable acknowledgments="`pandoc -t latex sources/acknowledgments.md`" \
    --variable preface="`pandoc -t latex sources/preface.md`" \
    --variable macros="`cat templates/shared-macros.tex`" \
    --output $(bookfilename).tex \
    $(foreach chapter,$(CHAPTERS),tmp-$(notdir $(chapter))); \
    $(foreach chapter,$(CHAPTERS),rm tmp-$(notdir $(chapter));) \
    mkdir -p tex/assets; \
    cp assets/*.pdf tex/assets; \
    cp assets/*.png tex/assets; \
    cp assets/*.jpg tex/assets; \
    cp references.bib tex/; \
    mv $(bookfilename).tex tex/; \
    cd tex; \
    pdflatex $(bookfilename).tex; \
    makeindex $(bookfilename); \
    bibtex $(bookfilename); \
    pdflatex $(bookfilename).tex; \
    pdflatex $(bookfilename).tex; \
    rm *.aux *.log *.blg *.out *.bib; \
    mv $(bookfilename).pdf ../publish/pdf;

The other edits are in the template book.tex:

\documentclass[oneside,12pt]{book}

\usepackage[utf8]{inputenc}

\usepackage{graphicx}
\setkeys{Gin}{width=\linewidth,totalheight=\textheight,keepaspectratio}

\usepackage{xcolor}
\definecolor{darkblue}{HTML}{00416A}

\usepackage{longtable}
\usepackage{booktabs}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{boxedminipage}
\usepackage{microtype}
\usepackage{makeidx}
\usepackage{hyperref}
\usepackage{ifthen}
\usepackage{array}
\usepackage{calc}

\usepackage{titlesec,titletoc}

\usepackage[letterpaper,textwidth=5.5in,textheight=8.5in]{geometry}

\usepackage[osf,sc]{mathpazo}
\RequirePackage[scaled=0.90]{helvet}
\RequirePackage[scaled=0.85]{beramono}
\RequirePackage[T1]{fontenc}
\RequirePackage{textcomp}

\usepackage[square,sort,comma,numbers]{natbib}
\usepackage[superscript,biblabel]{cite}
\renewcommand{\citep}[1]{\cite{#1}}



\pagestyle{plain}

%%
% Make Tuftian-style section headings and TOC formatting

\titleformat{\chapter}%
  [display]% shape
  {\relax}% format applied to label+text
  {\itshape\huge\thechapter}% label
  {0pt}% horizontal separation between label and title body
  {\huge\rmfamily\itshape}% before the title body
  []% after the title body

\titleformat{\section}%
  [hang]% shape
  {\normalfont\Large\itshape}% format applied to label+text
  {\thesection}% label
  {1em}% horizontal separation between label and title body
  {}% before the title body
  []% after the title body

\titleformat{\subsection}%
  [hang]% shape
  {\normalfont\large\itshape}% format applied to label+text
  {\thesubsection}% label
  {1em}% horizontal separation between label and title body
  {}% before the title body
  []% after the title body

\titleformat{\paragraph}%
  [runin]% shape
  {\normalfont\itshape}% format applied to label+text
  {\theparagraph}% label
  {1em}% horizontal separation between label and title body
  {}% before the title body
  []% after the title body

\titlespacing*{\chapter}{0pt}{50pt}{40pt}
\titlespacing*{\section}{0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\titlespacing*{\subsection}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus.2ex}

\makeatother

\newtheorem{Definition}{Definition}
\newtheorem{Theorem}{Theorem}
\newtheorem{Lemma}{Lemma}
\newtheorem{Exercise}{Exercise}
\newtheorem{Fact}{Fact}
\newtheorem{Proposition}{Proposition}
\newtheorem{Assumption}{Assumption}
\newenvironment{Algorithm}{\begin{center}\begin{boxedminipage}{0.92\textwidth}}{\end{boxedminipage}\end{center}}
\newenvironment{Proof}{\begin{proof}}{\end{proof}}
\newtheorem*{summary*}{Summary}
\newenvironment{Summary}{\begin{center}\begin{minipage}{0.92\textwidth}\begin{summary*}}{\end{summary*}\end{minipage}\end{center}\medskip}
\newenvironment{EmphBox}{\begin{center}\begin{minipage}{0.8\textwidth}}{\end{minipage}\end{center}\medskip}

\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}

\renewcommand{\bot}{\perp}
\renewcommand{\hat}{\widehat}

\usepackage{wrapfig}
\usepackage{marginfix}
\usepackage[morefloats=100]{morefloats}

\newcommand{\marginnote}[1]{
\begin{wrapfigure}{o}{0.4\textwidth}
\footnotesize #1
\end{wrapfigure}
}

\renewcommand{\footnote}[1]{\marginnote{#1}}

\setcounter{secnumdepth}{0}
\makeatletter
\renewcommand{\@seccntformat}[1]{}
\makeatother

$macros$

%
% Book specific layout
%

$if(book-layout)$

\usepackage{ifthen}
\usepackage{chngcntr}
\counterwithout{figure}{chapter}
\counterwithout{table}{chapter}

\hypersetup{
  colorlinks,
  linkcolor = black,
  urlcolor = black,
  pdftitle = {$booktitle$},
  pdfauthor = {$bookauthors$},
  hyperindex = true
}

\usepackage{eso-pic}
\newcommand\BackgroundPic{%
\put(0,0){%
\parbox[b][\paperheight]{\paperwidth}{%
\vfill
\centering
\includegraphics[width=\paperwidth,height=\paperheight,%
keepaspectratio]{assets/cargo-cult-pixels-lower.png}%
\vfill
}}}
\title{$booktitle$}
\author{$bookauthors$}
\setcounter{tocdepth}{1}

\makeindex

\newif\ifshowchapternumber


\let\OLDthebibliography\thebibliography
\renewcommand\thebibliography[1]{
  \OLDthebibliography{#1}
  \setlength{\parskip}{0pt}
  \setlength{\itemsep}{0pt plus 0.5ex}
}

\begin{document}
\AddToShipoutPicture*{\BackgroundPic}

\pagenumbering{roman}

\definecolor{browntext}{RGB}{85,70,44}
\definecolor{authortext}{RGB}{118,16,0}

\noindent{\Huge\tt\color{browntext}\uppercase{$booktitle$}}

\vspace{1cm}

\noindent{\huge\tt\color{browntext} $booksubtitle$}

\vspace{3cm}

\noindent{\LARGE \tt \color{authortext} $bookauthors$}

\thispagestyle{empty}

\pagebreak

\vfill

\noindent Licensed under the \href{https://creativecommons.org/licenses/by-nc-nd/4.0/}{Creative Commons BY-NC-ND 4.0} license. 


\vspace{1cm}

\noindent Compiled on $lastupdate$.

\noindent Latest version available at \url{https://mlstory.org}.

\thispagestyle{empty}

\pagebreak

\vspace{2cm}

For Isaac, Leonora, and Quentin

\thispagestyle{empty}

\pagebreak

\tableofcontents

\chapter*{Preface}

$preface$

\chapter*{Acknowledgments}

$acknowledgments$

\mainmatter

\sloppy

\setcounter{page}{1}
\pagenumbering{arabic}

$body$

\backmatter

\footnotesize

\bibliographystyle{unsrt}
\bibliography{references}

\listoffigures
\listoftables
\printindex

$endif$

%
% Layout for individual chapters
%
$if(chapter-layout)$

\hypersetup{
  colorlinks,
  linkcolor = darkblue,
  urlcolor = darkblue,
  pdftitle = {$booktitle$ - $title$},
  pdfauthor = {$bookauthors$}
}

\title{$booktitle$ - $lastupdate$}
\author{$bookauthors$}

\begin{document}

\noindent {\huge\textit{\textbf{$chapter-number$}}}

\vspace{1cm}

\noindent {\huge\it $title$}

\vspace{1.5cm}

$body$

\bibliographystyle{unsrt}
\bibliography{references}

$endif$


\end{document}

I hope this helps. One of these days, I'll try to clean up the files and update the repo.

mrtzh avatar Feb 10 '23 09:02 mrtzh