0

Following the description of filecontentsdefmacro environment in the manual of filecontentsdef, I understood that it can be used to save some data in a macro without the need to create a physical file in the working directory.

However, the following MWE doesn't work as I expected. So, my question is how can I store a *.bib file data in a macro without creating a physical file in the working directory?

% arara: lualatex: { options: [ '-synctex=1', '-shell-escape','-interaction=nonstopmode' ]}
% arara: biber
% arara: lualatex: { options: [ '-synctex=1', '-shell-escape','-interaction=nonstopmode' ]}
% arara: lualatex: { options: [ '-synctex=1', '-shell-escape','-interaction=nonstopmode' ]}

\documentclass[nonatbib]{elsarticle}

\makeatletter
\let\c@author\relax
\makeatother

\usepackage[backend=biber,hyperref=true]{biblatex}

\usepackage{filecontentsdef,hyperref}
\begin{filecontentsdefmacro}{\somemacro}
@Article{key,
    author =    {author},
    title =     {title},
    journal = {journal}
}
\end{filecontentsdefmacro}

\addbibresource{\somemacro}

\begin{document}
    Lorem ipsum~\cite{key}.
    \printbibliography
\end{document}
  • 3
    You can't. biber wants a file, not some tex macro long gone when biber is called. Beside this it is quite unclear what you would gain - tex creates other files (log, toc) too, so where is the problem with the bib? – Ulrike Fischer Oct 9 at 20:39
  • @UlrikeFischer So, is it possible to create a temporary file from this macro to be called by biber then delete it at the end of the document build? – Diaa Oct 9 at 20:42
  • 2
    You don't need this package to create a temporary file - the standard filecontents will do this to. And if you can run biber you should also be able to run some clean up code after it has finished. – Ulrike Fischer Oct 9 at 20:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.