retorquere / zotero-better-bibtex

Make Zotero effective for us LaTeX holdouts
https://retorque.re/zotero-better-bibtex/
MIT License
5.3k stars 284 forks source link

[Bug]: Film references do not export properly for APA formating #2494

Closed deepers closed 1 year ago

deepers commented 1 year ago

Debug log ID

G6SKQ8SN-refs-euc

What happened?

Here is a BibLaTeX file with two entries. The first is an export from Better BibTeX. The second is one of the BibLaTeX APA test references.

@video{formanOneFlewCuckoo1975,
  title = {One Flew over the Cuckoo's Nest},
  editor = {Forman, Miloš},
  date = {1975},
  publisher = {{United Artists}},
  editortype = {director},
  keywords = {Drama,Mentally ill$$QMentally ill}
}
@VIDEO{10.12:84a,
    ENTRYSUBTYPE   = {film},
    AUTHOR         = {M. Forman},
    AUTHOR+an:role = {1=director},
    TITLE          = {One Flew Over the Cuckoo's Nest},
    PUBLISHER      = {United Artists},
    DATE           = {1975}
}

Here is a LaTeX file citing both of these references.

\documentclass{article}
\usepackage[style=apa,backend=biber]{biblatex}
\addbibresource{bibliography.bib}

\begin{document}
\autocite{formanOneFlewCuckoo1975}
\autocite{10.12:84a}
\printbibliography
\end{document}

I've copied the reference list from the output PDF. You can see that the Better BibTeX reference (the second one) is not formatted correctly for APA 7.

References
Forman, M. (Director). (1975a). One flew over the cuckoo’s nest [Film]. United Artists.
Forman, M. (typedirector). (1975b). One flew over the cuckoo’s nest. United Artists.
retorquere commented 1 year ago

I'll have to see whether the form you have working is a general biblatex solution rather than something peculiar to biblatex-apa. Editortype is supposed to work, but biblatex-apa apparently made different choices: https://tex.stackexchange.com/questions/466884/biblatex-apa-style-does-not-support-editor-types . Given that I need to make sure they haven't made more incompatibile choices that would affect other styles before I adopt this.

retorquere commented 1 year ago

@njbart opinions on this?

njbart commented 1 year ago

For the time being, I would advise against extensive changes in BBT.

BL ‘Data Annotations’, e.g., AUTHOR+an:role, are relatively new, and while BA has adopted them, not all other biblatex styles have followed (yet?). BC, e.g., does not currently support them.

Given that there is a relatively straightforward solution, reported in the stackexchange thread mentioned above, i.e., including, in the latex header,

\renewbibmacro*{apaeditorstrg}[1]{%
  \iffieldundef{#1type}
    {\ifthenelse{\value{#1}>1\OR\ifandothers{#1}}
       {\bibcpstring{editors}}
       {\bibcpstring{editor}}}
    {\ifthenelse{\value{#1}>1\OR\ifandothers{#1}}
       {\ifbibstring{type\thefield{#1type}s}
          {\bibcpstring{type\thefield{#1type}s}}
          {\bibcpstring{\thefield{#1type}s}}}
       {\ifbibstring{type\thefield{#1type}}
          {\bibcpstring{type\thefield{#1type}}}
          {\bibcpstring{\thefield{#1type}}}}}}

that’s what I recommend to the OP for now.

One change that might be considered for BBT is that given that for BL video is just an alias for movie, and both BA and BC use video exclusively in both their documentation and their sample .bib files, and, most importantly, as I just discovered, BC does not even support movie, i.e., triggers an error when movie is used, BBT might as well map Zotero film not to BL movie as it currently does, but to BL video with entrysubtype = {film}, the latter both to provide the otherwise missing [Film] in the output of the OP’s example, and a handle in case further downstream processing is desired with a distinction between entries originating as Zotero Film vs. Video Recording.

In terms of downstream distinctions as well as round-trip and Zotero import considerations, BBT could also add entrysubtype = {tvbroadcast} to items coming from Zotero TV Broadcast, and import BL video (and movie) items with entrysubtype = {film} or entrysubtype = {tvbroadcast} to Zotero Film and TV Broadcast. Note that entrysubtype = {tvbroadcast} is not used by any biblatex styles I am aware of, so this would only be for distinction and round-trip purposes. Also note that BC does have video with entrysubtype = {tvepisode}; it probably wouldn’t hurt if BBT also imported this as Zotero TV Broadcast as well, though tvepisode serves a very specific purpose in BC, so I wouldn’t use it in the context of BBT export.

(On the intricacies of the entrysubtype field in BC video items, see the current BC manual, p. 37 and 128. I don’t think BBT can do much here, and would either leave this to manual editing, or try to automate this as much as possible by taking advantage of BL sourcemap mechanisms.)

Notes: BL=the biblatex package, either underlying platform and/or its specific styles, distinguished as necessary, as per its package manual; BA=biblatex-apa; BC=biblatex-chicago

deepers commented 1 year ago

Thanks @retorquere and @njbart. I tried putting that snippet in my LaTeX header, but it seems like the result is still not exactly APA—there is a missing "[Film]" and "Dir." instead of "Director".

Forman, M. (Director). (1975a). One flew over the cuckoo’s nest [Film]. United Artists.
Forman, M. (Dir.). (1975b). One flew over the cuckoo’s nest. United Artists.

Thanks, Deepee

retorquere commented 1 year ago

G6SKQ8SN-refs-euc has item type Video Recording BTW, not Film.

retorquere commented 1 year ago

This gets me [film] but not Director. Should the preamble also include the NewBibliographyString and DefineBibliographyStrings commands?

\documentclass{article}
\usepackage[style=apa,backend=biber]{biblatex}

\renewbibmacro*{apaeditorstrg}[1]{%
  \iffieldundef{#1type}
    {\ifthenelse{\value{#1}>1\OR\ifandothers{#1}}
       {\bibcpstring{editors}}
       {\bibcpstring{editor}}}
    {\ifthenelse{\value{#1}>1\OR\ifandothers{#1}}
       {\ifbibstring{type\thefield{#1type}s}
          {\bibcpstring{type\thefield{#1type}s}}
          {\bibcpstring{\thefield{#1type}s}}}
       {\ifbibstring{type\thefield{#1type}}
          {\bibcpstring{type\thefield{#1type}}}
          {\bibcpstring{\thefield{#1type}}}}}}

\begin{filecontents*}{\jobname.bib}
@video{formanOneFlewCuckoo1975,
  entrysubtype = {film},
  title = {One Flew over the Cuckoo's Nest},
  editor = {Forman, Miloš},
  date = {1975},
  publisher = {{United Artists}},
  editortype = {director},
  keywords = {Drama,Mentally illQMentally ill}
}
\end{filecontents*}
\addbibresource{\jobname.bib}

\begin{document}
\autocite{formanOneFlewCuckoo1975}
\printbibliography
\end{document}
deepers commented 1 year ago

I don't get "[Film]". If I change the item type to Film in Zotero and then export to BibLaTeX, I get

@movie{formanOneFlewCuckoo1975,
    title = {One Flew over the Cuckoo's Nest},
    editor = {Forman, Miloš},
    date = {1975},
    publisher = {{United Artists}},
    editortype = {director},
    keywords = {Drama,Mentally ill$$QMentally ill}
}

and the output is

Forman, M. (Dir.). (1975). One flew over the cuckoo’s nest.
retorquere commented 1 year ago

I have a local build that adds the entrysubtype. Once the test suite finishes that build will be posted here.

deepers commented 1 year ago

Great, thanks!

njbart commented 1 year ago

Just spotted here:

@video{Kubrick1964,
  entrysubtype = {tvbroadcast},
  title = {Dr. {{Strangelove}} or: How {{I}} Learned to Stop Worrying and Love the Bomb},
  ...

– is that intentional? Shouldn’t it be entrysubtype = {film}?

njbart commented 1 year ago

Well, the \renewbibmacro* ... snippet reproduced above gives me ‘Dir.’; haven’t figured out yet how to obtain ‘Director’.

In a pinch, for ‘Director’ try

\NewBibliographyString{typedirector}
\DefineBibliographyStrings{english}{
  typedirector  = {Director},
}

instead of the \renewbibmacro* ... snippet, and add other missing roles as needed.

retorquere commented 1 year ago
@video{Kubrick1964,
  entrysubtype = {tvbroadcast},
  title = {Dr. {{Strangelove}} or: How {{I}} Learned to Stop Worrying and Love the Bomb},
  ...

– is that intentional? Shouldn’t it be entrysubtype = {film}?

It should be, but the source entry claims itself to be of type TV Broadcast, so it's a correct translation of a faulty entry.

github-actions[bot] commented 1 year ago

:robot: this is your friendly neighborhood build bot announcing test build 6.7.75.4182 ("remember itemID for groups")

Install in Zotero by downloading test build 6.7.75.4182, opening the Zotero "Tools" menu, selecting "Add-ons", open the gear menu in the top right, and select "Install Add-on From File...".

retorquere commented 1 year ago

@deepers how did you get keywords = {Drama,Mentally ill$$QMentally ill}? When I export G6SKQ8SN-refs-euc I get keywords = {Drama,Mentally illQMentally ill}, which is what I'd expect given the input in G6SKQ8SN-refs-euc, and I don't even know what I would have to input into Zotero to get BBT to export a bare $$.

Can you paste the tag value here directly, surrounding it by backquotes (`)?

retorquere commented 1 year ago

Build 4182 will export the entrysubtype.

deepers commented 1 year ago

Hi @retorquere. The tag values are Drama and Mentally ill$$QMentally ill. These were generated by the Zotero browser plugin from this library link.

I edited out most of the extraneous fields before generating the debug log, but I left the tags.

retorquere commented 1 year ago

According to the log ID, there are no dollar signs in the tag. Can you export the entry as Zotero RDF and attach it here?

deepers commented 1 year ago

I see the dollar signs in the RDF file.

<rdf:RDF
 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
 xmlns:z="http://www.zotero.org/namespaces/export#"
 xmlns:dc="http://purl.org/dc/elements/1.1/"
 xmlns:foaf="http://xmlns.com/foaf/0.1/"
 xmlns:bib="http://purl.org/net/biblio#">
    <bib:MotionPicture rdf:about="#item_402">
        <z:itemType>film</z:itemType>
        <dc:publisher>
            <foaf:Organization>
               <foaf:name>United Artists</foaf:name>
            </foaf:Organization>
        </dc:publisher>
        <z:directors>
            <rdf:Seq>
                <rdf:li>
                    <foaf:Person>
                        <foaf:surname>Forman</foaf:surname>
                        <foaf:givenName>Miloš</foaf:givenName>
                    </foaf:Person>
                </rdf:li>
            </rdf:Seq>
        </z:directors>
        <dc:subject>
           <z:AutomaticTag><rdf:value>Drama</rdf:value></z:AutomaticTag>
        </dc:subject>
        <dc:subject>
            <z:AutomaticTag>
               <rdf:value>Mentally ill$$QMentally ill</rdf:value>
            </z:AutomaticTag>
        </dc:subject>
        <dc:title>One flew over the cuckoo's nest</dc:title>
        <dc:date>1975</dc:date>
    </bib:MotionPicture>
</rdf:RDF>
retorquere commented 1 year ago

Ah I see what happened. The dollar signs are actually in G6SKQ8SN-refs-euc, I messed up when I copied the cases over, and either my parser or my exporter is wrong -- my parser treats keywords as normal parsing, and my exporter treated it as verbatim.

github-actions[bot] commented 1 year ago

:robot: this is your friendly neighborhood build bot announcing test build 6.7.75.4197 ("keywords not verbatim")

Install in Zotero by downloading test build 6.7.75.4197, opening the Zotero "Tools" menu, selecting "Add-ons", open the gear menu in the top right, and select "Install Add-on From File...".

retorquere commented 1 year ago

Build 4182 and later are the same, except for the now-fixed keywords. Do you have a working setup with these builds?

njbart commented 1 year ago

… I see no indication that keywords is verbatim, correct?

Absolutely.

deepers commented 1 year ago

I installed the latest test build. The exported BibLaTex now looks like

@video{formanOneFlewCuckoo1975,
    entrysubtype = {film},
    title = {One Flew over the Cuckoo's Nest},
    editor = {Forman, Miloš},
    date = {1975},
    publisher = {{United Artists}},
    editortype = {director},
    keywords = {Drama,Mentally ill\$\$QMentally ill}
}

and the following LaTeX

\documentclass{article}
\usepackage[style=apa,backend=biber]{biblatex}
\addbibresource{bibliography.bib}

\NewBibliographyString{typedirector}
\DefineBibliographyStrings{english}{
    typedirector  = {Director},
}

\begin{document}
\autocite{formanOneFlewCuckoo1975}
\printbibliography
\end{document}

produces

Forman, M. (Director). (1975). One flew over the cuckoo’s nest [Film]. United Artists.

So all looks good.

I wondered if there should be an entrysubtype for other types of video, for example like this YouTube video in the BibLaTex APA reference list.

@VIDEO{10.12:88b,
    ENTRYSUBTYPE    = {video},
    AUTHOR     = {TED},
    TITLE           = {Brené {Brown}},
    SUBTITLE        = {Listening to Shame},
    PUBLISHER       = {YouTube},
    DATE            = {2012-03-16},
    URL             = {https://www.youtube.com/watch?v=psN1DORYYV0}
}
retorquere commented 1 year ago

Does it make any difference in rendering? It doesn't really look like a subtype that way.

retorquere commented 1 year ago

If not, I'd like to close this issue.

deepers commented 1 year ago

There is a difference in rendering. The first item below is based on the BibLaTeX APA example, and the second is from the Zotero export. Apart from the title, you can see that there are other differences.

TED. (2012a, March 16). Brené Brown: Listening to shame [Video]. YouTube. https://www.youtube.com/watch?v=psN1DORYYV0
TED (Director). (2012b, March 16). Listening to shame — Brené Brown. Retrieved April 25, 2023, from https : / / www . youtube . com / watch ? v = psN1DORYYV0

This is what Better BibTeX exports.

@video{tedListeningShameBrene2012,
    title = {Listening to Shame | {{Brené Brown}}},
    editor = {{TED}},
    date = {2012-03-16},
    url = {https://www.youtube.com/watch?v=psN1DORYYV0},
    urldate = {2023-04-25},
    editortype = {director}
}
retorquere commented 1 year ago

A new build will drop in 10 minutes or so that does that, but what extra information does this convey? What is the difference between a video, and a video of "subtype" video (rather than non-video I guess? Does not make sense to me).

deepers commented 1 year ago

I'm not sure. From my point of view, I'm most concerned with having my bibliographic items properly formatted in APA style. Thanks!

github-actions[bot] commented 1 year ago

:robot: this is your friendly neighborhood build bot announcing test build 6.7.76.4225 ("adjust tests")

Install in Zotero by downloading test build 6.7.76.4225, opening the Zotero "Tools" menu, selecting "Add-ons", open the gear menu in the top right, and select "Install Add-on From File...".

deepers commented 1 year ago

Looks good. Thanks for all your help @retorquere!