You can create entries in the table of contents (TOC) when importing a PDF. Here is an example:
\documentclass{article}
\usepackage{pdfpages}
\begin{document}
\tableofcontents
\includepdf[pages=-,addtotoc={
1,section,1,First Section Entry,p1,
1,subsection,1,Subsection Entry,p2,
2,section,1,Second Section Entry,p3}]
{publishing-logo+layout.pdf}
\end{document}
Parameters for each TOC entry are:
- Page number relative to the first page of the included document. Caveat: with
pages={3-10}
, the smallest possible number would be 3
.
- Level for the TOC entry
- Depth of section (1 for section, 2 for subsection, etc.)
- TOC entry
- Label for the entry
You can create two entries for a single page on different levels (like section
and subsection
). In the example, the first two entries go to the same page. A label (like p2
) can be used to refer to a page that is part of the included PDF.
Unfortunately error messages from pdfpages
are not helpful when the above list contains errors. I encountered the following error, which was hard to spot:
- With
pages={3-10}
the first entry in an addtotoc
record must be 3
or larger. It was 1
in my case but the error message wasn't pointing to it.
Any automatic solution will have a hard time beating a human well-versed in the Chicago Manual of Style's headline-style capitalization rules. So you're probably better off formatting titles in your source file manually. Whenever the document language or bibliography format calls for sentence-style capitalization, it is relatively easy to apply with biblatex's \MakeSentenceCase
macro.
That said you could write a new macro, say \MakeHeadlineCase
, and apply it in the title formatting directives. Another approach is to use biber's sourcemap
option. It supports regular expressions and modifies fields before biblatex even sees them, which means the solution is entirely style-independent.
A rough approximation to headline-style capitalization is implemented in the following source mapping. It uses the XML syntax of the biber configuration file biber.conf
. You can also specify source mappings in the document preamble with biblatex's \DeclareSourcemap
command.
<?xml version="1.0" encoding="UTF-8"?>
<config>
<sourcemap>
<maps datatype="bibtex" map_overwrite="1">
<map>
<map_step map_field_source="TITLE"
map_match="(^|\s)(\w+\S*w*)" map_replace="$1\u\L$2"/>
<map_step map_field_source="TITLE"
map_match="\-(\w+)" map_replace="\-\u\L$1"/>
<map_step map_field_source="TITLE"
map_match="(\s+|\-)(A(|n|nd|s|t)|F(or|rom)|I(n|s)|O(f|n|r)|T(he|o)|With)\b"
map_replace="$1\L$2"/>
<map_step map_field_source="TITLE"
map_match="([:;]\s+)([a-z])" map_replace="$1\u$2"/>
</map>
</maps>
</sourcemap>
</config>
The first two steps capitalize words at the beginning of the string (^
), after whitespace (\s
) or following a hyphen (\-
). The third map down-cases selected words after whitespace or a hyphen. The last map capitalizes words following a colon or semi-colon ([:;]
).
Here's a self-contained example.
\documentclass{article}
\usepackage[backend=biber]{biblatex}
\usepackage{filecontents}
\begin{filecontents*}{biber.conf}
<?xml version="1.0" encoding="UTF-8"?>
<config>
<sourcemap>
<maps datatype="bibtex" map_overwrite="1">
<map>
<map_step map_field_source="TITLE"
map_match="(^|\s)(\w+\S*w*)" map_replace="$1\u\L$2"/>
<map_step map_field_source="TITLE"
map_match="\-(\w+)" map_replace="\-\u\L$1"/>
<map_step map_field_source="TITLE"
map_match="(\s+|\-)(A(|n|nd|s|t)|B(ut|y)|F(or|rom)|I(n|s)|O(f|n|r)|T(he|o)|With)\b"
map_replace="$1\L$2"/>
<map_step map_field_source="TITLE"
map_match="([:;]\s+)([a-z])" map_replace="$1\u$2"/>
</map>
</maps>
</sourcemap>
</config>
\end{filecontents*}
\begin{filecontents*}{\jobname.bib}
@BOOK{Smith2003,
title = {This is an off-the-hook book title, but it doesn't have a subtitle},
publisher = {Penguin},
year = {2003},
author = {Smith, James},
address = {London}}
@ARTICLE{Doe1970,
author = {H{\"a}user, {\O}rnulf},
title = {{\O}rnulf H{\"a}user's letter to the editor: an $\alpha$-to-$\omega$
summary of $\epsilon$--improvement},
journal = {Great Journal},
year = {1970},
volume = {40},
pages = {207-234}}
\end{filecontents*}
\addbibresource{\jobname.bib}
\begin{document}
\nocite{*}
\printbibliography
\end{document}
Best Answer
Just put this in the preamble: