gsalzer / subfiles

class and package for multi-file projects in LaTeX
LaTeX Project Public License v1.3c
25 stars 1 forks source link

Strange behavior with biblatex and @Preamble #33

Closed lcnittl closed 1 year ago

lcnittl commented 1 year ago

Having the following directory tree

C:.
│   .latexmkrc
└───src
    ├───data
    │       main.bib
    ├───main
    │       main.tex
    └───sub
            sub_1.tex
            sub_2.tex

with the following file contents

.latexmkrc

set_tex_cmds( '-interaction=nonstopmode -shell-escape -synctex=1 -file-line-error %O %S' );
$hash_calc_ignore_pattern{'pdf'} = '^.*?(\/(CreationDate|ModDate)\(|\/ID |<xmp:(ModifyDate|CreateDate)>|xapMM:DocumentID=\'uuid:.+?\')';
$do_cd = 1;
$pdf_mode = 4;

main.tex

% !TeX encoding = UTF-8
% !TeX spellcheck = en_GB
% !TeX program = latexmk
% !TeX options = -r "../../.latexmkrc" -rc-report
\documentclass{report}

\usepackage[
  backend=biber,
  style=chem-angew,
  subentry=true,
  sortsets=true,
  alldates=iso,
  seconds=true,
  date=year,
]{biblatex} % doi=true % Load before 'hyperref'

\usepackage{subfiles}

% Need to be after subfiles
% See: https://github.com/gsalzer/subfiles/blob/master/tests/biblatex
\addbibresource{../data/main.bib}

\begin{document}
This is the main document

\subfile{../sub/sub_1.tex}

\subfile{../sub/sub_2.tex}

\printbibliography
\end{document}

sub_1.tex

% !TeX encoding = UTF-8
% !TeX spellcheck = en_GB
% !TeX program = latexmk
% !TeX options = -r "../../.latexmkrc" -rc-report
\documentclass[../main/main.tex]{subfiles}

\begin{document}
This is the reference from sub\textunderscore{}1 \autocite{Kaminskyy2011a}.
\end{document}

sub_2.tex

% !TeX encoding = UTF-8
% !TeX spellcheck = en_GB
% !TeX program = latexmk
% !TeX options = -r "%WORKSPACE_FOLDER%/.latexmkrc" -rc-report
\documentclass[../main/main.tex]{subfiles}

\begin{document}
This is the reference from sub\textunderscore{}2 \autocite{Knittl-Frank2017a}.
\end{document}

main.bib

@Preamble{"This bib file requires package 'csquotes'"}

@article{Kaminskyy2011a,
  author       = {Danylo Kaminskyy and Barbara Bednarczyk-Cwynar and Olexandr Vasylenko and Oxana Kazakova and Borys Zimenkovsky and Lucjusz Zaprutko and Roman Lesyk},
  title        = {Synthesis of new potential anticancer agents based on 4-thiazolidinone and oleanane scaffolds},
  journaltitle = {Med. Chem. Res.},
  date         = {2011},
  volume       = {21},
  number       = {11},
  pages        = {3568--3580},
  doi          = {10.1007/s00044-011-9893-9},
  file         = {:file/Kaminskyy2011a.pdf:PDF},
  groups       = {MS},
  owner        = {knittlfrac92},
  publisher    = {Springer Nature},
  timestamp    = {2018-06-27},
}

@thesis{Knittl-Frank2017a,
  author      = {Christian Knittl-Frank},
  title       = {C–H Activation in Natural Product Synthesis},
  type        = {mathesis},
  institution = {University of Vienna},
  date        = {2017},
  language    = {English},
  url         = {http://othes.univie.ac.at/50466/},
  urldate     = {2018-06-27},
  file        = {:file/Knittl-Frank2017a.pdf:PDF},
  owner       = {knittlfrac92},
  timestamp   = {2018-06-27},
}

@Comment{jabref-meta: databaseType:biblatex;}

@Comment{jabref-meta: saveActions:enabled;
abstract[html_to_unicode,identity,latex_to_unicode]
date[normalize_date]
month[normalize_month]
pages[normalize_page_numbers]
title[html_to_unicode,latex_to_unicode]
;}

@Comment{jabref-meta: saveOrderConfig:specified;citationkey;false;year;false;title;false;}

Outputs the @Preamble content at the beginning of all documents:

main.pdf image

sub_1.pdf image

sub_2.pdf image

Any ideas on how to resolve this, besides removing the @Preamble?

gsalzer commented 1 year ago

@lcnittl The behavior you observe has nothing to do with subfiles. Eliminate the subfiles package from one of the subfiles, e.g. from sub_1.tex, by copying the preamble to the file (see below), and you will observe the same phenomenon. So the question really is: Is it possible to suppress the effect of @Preamble? Best ask this question on tex.stackexchange.com and tag it with biblatex.

\documentclass{report}
\usepackage[
  backend=biber,
  style=chem-angew,
  subentry=true,
  sortsets=true,
  alldates=iso,
  seconds=true,
  date=year,
  ]{biblatex} % doi=true % Load before 'hyperref'
\addbibresource{../data/main.bib}
\begin{document}
This is the reference from sub\textunderscore{}1 \autocite{Kaminskyy2011a}.
\end{document}
lcnittl commented 1 year ago

Oh my! Sorry for the waste of time!

I very cleverly managed to a) test the main file without subfiles, yet also without \autocite and b) drop the @Preamble during playing around, giving me the impression subfiles caused it.

But you are right, can reproduce in the sub files and also the main file (having an \autocite kills it).

As I am already here: Thanks for maintaining this amazing package. Helps a lot in reducing compilation times!