Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

\iffieldxref{labeltitle} when the main entry has no title. #588

Closed
maieul opened this issue Jun 6, 2017 · 16 comments
Closed

\iffieldxref{labeltitle} when the main entry has no title. #588

maieul opened this issue Jun 6, 2017 · 16 comments
Assignees
Labels

Comments

@maieul
Copy link
Contributor

maieul commented Jun 6, 2017

Hi, suppose the following things:

  • a @book entry without title

  • a @inBook entry with title, with crossref to the @book entry.

  • `\iffieldxref{title} return false, as expected.

  • `\iffieldxref{labeltitle} return true, which is not the expected result.

Cf the MWE

\documentclass[twoside,11pt]{article}

\usepackage{filecontents}
\begin{filecontents}{biblio.bib}



@book{CCSG26,
	Editor = {Van Deun, Peter and Jacques Noret},
	Number = {26},
	Series = {Corpus Christianorum Series Graeca},
	Shortseries = {CCSG},
	Title = {Hagiographica Cypria}}


@bookinbook{BHG226,
	Author = {{Alexandre de Chypre}},
	Bhg = {226},
	Crossref = {CCSG26},
	Pages = {83-122},
	Title = {Laudatio Barnabae},}


@book{MGH_SS_9,
	Series = {Monumenta Germania Historica Scriptores (in folio)},
	Shortseries = {MGH SS},
	Volume = {9}}

@book{AnnalesZwetlenses,
	Crossref = {MGH_SS_9},
	Editor = {Wilhem Wattenbach},
	Pages = {677-684},
	Title = {Annales Zwetlenses (1-1349)}}

\end{filecontents}
\usepackage[citestyle=verbose-trad2,mincrossrefs=0,citereset=section]{biblatex}
\bibliography{biblio}
\begin{document}

\section{Good}

\renewbibmacro{begentry}{%
  \iffieldxref{title}{oui}{non}%
}

\makeatother
 \cite{AnnalesZwetlenses}
 
 \cite{BHG226}

\section{Wrong}
\renewbibmacro{begentry}{%
  \iffieldxref{labeltitle}{oui}{non}%
}
 \cite{AnnalesZwetlenses}
 
 \cite{BHG226}

\section{Turn around}

 \makeatletter
 \renewbibmacro{begentry}{%
  \entrydata{\thefield{crossref}}{%
  	\savefield{labeltitle}{\labeltitle@crossref}%
  }%
  \ifboolexpr{
     test{\iffieldxref{labeltitle}} 
     and test{\ifnameequals{labeltitle}{\labeltitle@crossref}}%
     }%
    {oui}{non}%
}

 \cite{AnnalesZwetlenses}
 
 \cite{BHG226}



\end{document}
@moewew
Copy link
Collaborator

moewew commented Jun 7, 2017

This is an interesting one.

As far as I can tell it comes from the fact that labeldate is a dynamic field coupled with how the comparison is done.

Essentially biblatex saves the content of the child entry and then gets the data from the parent entry - with \getdata - that means that in the current context all fields now come from the parent. Then it compares the relevant field of the parent entry with the saved data from the child. Now \getdata simply stores the contents of the fields in the respective macros. It does not undefine macros for fields that are empty - as they don't appear in the .bbl. So in this special situation where field contents get overwritten (provided the new ones are non-empty) we run into a problem if the new fields are empty - nothing will be overwritten and the old content will prevail. That was already identified as a problem, so we find \csundef{abx@field@#1} in the code that makes sure to clear the old content of the field to compare before the new contents of the parent are imported. The problem is that in this case labeltitle is a virtual field that dynamically uses several possible other fields as source. So we would have to clear all relevant fields before proceeding. This is not done at the moment.

@plk
Copy link
Owner

plk commented Jun 7, 2017

This is correct - I suspect the solution is fairly simple - use the \abx@dorfields and \abx@dornames macros to clear these dynamic fields too - @moewew - perhaps you can try this?

@moewew
Copy link
Collaborator

moewew commented Jun 7, 2017

