Blog 1

Random Talk on Random Thoughts

Writting Letter With Bibliography

| Comments |

Background

Recently, I need to write letters. Get the formatting for addressee and sender automatically done, I choose $\rm \LaTeX$. I cite a book in my letter, and try to add a bibliography at the end of the letter.

Problem

During the compilation for the following letter, an error was thrown.

A failed $\rm \LaTeX$ letter (noltrbib.tex) download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
\documentclass[12pt]{lettre}
\usepackage{fontspec}
\usepackage[frenchb]{babel}
\usepackage[backend=biber]{biblatex}
\addbibresource{ltrbib.bib}
\usepackage{csquotes}

\begin{document}
\begin{letter}{
    Nom de destinataire \\
    4, boulevard de la Paix, \\
    12345 Nom de ville
}

  \name{Votre NOM}
  \address{
    Votre NOM\\
    23, rue à votre ville \\
    23456 Nom de votre ville
  }
  \lieu{Votre ville}
  \telephone{01 02 03 04 05}
  \nofax

  \def\concname{Objet :~}
  \conc{Saisir votre objet}
  \opening{Madame, Monsieur,}

  Un exemple de citation dans un document $\rm \LaTeX$.  \cite{serre}
  Le faux texte ci-dessous est généré par le plugin Lorem Ipsum pour
  Vim.

% lorem{{{
  Curabitur eget nisi at lectus placerat gravida. Vivamus nulla. Donec
  luctus. Sed quis tellus. Quisque lobortis faucibus mi. Aenean vitae
  risus ut arcu malesuada ornare. Maecenas.

  Amet, rhoncus in, ipsum. Mauris rhoncus, lacus eu convallis sagittis,
  quam magna placerat est, vitae imperdiet mauris arcu ac dui. In ac
  urna non justo posuere mattis. Suspendisse egestas bibendum nulla. In
  erat nunc, posuere sed, auctor quis, pulvinar quis, mi. Mauris at est.
  Phasellus lacinia eros in arcu. Maecenas lobortis, tellus vel gravida
  tincidunt, elit erat suscipit arcu, in varius erat risus vel magna.
  Fusce nec ante quis dolor vestibulum bibendum. Pellentesque sit amet
  urna.
% lorem}}}

  \closing{Veuillez d'agréer, Madame, Monsieur, mes salutations les
  meilleures.}

  \printbibliography
\end{letter}
\end{document}
A sample Bib$\rm \LaTeX$ file (ltrbib.bib) download
1
2
3
4
5
6
7
8
9
@BOOK{serre,
    author = {Serre, J. P.},
    title = {Cours d'arithmétique},
    publisher = {Presse Universitaire de France},
    year = {1970},
    edition = {1ère ed.},
    address = {Paris, France},
    pages = {103--106},
}

Here’s my compilation procedure.

$ xelatex noltrbib.tex
$ biber noltrbib
$ xelatex noltrbib.tex
This is XeTeX, Version 3.1415926-2.5-0.9999.3 (TeX Live 2013/Debian)
 restricted \write18 enabled.
...
! Undefined control sequence.
\\blx@head@bibliography [#1]->\section 
                                       *{#1}\markboth {\MakeUppercase {#1}}{...
l.52 \end
         {letter}
?
...

I type <Enter> at ?, and get a PDF that seems OK. You may read the log file for this file to know more about this error. However, each time I use $\rm \LaTeX$-Suite to compile the document inside Vim, a quickfix window pops up. This is quite inconvenient: I need to use <C-w>k to switch to the original buffer or ZQ to close the quickfix window. Therefore, I am motivated to find out a solution for this error.

Solution

Luckily, I find the thread Environment thebibliography undefined when using letter in $\rm \LaTeX$ Forum extremely useful. In my opinion, if one can include inline code in a post in this forum, the file name letterbib.sty and the command in the preamble can be shown in monospaced font for readability.

A minimal working $\rm \LaTeX$ letter (ltrbib.tex) download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
\documentclass[12pt]{lettre}
\usepackage{fontspec}
\usepackage[frenchb]{babel}
\usepackage[backend=biber]{biblatex}
\addbibresource{ltrbib.bib}
\usepackage{csquotes}
\usepackage{letterbib}

\begin{document}
\begin{letter}{
    Nom de destinataire \\
    4, boulevard de la Paix, \\
    12345 Nom de ville
}

  \name{Votre NOM}
  \address{
    Votre NOM\\
    23, rue à votre ville \\
    23456 Nom de votre ville
  }
  \lieu{Votre ville}
  \telephone{01 02 03 04 05}
  \nofax

  \def\concname{Objet :~}
  \conc{Saisir votre objet}
  \opening{Madame, Monsieur,}

  Un exemple de citation dans un document $\rm \LaTeX$.  \cite{serre}
  Le faux texte ci-dessous est généré par le plugin Lorem Ipsum pour
  Vim.

% lorem{{{
  Curabitur eget nisi at lectus placerat gravida. Vivamus nulla. Donec
  luctus. Sed quis tellus. Quisque lobortis faucibus mi. Aenean vitae
  risus ut arcu malesuada ornare. Maecenas.

  Amet, rhoncus in, ipsum. Mauris rhoncus, lacus eu convallis sagittis,
  quam magna placerat est, vitae imperdiet mauris arcu ac dui. In ac
  urna non justo posuere mattis. Suspendisse egestas bibendum nulla. In
  erat nunc, posuere sed, auctor quis, pulvinar quis, mi. Mauris at est.
  Phasellus lacinia eros in arcu. Maecenas lobortis, tellus vel gravida
  tincidunt, elit erat suscipit arcu, in varius erat risus vel magna.
  Fusce nec ante quis dolor vestibulum bibendum. Pellentesque sit amet
  urna.
% lorem}}}

  \closing{Veuillez d'agréer, Madame, Monsieur, mes salutations les
  meilleures.}

  \printbibliography
\end{letter}
\end{document}

Finally, no compilation error is shown in the generated log. You may view the second generated PDF.

Lessons learnt

To install the above STY file, which isn’t found on CTAN, one needs to manually download it to ~/texmf on *nix. (Search “~/texmf” for the way to find “temxf” on Win*.) Searching “texmf linux refresh”, I find the way for a $\rm \TeX$ database update. I miss the first argument in the command texhash ~/texmf, and then the installed STY file can’t be found in ~/texmf/ls-R.

Comments