[Tex/LaTex] BibTeX Problem: Can be used only in preamble

biblatexbibtex

This is the MWE:

\documentclass{scrbook}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[backend=bibtex,style=authoryear,citestyle=authoryear]{biblatex} 
\addbibresource{literatur.bib}
\begin{document}
\chapter{Introduction}
The article \cite{duffie2003} is great
\bibliography{literatur}
\printbibliography
\end{document}

This is the .bib file:

@Article{duffie2003,
author = "Duffie, D. and Filipović, D. and Schachermayer, W.",
doi = "10.1214/aoap/1060202833",
fjournal = "The Annals of Applied Probability",
journal = "Ann. Appl. Probab.",
month = "08",
number = "3",
pages = "984--1053",
publisher = "The Institute of Mathematical Statistics",
title = "Affine processes and applications in finance",
url = "https://doi.org/10.1214/aoap/1060202833",
volume = "13",
year = "2003"
}

This is the .log file:

This is pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2018) (preloaded format=pdflatex 2018.8.10)  30 AUG 2018 02:38
entering extended mode
 restricted \write18 enabled.
 %&-line parsing enabled.
**document.tex
(./document.tex
LaTeX2e <2018-04-01> patch level 5
(/usr/local/texlive/2018/texmf-dist/tex/latex/koma-script/scrbook.cls
Document Class: scrbook 2018/03/30 v3.25 KOMA-Script document class (book)
(/usr/local/texlive/2018/texmf-dist/tex/latex/koma-script/scrkbase.sty
Package: scrkbase 2018/03/30 v3.25 KOMA-Script package (KOMA-Script-dependent b
asics and keyval usage)

(/usr/local/texlive/2018/texmf-dist/tex/latex/koma-script/scrbase.sty
Package: scrbase 2018/03/30 v3.25 KOMA-Script package (KOMA-Script-independent 
basics and keyval usage)

(/usr/local/texlive/2018/texmf-dist/tex/latex/graphics/keyval.sty
Package: keyval 2014/10/28 v1.15 key=value parser (DPC)
\KV@toks@=\toks14
)
(/usr/local/texlive/2018/texmf-dist/tex/latex/koma-script/scrlfile.sty
Package: scrlfile 2018/03/30 v3.25 KOMA-Script package (loading files)
)))
(/usr/local/texlive/2018/texmf-dist/tex/latex/koma-script/tocbasic.sty
Package: tocbasic 2018/03/30 v3.25 KOMA-Script package (handling toc-files)
\scr@dte@tocline@numberwidth=\skip41
\scr@dte@tocline@numbox=\box26
)
Package tocbasic Info: omitting babel extension for `toc'
(tocbasic)             because of feature `nobabel' available
(tocbasic)             for `toc' on input line 136.
Package tocbasic Info: defining new hook before heading of `' on input line 166
3.
Class scrbook Info: File `scrsize11pt.clo' used instead of
(scrbook)           file `scrsize11.clo' to setup font sizes on input line 2331
.

(/usr/local/texlive/2018/texmf-dist/tex/latex/koma-script/scrsize11pt.clo
File: scrsize11pt.clo 2018/03/30 v3.25 KOMA-Script font size class option (11pt
)
)
(/usr/local/texlive/2018/texmf-dist/tex/latex/koma-script/typearea.sty
Package: typearea 2018/03/30 v3.25 KOMA-Script package (type area)
\ta@bcor=\skip42
\ta@div=\count80
\ta@hblk=\skip43
\ta@vblk=\skip44
\ta@temp=\skip45
\footheight=\skip46
Package typearea Info: These are the values describing the layout:
(typearea)             DIV  = 10
(typearea)             BCOR = 0.0pt
(typearea)             \paperwidth      = 597.50793pt
(typearea)              \textwidth      = 418.25555pt
(typearea)              DIV departure   = -6%
(typearea)              \evensidemargin = 47.2316pt
(typearea)              \oddsidemargin  = -12.5192pt
(typearea)             \paperheight     = 845.04694pt
(typearea)              \textheight     = 595.80026pt
(typearea)              \topmargin      = -25.16531pt
(typearea)              \headheight     = 17.0pt
(typearea)              \headsep        = 20.40001pt
(typearea)              \topskip        = 11.0pt
(typearea)              \footskip       = 47.6pt
(typearea)              \baselineskip   = 13.6pt
(typearea)              on input line 1706.
)
\c@part=\count81
\c@chapter=\count82
\c@section=\count83
\c@subsection=\count84
\c@subsubsection=\count85
\c@paragraph=\count86
\c@subparagraph=\count87
\scr@dte@part@maxnumwidth=\skip47
\scr@dte@chapter@maxnumwidth=\skip48
\scr@dte@section@maxnumwidth=\skip49
\scr@dte@subsection@maxnumwidth=\skip50
\scr@dte@subsubsection@maxnumwidth=\skip51
\scr@dte@paragraph@maxnumwidth=\skip52
\scr@dte@subparagraph@maxnumwidth=\skip53
\abovecaptionskip=\skip54
\belowcaptionskip=\skip55
\c@pti@nb@sid@b@x=\box27
\scr@dte@figure@maxnumwidth=\skip56
Package tocbasic Info: omitting babel extension for `lof'
(tocbasic)             because of feature `nobabel' available
(tocbasic)             for `lof' on input line 6251.
\c@figure=\count88
\scr@dte@table@maxnumwidth=\skip57
Package tocbasic Info: omitting babel extension for `lot'
(tocbasic)             because of feature `nobabel' available
(tocbasic)             for `lot' on input line 6272.
\c@table=\count89
Class scrbook Info: Redefining `\numberline' on input line 6445.
\bibindent=\dimen102
)
(/usr/local/texlive/2018/texmf-dist/tex/generic/babel/babel.sty
Package: babel 2018/06/05 3.22 The Babel package

(/usr/local/texlive/2018/texmf-dist/tex/generic/babel/switch.def
File: switch.def 2018/06/05 3.22 Babel switching mechanism
)
(/usr/local/texlive/2018/texmf-dist/tex/generic/babel-english/english.ldf
Language: english 2017/06/06 v3.3r English support from the babel system

(/usr/local/texlive/2018/texmf-dist/tex/generic/babel/babel.def
File: babel.def 2018/06/05 3.22 Babel common definitions
\babel@savecnt=\count90
\U@D=\dimen103

(/usr/local/texlive/2018/texmf-dist/tex/generic/babel/txtbabel.def)
\bbl@dirlevel=\count91
)
\l@canadian = a dialect from \language\l@american 
\l@australian = a dialect from \language\l@british 
\l@newzealand = a dialect from \language\l@british 
))
(/usr/local/texlive/2018/texmf-dist/tex/latex/base/inputenc.sty
Package: inputenc 2018/04/06 v1.3b Input encoding file
\inpenc@prehook=\toks15
\inpenc@posthook=\toks16
)
(/usr/local/texlive/2018/texmf-dist/tex/latex/biblatex/biblatex.sty
Package: biblatex 2018/03/04 v3.11 programmable bibliographies (PK/MW)

(/usr/local/texlive/2018/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty
Package: pdftexcmds 2018/01/30 v0.27 Utility functions of pdfTeX for LuaTeX (HO
)

(/usr/local/texlive/2018/texmf-dist/tex/generic/oberdiek/infwarerr.sty
Package: infwarerr 2016/05/16 v1.4 Providing info/warning/error messages (HO)
)
(/usr/local/texlive/2018/texmf-dist/tex/generic/oberdiek/ifluatex.sty
Package: ifluatex 2016/05/16 v1.4 Provides the ifluatex switch (HO)
Package ifluatex Info: LuaTeX not detected.
)
(/usr/local/texlive/2018/texmf-dist/tex/generic/oberdiek/ltxcmds.sty
Package: ltxcmds 2016/05/16 v1.23 LaTeX kernel commands for general use (HO)
)
(/usr/local/texlive/2018/texmf-dist/tex/generic/oberdiek/ifpdf.sty
Package: ifpdf 2017/03/15 v3.2 Provides the ifpdf switch
)
Package pdftexcmds Info: LuaTeX not detected.
Package pdftexcmds Info: \pdf@primitive is available.
Package pdftexcmds Info: \pdf@ifprimitive is available.
Package pdftexcmds Info: \pdfdraftmode found.
)
(/usr/local/texlive/2018/texmf-dist/tex/latex/etoolbox/etoolbox.sty
Package: etoolbox 2018/02/11 v2.5e e-TeX tools for LaTeX (JAW)
\etb@tempcnta=\count92
)
(/usr/local/texlive/2018/texmf-dist/tex/latex/oberdiek/kvoptions.sty
Package: kvoptions 2016/05/16 v3.12 Key value format for package options (HO)

(/usr/local/texlive/2018/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty
Package: kvsetkeys 2016/05/16 v1.17 Key value parser (HO)

(/usr/local/texlive/2018/texmf-dist/tex/generic/oberdiek/etexcmds.sty
Package: etexcmds 2016/05/16 v1.6 Avoid name clashes with e-TeX commands (HO)
Package etexcmds Info: Could not find \expanded.
(etexcmds)             That can mean that you are not using pdfTeX 1.50 or
(etexcmds)             that some package has redefined \expanded.
(etexcmds)             In the latter case, load this package earlier.
)))
(/usr/local/texlive/2018/texmf-dist/tex/latex/logreq/logreq.sty
Package: logreq 2010/08/04 v1.0 xml request logger
\lrq@indent=\count93

(/usr/local/texlive/2018/texmf-dist/tex/latex/logreq/logreq.def
File: logreq.def 2010/08/04 v1.0 logreq spec v1.0
))
(/usr/local/texlive/2018/texmf-dist/tex/latex/base/ifthen.sty
Package: ifthen 2014/09/29 v1.1c Standard LaTeX ifthen package (DPC)
)
(/usr/local/texlive/2018/texmf-dist/tex/latex/url/url.sty
\Urlmuskip=\muskip10
Package: url 2013/09/16  ver 3.4  Verb mode for urls, etc.
)
(/usr/local/texlive/2018/texmf-dist/tex/generic/xstring/xstring.sty
(/usr/local/texlive/2018/texmf-dist/tex/generic/xstring/xstring.tex
\@xs@message=\write3
\integerpart=\count94
\decimalpart=\count95
)
Package: xstring 2013/10/13  v1.7c  String manipulations (C Tellechea)
)
\c@tabx@nest=\count96
\c@listtotal=\count97
\c@listcount=\count98
\c@liststart=\count99
\c@liststop=\count100
\c@citecount=\count101
\c@citetotal=\count102
\c@multicitecount=\count103
\c@multicitetotal=\count104
\c@instcount=\count105
\c@maxnames=\count106
\c@minnames=\count107
\c@maxitems=\count108
\c@minitems=\count109
\c@citecounter=\count110
\c@savedcitecounter=\count111
\c@uniquelist=\count112
\c@uniquename=\count113
\c@refsection=\count114
\c@refsegment=\count115
\c@maxextratitle=\count116
\c@maxextratitleyear=\count117
\c@maxextradate=\count118
\c@maxextraalpha=\count119
\c@abbrvpenalty=\count120
\c@highnamepenalty=\count121
\c@lownamepenalty=\count122
\c@maxparens=\count123
\c@parenlevel=\count124
\blx@tempcnta=\count125
\blx@tempcntb=\count126
\blx@tempcntc=\count127
\blx@maxsection=\count128
\blx@maxsegment@0=\count129
\blx@notetype=\count130
\blx@parenlevel@text=\count131
\blx@parenlevel@foot=\count132
\blx@sectionciteorder@0=\count133
\labelnumberwidth=\skip58
\labelalphawidth=\skip59
\biblabelsep=\skip60
\bibitemsep=\skip61
\bibnamesep=\skip62
\bibinitsep=\skip63
\bibparsep=\skip64
\bibhang=\skip65
\blx@bcfin=\read1
\blx@bcfout=\write4
\c@mincomprange=\count134
\c@maxcomprange=\count135
\c@mincompwidth=\count136
Package biblatex Info: Trying to load biblatex default data model...
Package biblatex Info: ... file 'blx-dm.def' found.

(/usr/local/texlive/2018/texmf-dist/tex/latex/biblatex/blx-dm.def
File: blx-dm.def 2018/03/04 v3.11 biblatex localization (PK/MW)
)
Package biblatex Info: Trying to load biblatex style data model...
Package biblatex Info: ... file 'authoryear.dbx' not found.
Package biblatex Info: Trying to load biblatex custom data model...
Package biblatex Info: ... file 'biblatex-dm.cfg' not found.
\c@afterword=\count137
\c@savedafterword=\count138
\c@annotator=\count139
\c@savedannotator=\count140
\c@author=\count141
\c@savedauthor=\count142
\c@bookauthor=\count143
\c@savedbookauthor=\count144
\c@commentator=\count145
\c@savedcommentator=\count146
\c@editor=\count147
\c@savededitor=\count148
\c@editora=\count149
\c@savededitora=\count150
\c@editorb=\count151
\c@savededitorb=\count152
\c@editorc=\count153
\c@savededitorc=\count154
\c@foreword=\count155
\c@savedforeword=\count156
\c@holder=\count157
\c@savedholder=\count158
\c@introduction=\count159
\c@savedintroduction=\count160
\c@namea=\count161
\c@savednamea=\count162
\c@nameb=\count163
\c@savednameb=\count164
\c@namec=\count165
\c@savednamec=\count166
\c@translator=\count167
\c@savedtranslator=\count168
\c@shortauthor=\count169
\c@savedshortauthor=\count170
\c@shorteditor=\count171
\c@savedshorteditor=\count172
\c@labelname=\count173
\c@savedlabelname=\count174
\c@institution=\count175
\c@savedinstitution=\count176
\c@lista=\count177
\c@savedlista=\count178
\c@listb=\count179
\c@savedlistb=\count180
\c@listc=\count181
\c@savedlistc=\count182
\c@listd=\count183
\c@savedlistd=\count184
\c@liste=\count185
\c@savedliste=\count186
\c@listf=\count187
\c@savedlistf=\count188
\c@location=\count189
\c@savedlocation=\count190
\c@organization=\count191
\c@savedorganization=\count192
\c@origlocation=\count193
\c@savedoriglocation=\count194
\c@origpublisher=\count195
\c@savedorigpublisher=\count196
\c@publisher=\count197
\c@savedpublisher=\count198
\c@language=\count199
\c@savedlanguage=\count266
\c@origlanguage=\count267
\c@savedoriglanguage=\count268
\c@pageref=\count269
\c@savedpageref=\count270
\shorthandwidth=\skip66
\shortjournalwidth=\skip67
\shortserieswidth=\skip68
\shorttitlewidth=\skip69
\shortauthorwidth=\skip70
\shorteditorwidth=\skip71
\locallabelnumberwidth=\skip72
\locallabelalphawidth=\skip73
\localshorthandwidth=\skip74
\localshortjournalwidth=\skip75
\localshortserieswidth=\skip76
\localshorttitlewidth=\skip77
\localshortauthorwidth=\skip78
\localshorteditorwidth=\skip79
Package biblatex Info: Trying to load compatibility code...
Package biblatex Info: ... file 'blx-compat.def' found.

(/usr/local/texlive/2018/texmf-dist/tex/latex/biblatex/blx-compat.def
File: blx-compat.def 2018/03/04 v3.11 biblatex compatibility (PK/MW)
)
Package biblatex Info: Trying to load BibTeX backend compatibility...
Package biblatex Info: ... file 'blx-bibtex.def' found.

(/usr/local/texlive/2018/texmf-dist/tex/latex/biblatex/blx-bibtex.def
File: blx-bibtex.def 2018/03/04 v3.11 biblatex compatibility (PK/MW)


Package biblatex Warning: Using fall-back BibTeX(8) backend:
(biblatex)                functionality may be reduced/unavailable.

)
Package biblatex Info: Trying to load generic definitions...
Package biblatex Info: ... file 'biblatex.def' found.
 (/usr/local/texlive/2018/texmf-dist/tex/latex/biblatex/biblatex.def
File: biblatex.def 2018/03/04 v3.11 biblatex compatibility (PK/MW)
\c@textcitecount=\count271
\c@textcitetotal=\count272
\c@textcitemaxnames=\count273
\c@biburlnumpenalty=\count274
\c@biburlucpenalty=\count275
\c@biburllcpenalty=\count276
\c@smartand=\count277
)
Package biblatex Info: Trying to load bibliography style 'authoryear'...
Package biblatex Info: ... file 'authoryear.bbx' found.

(/usr/local/texlive/2018/texmf-dist/tex/latex/biblatex/bbx/authoryear.bbx
File: authoryear.bbx 2018/03/04 v3.11 biblatex bibliography style (PK/MW)
Package biblatex Info: Trying to load bibliography style 'standard'...
Package biblatex Info: ... file 'standard.bbx' found.

(/usr/local/texlive/2018/texmf-dist/tex/latex/biblatex/bbx/standard.bbx
File: standard.bbx 2018/03/04 v3.11 biblatex bibliography style (PK/MW)
\c@bbx:relatedcount=\count278
\c@bbx:relatedtotal=\count279
))
Package biblatex Info: Trying to load citation style 'authoryear'...
Package biblatex Info: ... file 'authoryear.cbx' found.

(/usr/local/texlive/2018/texmf-dist/tex/latex/biblatex/cbx/authoryear.cbx
File: authoryear.cbx 2018/03/04 v3.11 biblatex citation style (PK/MW)
Package biblatex Info: Redefining '\cite'.
Package biblatex Info: Redefining '\parencite'.
Package biblatex Info: Redefining '\footcite'.
Package biblatex Info: Redefining '\footcitetext'.
Package biblatex Info: Redefining '\smartcite'.
Package biblatex Info: Redefining '\textcite'.
Package biblatex Info: Redefining '\textcites'.
)
Package biblatex Info: Trying to load configuration file...
Package biblatex Info: ... file 'biblatex.cfg' found.

(/usr/local/texlive/2018/texmf-dist/tex/latex/biblatex/biblatex.cfg
File: biblatex.cfg 
))
Package biblatex Info: Trying to load language 'english'...
Package biblatex Info: ... file 'english.lbx' found.

(/usr/local/texlive/2018/texmf-dist/tex/latex/biblatex/lbx/english.lbx
File: english.lbx 2018/03/04 v3.11 biblatex localization (PK/MW)
)

Package biblatex Warning: 'babel/polyglossia' detected but 'csquotes' missing.
(biblatex)                Loading 'csquotes' recommended.

\@quotelevel=\count280
\@quotereset=\count281
(./document.aux)
\openout1 = `document.aux'.

LaTeX Font Info:    Checking defaults for OML/cmm/m/it on input line 6.
LaTeX Font Info:    ... okay on input line 6.
LaTeX Font Info:    Checking defaults for T1/cmr/m/n on input line 6.
LaTeX Font Info:    ... okay on input line 6.
LaTeX Font Info:    Checking defaults for OT1/cmr/m/n on input line 6.
LaTeX Font Info:    ... okay on input line 6.
LaTeX Font Info:    Checking defaults for OMS/cmsy/m/n on input line 6.
LaTeX Font Info:    ... okay on input line 6.
LaTeX Font Info:    Checking defaults for OMX/cmex/m/n on input line 6.
LaTeX Font Info:    ... okay on input line 6.
LaTeX Font Info:    Checking defaults for U/cmr/m/n on input line 6.
LaTeX Font Info:    ... okay on input line 6.
Package biblatex Info: Input encoding 'utf8' detected.
Package biblatex Info: Automatic encoding selection.
(biblatex)             Assuming data encoding 'utf8'.
Package biblatex Info: Input encoding 'utf8' specified.
Package biblatex Info: Data encoding 'utf8' specified.
(biblatex)             No need to reencode data.
\openout4 = `document-blx.bib'.

Package biblatex Info: Trying to load bibliographic data...
Package biblatex Info: ... file 'document.bbl' not found.

No file document.bbl.
Package biblatex Info: Reference section=0 on input line 6.
Package biblatex Info: Reference segment=0 on input line 6.
chapter 1.

LaTeX Warning: Citation 'duffie2003' on page 1 undefined on input line 8.


! LaTeX Error: Can be used only in preamble.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.9 \bibliography
                 {literatur}
Your command was ignored.
Type  I <command> <return>  to replace it with another command,
or  <return>  to continue without it.


LaTeX Warning: Empty bibliography on input line 10.

[1



{/usr/local/texlive/2018/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
(./document.aux)

LaTeX Warning: There were undefined references.


Package biblatex Warning: Please (re)run BibTeX on the file(s):
(biblatex)                document
(biblatex)                and rerun LaTeX afterwards.

Package logreq Info: Writing requests to 'document.run.xml'.
\openout1 = `document.run.xml'.

 ) 
Here is how much of TeX's memory you used:
 10014 strings out of 492642
 185181 string characters out of 6129384
 560141 words of memory out of 5000000
 13856 multiletter control sequences out of 15000+600000
 5141 words of font info for 19 fonts, out of 8000000 for 9000
 1141 hyphenation exceptions out of 8191
 44i,6n,66p,9114b,1594s stack positions out of 5000i,500n,10000p,200000b,80000s
</usr/local/texlive/2018/texmf-dist/fonts/type1/public/amsfonts/cm/cmbx10.pfb
></usr/local/texlive/2018/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb><
/usr/local/texlive/2018/texmf-dist/fonts/type1/public/amsfonts/cm/cmssbx10.pfb>

Output written on document.pdf (1 page, 31141 bytes).
PDF statistics:
 20 PDF objects out of 1000 (max. 8388607)
 13 compressed objects within 1 object stream
 0 named destinations out of 1000 (max. 500000)
 1 words of extra memory for PDF output out of 10000 (max. 10000000)

Best Answer

The \bibliography command in your document is the way standard bibliography packages produce the actual bibliography. But biblatex redefines \bibliography to be equivalent to \addbibresource, which defines simply what your .bib file is, and cannot be used in the preamble. The proper way to produce the bibliography with biblatex is the \printbibliography commands. So you need to replace

\bibliography{literatur}

with

\printbibliography

Delete your .aux files and compile again.

Some other comments: unless you have very strong reasons to use the bibtex backend, you really should use biber not bibtex when using biblatex. There are many features that are not usable if you use the bibtex backend. If you're not sure how to get your editor to run biber, see this question:

If you are using the same citestyle as bibstyle (as you are in your example) you can simply use style=authoryear.