OK, here is a possible fix

Instead of only deleting the (one relevant) field with \csundef{abx@field@#1} we use the full \blx@resetdata:

\def\blx@iffieldxref#1#2{%
  \begingroup
  \letcs\blx@tempa{abx@field@#2}%
  \letcs\blx@tempb{abx@field@#1}%
  \csundef{abx@field@#1}%
  \blx@getdata{\blx@tempa}%
  \blx@imc@iffieldequals{#1}\blx@tempb
    {\aftergroup\@firstoftwo}
    {\aftergroup\@secondoftwo}%
  \endgroup}

becomes

\def\blx@iffieldxref#1#2{%
  \begingroup
  \letcs\blx@tempa{abx@field@#2}%
  \letcs\blx@tempb{abx@field@#1}%
  \blx@resetdata
  \blx@getdata{\blx@tempa}%
  \blx@imc@iffieldequals{#1}\blx@tempb
    {\aftergroup\@firstoftwo}
    {\aftergroup\@secondoftwo}%
  \endgroup}

@moewew
Copy link
Collaborator

moewew commented Jun 7, 2017

I have put together pull request #590. Please test this thoroughly, I suspect @maieul has quite some interesting test cases for \iffieldxref and friends.

@moewew moewew closed this as completed Jun 7, 2017
@moewew moewew reopened this Jun 7, 2017
@moewew moewew self-assigned this Jun 7, 2017
@maieul
Copy link
Contributor Author

maieul commented Jun 7, 2017

I will try to do test this week-end. Please send me an email monday if I didn't do.

@maieul
Copy link
Contributor Author

maieul commented Jun 10, 2017

Hi, I have tried the pull requets #590 with the previous MWE. I get

(/Users/maieul/Library/texmf/tex/latex/biblatex/biblatex.cfg)) ! Missing number, treated as zero.

@maieul
Copy link
Contributor Author

maieul commented Jun 10, 2017

(I get it before the \addbibresource / \bibliography command)

@moewew
Copy link
Collaborator

moewew commented Jun 10, 2017

Ah yes. If you just download the files from dev you get errors, because the files have no version information in biblatex.sty. You could try copying over the first few lines of biblatex.sty from the current release.

@maieul
Copy link
Contributor Author

maieul commented Jun 10, 2017 via email

@moewew
Copy link
Collaborator

moewew commented Jun 10, 2017

Brilliant. Thanks for following up on this. Theoretically, there should be no problem with the patch. And a few tests I ran brought up no problems, either. I think we can merge.

moewew added a commit that referenced this issue Jun 10, 2017
Use resetdata in if*xref (see #588)
@maieul
Copy link
Contributor Author

maieul commented Jun 10, 2017

For reledmac, I have found a way to make test to be sure there is no breaking change. I have a script which

  1. Export .pdf example to a series of .png files
    2 Comparer these .png file with the other one, and make an error if one pixel or more have changed.

It is quite long to execute, but I am sur it's working.

@plk
Copy link
Owner

plk commented Jun 10, 2017

I have merged and updated 3.8 DEV. I think we should release very shortly. I already have a test suite like that which compares PDFs like that.

@maieul
Copy link
Contributor Author

maieul commented Jun 10, 2017

nice !

@maieul maieul closed this as completed Jun 10, 2017
@moewew
Copy link
Collaborator

moewew commented Jun 10, 2017

PLK also has some test suite in place. The danger is always that your test cases don't cover everything. As far as I can see \iffieldxref and friends are not very widely used and I'm not sure about the test suite.

@plk
Copy link
Owner

plk commented Jun 10, 2017

We don't test anywhere near everything in detail - @josephwright was looking into a real test suite using expl3 and I have a basic framework in place for this but there were structural issues with testing package and biber last time I looked.

@moewew
Copy link
Collaborator

moewew commented Jun 10, 2017

@plk Before we release I would like to at least fix the easy bits of mergedate. Cf #540 and #520 But I'm not sure how to tackle this. In a way mergedate is a bit overwhelmed by the new date system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants