We are currently planning to migrate to a different platform for the forum. We will announce this fact both here and on Twitter, once we have settled on a solution.

Working with references and attachments - Problems and requests

Hey folks,

just discovered this really awesome app some days ago and spent hours over hours so far digging into its functionalities.

One problem/qestion that haunts me, however, is how to deal with attachments to bibliographic references. I established a category of files (located in a zettlr-subfolder) where each file contains an excerpt for a single article/book/paper. I have connected zettlr to my bibtex-file (created with JabRef) and all the citing stuff works really fine so far.

There is a nice feature (in theory) to open the respective file attachment by right-clicking the inserted reference - however, that does not work for me: no file opens!

After doing some research in the zettlr documentation and forum, I figured out that obviously
1. the "open attachment" option only looks for attachments in the same directory (and subdirectories?) of the .md-file I am currently working on AND
2. only for attachments whose filename exactly match the bibkey?

Anyway, this solution is still not working for me: first, I moved a copy of the respective paper in the zettlr directory; after refreshing zettlr it now shows up in the sidebar attachment pane - but still not opening by right-click → open attachment; I then renamed the file so that it exactly matched the bibkey → still not opening (neither by right-click nor by directly clicking the file link in the sidebar!) Did I miss anything important?
This is what the log says: "Trying to run command through Application: open-attachment" (followed by nor further message) when trying to open by right-click and "Trying to run command through Application: win-menu - No command registered with the application for command win-menu" when directly clicking the attachment link in the sidebar (by the way, I am working on Linux Ubuntu 20.04 if that is of any interest for this topic...)

Anyway, even besides the fact that currently it doesn't work as it should, what I would like to do is the following:
1. opening the file from within zettlr without renaming it to match the bibkey (for different reasons, my literature pdfs have names other than their bibkey);
2. opening the file from within zettlr without moving it to the zettlr directory. I have one central folder where I keep all my papers (and defined this as the default folder from within JabRef). Of course I could place my default directory within the zettlr directory; yet this wouldn't be a real nice solution as - in this case - the sidebar pane would show several of thousands of linked files (and thus even hide the references from the sidebar as these are only shown after the attached files).

Is there any possibility or workaround/manual configuration for this? Or did I even misunderstand the whole logic behind the reference/attachment thing?

As to my above-mentioned "excerpt-files", I would additionally like to add what for me would be the perfect solution: to have a header at the top of each excerpt that shows author, year, title, publisher (or journal) and abstract (if the bibtex-file already includes one). Of course I could type such a header manually - but there should be, I think, an easy solution for accomplishing this via - for example - a YAML header that just extracts/parses the relevant information from the respective bibtex-file!? Easy at least in case one is more familiar with YAML / pandoc than I am... :wink:
Something similar to this actually - anyway, as a dummy I don't quite get how to realize this... Any suggestions for that? Or at least any link to a quite simple introduction for dummies which are familiar with html, css, etc. stuff but not with pandoc?


  • Hey,

    easy solution for that: The "open attachment"-context menu option is completely detached from the "attachment sidebar" (putting this in quotes as there's currently a debate to rename that thing). What's listed in the attachment list is simply all the files within the currently selected directory that should be shown according to the corresponding setting, and these can be opened with a simple left-click.

    What you're attempting to do, however, is to open files explicitly linked to citation references from within your library. These are bound to the citekeys by means of a link that needs to be made via your reference manager. There are two types of attachments Zettlr supports for such references: Zotero-generated ones and those within BibTex files.

    1. BibTex: BibTex files contain a special key that contains the paths to potential files, and if you load a BibTex literature database into Zettlr, it will look out for these fields, and if it finds them, it will extract the files. If you then right-click a citation and choose to open the corresponding file, Zettlr will look in its internal list of these references to find matching files, and, if there is at least one, it will attempt to open it in your default PDF viewer.
    2. Zotero: If you use Zotero and link a CSL-JSON file, the problem is that these CSL-JSON-files do not support such a field yet, so the links are not contained in the literature database. Instead, what Zettlr will do if it encounters a CSL JSON file, is to "ping" Zotero, that is, see if it is running. If it is, it will send a request to the running Zotero instance and request a list of files attached to the specified citekey. For that to work you'll need to have the newest version of BetterBibTex from retorquere installed, as he implemented that feature specifically for Zettlr to work with Zotero attachments. BBT will answer Zettlr's request with a list of references of which the first PDF-file will then be opened.

    Long story short, you'll need to make sure the files are actually linked within your reference manager so that Zettlr knows which file to open! I hope that clarifies things a little bit.


  • you'll need to make sure the files are actually linked within your reference manager

    They are - as I described - all linked from within JabRef, actually that was my first thought how zettlr handles this "open attachment" function. Only after it didn't work the idea came up that zettlr might possibly not search for corresponding links in the bib-file but in the zettlr directory...

    Anyway, I guess I found the problem: since version 5, JabRef changed from absolute to relative file links - which makes sense if you use JabRef from different computers or in a collaborative manner, but obviously is an obstacle when you are working with the bib-file from within another application... Strangely, there doesn't seem to be an option to switch back to absolute file paths... :neutral: I'll check it in more detail tomorrow and give a short report about it!

  • Strangely, there doesn't seem to be an option to switch back to absolute file paths...

    For this, check out this issue: https://github.com/Zettlr/Zettlr/issues/619

  • For this, check out this issue: https://github.com/Zettlr/Zettlr/issues/619

    OK, thanks! Did you get any news from the JabRef guy so far?

  • Did you get any news from the JabRef guy so far?

    What do you mean? (For context: Tobias Diez is one of the JabRef guys :D)

  • As far as I understood he proposed to (try to) make changes to the zettlr script in order to deal with the problem related to JabRef default paths... I mean: have you heard anything about that topic or does the problem still persist?

    I am currently trying to become acquainted with the basics of javascript/json so that I will be able to extend my configuration possibilities in the future (e.g. with regard to bibtex parsers, but also in order to immerse myself more deeply in the world of programming...) - however, my time is quite limited at the moment, means that I cannot make any promises - neither to myself nor to others... :wink:

  • have you heard anything about that topic or does the problem still persist?

    ah, no, so far not, but I'm beginning to lose some of the oversight over these rather specific things currently :D

Sign In or Register to comment.