My Zotero annotation template that works

Have you the CSS snippet option turned on ? Or do you have the css file on the right folder ?

Like @odulhin mentioned, you might have forgotten the CSS snippet.

Alternatively, just on the off chance you or someone else runs into the same niche issue as I did: if you “Add a new note from annotations” in Zotero, the imported annotations won’t show up in call-out boxes at all. They’ll just look like plain text. The Zotero Integration and this template draw from the annotations themselves, so if you’ve got an Annotations note attached to the ref you’re trying to import, you can probably delete it.

If you do that and then find that no annotations are imported at all, check how many PDFs you have attached to the reference in Zotero. As far as I can tell this template only draws annotations from the top one, so delete any duplicate PDFs until your annotated PDF is the only one remaining. Those two steps fixed it for me.

I would be interested in seeing a template that could pull annotations from multiple PDFs, since having duplicates appears to be a relatively common problem for me.


Thank you for this example, it looks so great!
However I have found that when I imported a item from Zotero, the highlights are ordered by their orders of appearance, instead of grouped by their highlights. I am not familiar with the coding part, so any idea would help! Thank you very much.

Hi to be honest with I struggled quite a bit to write my template but I found a post which seems to answer your question Zotero Integration – Import Templates? - #133 by jujumartini

Hi, thanks you very much for the template. I have a question : is there a way to change the color of the highlight ? I find it very bright and i wanted to get the citation without it.
thanks for your help!

Thanks to everyone on this thread who has been so generous with their templates/responses. As a complete Obsidian newby, with limited scripting skills (very limited), this has all been extremely helpful.

@nocona I have managed to implement your template, and in doing so have a) learnt a fair bit about obsidian, and b) found a solution that suits my use case and level of skill. Thanks again.

How can I activate the CSS snippet? Can someone help?

My final template with Tags imports included. thanks to @Albialy

---
year: {{date | format ("YYYY")}}
tags: research, {{allTags}}
authors: {{authors}}

Abstract:  {{abstractNote}}
---

### {{title}}
{{pdfZoteroLink}}

### Notes
{% for annotation in annotations -%}{%- if annotation.annotatedText -%}{% if 'Red' in annotation.colorCategory %} 
##### {{annotation.annotatedText | escape }}{% else %}
<mark class="customZot-{% if annotation.color %}{{annotation.colorCategory}} {% endif %}">{{annotation.annotatedText | escape }}</mark> ([{{annotation.page}}](zotero://open-pdf/library/items/{{annotation.attachment.itemKey}}?page={{annotation.page}}&annotation={{annotation.id}}))

{% endif %}{%- endif %} {% if annotation.imageRelativePath %} ![[{{annotation.imageRelativePath}}]]{% endif %}{% if annotation.comment %} 
>{{annotation.comment}}
{% endif %}{% endfor -%}

Hello, please could you help me! I’ve been trying to use this template and thought I’d set it up correctly but for some reason when I import a paper from Zotero using the template only the annotations are imported but none of the tabs or bibliographical information. Could you advise where I am going wrong? Thanks in advance!!!

Here are some screenshots that might help!




Just wanted to say thank you for this. It works really well for my workflow.

Hi, thanks for this really useful template. I’m having trouble with the bibliography: it keeps appearing two lines below the {{bibliography}} marking. I’ve got zotero integration extension and Zotero export style both set to Nature.

This section of the template looks like:

 **Citation**:: {{bibliography}}

but I get, for example
Screenshot from 2024-01-23 10-18-20

Anyone know a solution to this? Thanks!

Numbered bibliography styles have line breaks in them. You can correct this by replacing line breaks with spaces. This should do the trick (it’s what I do in my template):

{% if bibliography %}**Citation**:: {{bibliography|replace("\n","" )}}{% endif %}

Hello!

How can I modify the template so that there’s no greater than sign after (p. 4)?

Annotations already have a default URI, I really have no idea why anyone would use the following:

zotero://open-pdf/library/items/{{annotation.attachment.itemKey}}?page={{annotation.page}}&annotation={{annotation.id}}

This is not only unnecessarily complicated, but it will also fail automatically if sources are not located in “My Library”, e.g., group libraries. Exchange it for the following:

{{annotation.desktopURI}}