2

As shown in this MWE

\RequirePackage{snapshot}
\documentclass{scrbook}
\usepackage{filecontents,biblatex}
\begin{filecontents}{bib/\jobname.bib}
  @misc{anything,
  author={A. Anyone}}
\end{filecontents}
\addbibresource{\jobname.bib}


\begin{document}
 \chapter{My document}
This is my text
\end{document}

I like to have the bibliography in the subfolder bib. But filecontents cannot create the folder however I have --shell-escape enabled:

! I can't write on file `bib/bundledocbib.bib'.
<to be read again> 
\relax 
l.4 \begin{filecontents}{bib/\jobname.bib}  
lukascbossert
  • 3,015
  • 1
  • 16
  • 37
  • 1
    filecontents suppose to make the content of a file available to your code as there was a file there (that is not true). I don't see a reason to make "iconic folders" because folders is out of scope for combination of filecontents with tex (that just need a way to read the contents of every file and doesn't care for it's location anymore). – koleygr Feb 24 '18 at 22:56

1 Answers1

3

If you really have -shell-escape enabled you can create the folder before the first use (here with windows commands):

\documentclass{scrbook}
\usepackage{filecontents,biblatex}
\usepackage{shellesc}
\ShellEscape{mkdir bib}
\begin{filecontents}{bib/\jobname.bib}
  @misc{anything,
  author={A. Anyone}}
\end{filecontents}
\addbibresource{bib/\jobname.bib}


\begin{document}
 \chapter{My document}
 \cite{anything}
This is my text
\end{document}

Inside my test-folder this is okay, but for real documents I wouldn't do it - I also don't use filecontents with them. Imho it is much to easy to overwrite some important file.

Ulrike Fischer
  • 327,261
  • I agree, wouldnt build bigger tex-projects with filecontents either, but needed it for demonstration purpose with bundledoc. – lukascbossert Feb 24 '18 at 23:32