Storing Additional Files into attachment folders - LaTeX

Suppose I have attached a file to an item. Zotero automatically creates a new folder with an arbitrary name, for e.g. X49JSXMY.
Suppose I decide to manually copy additional files into this folder (using my OS file explorer an not zotero).
Is it safe ? I mean, can these additional files be altered by zotero (even after sync with the cloud or software update)?

Why I want to do that ?
Because I use LaTeX to generate some reports as pdf. Then, I save these report using zotero by creating a proper item and attach the pdf file to it. I would like to store the LaTeX files used to generate this pdf in the same folder as the pdf. Doing so, I can generate a new pdf with my LaTeX files if I want to and it will directly update the pdf in my zotero library.

So, my goal is to find a way to "link" my LaTeX files to the "automatically generated folder" where the final pdf is stored...
  • Zotero won't touch the files including during sync -- it will also not sync them, so you'd only have them on the device you put them into the Zotero folder. That also means you'd lose the files if you ever wanted to restore your library by syncing it down from the server to an empty version of Zotero.
  • But the files would be deleted during sync if the PDF was modified elsewhere (say, because your PDF reader re-saved it for some reason). I would strongly recommend not putting additional files anywhere within the data directory. This is a Zotero-managed folder, and we can't make any guarantees about unknown files.
  • Thank you both very much for your help !

    @dstillman I understand that it is not a good practice to put additional files and I will definitely try to find another way to do what I want.
    But, to be sure I understand well how zotero deals with files during sync, when you say :
    > the files would be deleted during sync if the PDF was modified elsewhere

    do you mean that if the the two pdf (one in the web library and one locally on my computer which I modify/erase manually without using zotero) are not the same, the local one would be deleted during sync ?
  • No, I'm just talking about normal file syncing: if the remote file has changed and the local one hasn't, the local one will be replaced on sync. I'm just saying that any auxiliary files in the directory would be deleted at the same time.
  • @dstillman Ok it is clear for me. Thanks a lot.

    On more question if I may (not related to your last comment), is there any difference for the library "sync process" if the file has been modified by zotero desktop app or manually by the user with the OS file explorer ? Or the "sync process" just compare the files metadata or something without checking some kind of zotero desktop app log to check the history of modifications...
  • (I didn't realize that, hence the different answer; sorry about that)
  • edited November 17, 2023
    (@adamsmith these things happen, don't worry and thank you very much for your involvement!)
  • @rigal.sylvain: Yes, Zotero itself doesn't modify the actual file. If you don't use an external PDF reader or make other external changes, the file is only ever uploaded when it's created. See Annotations in Database. External changes trigger file uploads, but as that page mentions, that's less efficient and might not happen immediately.
  • @dstillman Very interesting, I didn't know about the annotations, thank you for this discovery.
    Zotero never ceases to amaze me with its power!
    (the sync process seems to be very challenging with multiple users...)
  • did you figure out a good solution? I think you could put the tex files there, but they wouldn't show up in Zotero, right? I think it would be cool if there could be a LaTeX compiler in Zotero...
  • I don't use latex compilation (so maybe I'm missing something), but the best solution to keeping things together *within Zotero* would probably be to add the files as attachments under the parent item. If there are multiple files from each compilation, put them in a ZIP file and attach that.

    Admittedly each file would get its own (arbitrarily-named) folder (different to the PDF's folder). So finding everything from *outside* Zotero is a little more problematic, if you need to do that. But you can right-click Show File on the attachment file to get to the file you want in your OS. Also, if you have file syncing turned ON, those files will be uploaded to Zotero servers (and thus count against your online file storage quota).

    Alternatively, you could add the other files as "linked" files, from a folder elsewhere on your computer (either all in a single folder, or in a sub-folder [eg by parent name] under that folder hierarchy). That way they would be easier to find from outside Zotero, and not get file-synced.
  • edited today at 8:33am
    @tim820 I finally end up with a mix of the two solutions you propose :

    1. I store all my LaTeX files related to a pdf in a folder and the "main.tex" LaTex file is "stored" into Zotero as a linked file and I use the "Show File" feature to access the folder.
    2. When I need theses LaTeX files to be saved on the cloud, I create a zip file and attach it to the item.

    This is not completely satisfying for me because it is a lot of manual steps (create the LaTeX folder and attach it, create the zip file and attach it, attach the pdf) and I work a lot on a terminal and so I have to do "Show File" and then copy the path or open manually a terminal in this folder (I do that for all multi-files projects, e.g. with python, matlab, markdown, etc.).

    A good feature for me would be to have, in addition to "Show File", a "Open a terminal in file location" and "copy location path" options.

    My dream would be to have Zotero as a command line tool and be able to directly cd to a folder of a program project (e.g. with the following citation citation key : MyProgram), with something like : $zotero cd MyProgram
    But I will not ask for this feature because it is a completely different tool and not "just" a bibliographic assistant.

    BTW, I use Zotero as a the main interface for accessing all the files on my computer, not only document and program, but everything! I try to not navigate through folders and sub-folders with a file explorer but use Zotero instead in order to quickly find a file with the powerful research bar along with the tag management. Zotero is my main file explorer ;)

  • My dream would be to have Zotero as a command line tool and be able to directly cd to a folder of a program project (e.g. with the following citation citation key : MyProgram), with something like : $zotero cd MyProgram
    But I will not ask for this feature because it is a completely different tool and not "just" a bibliographic assistant.
    Actually, there is an Emacs package for Zotero, which should allow something similar (inside Emacs): https://gitlab.com/fvdbeek/emacs-zotero

    However, I tried and I didn't get it to work.

    But the main thing I wanted to say here is that once you know the storage folder for the PDF related item, you can have the tex files in an special folder (for example a git project you could sync through some Git repository such as Codeberg) and the pdflatex or whatever instruction, AUCTEX or latexmk allow to save the pdf file in a different directory from the tex files directory, which would be the one in the Zotero storage.

  • BTW, I use Zotero as a the main interface for accessing all the files on my computer, not only document and program, but everything! I try to not navigate through folders and sub-folders with a file explorer but use Zotero instead in order to quickly find a file with the powerful research bar along with the tag management. Zotero is my main file explorer ;)
    I do this but just restricted to PDFs, since Zotero only can read them. An Emacs approximation is much better since it can do almost anything, read text files, visualise PDFs, but also Office documents, reproduce media, etc.

    Regarding, this, ideally, Zotero should integrate in some way an Office reader (such as Emacs Docview, if not Libre Office integrated [https://forums.zotero.org/discussion/105841/fr-libre-office-embedded-into-zotero]), since many supplementary files are .docx/.odt or spreadsheets, and also a media player for Audio Recordings, Podcasts, Films, etc.
Sign In or Register to comment.