Export 'LaTeX' Form
I have a title, say "Emergence of a $k$-Core", and I would like Zotero to export precisely this, not escape the $-s to give "Emergence of a \$k\$-Core". In this discussion [https://github.com/retorquere/zotero-better-bibtex/issues/124] someone explains that this can be done by tagging the item "#LaTeX". However, I don't want to have to do this for every item. (Other discussions suggest that you can tag multiple items at the same time using the "tag selector" in the bottom-left of the window... no such thing exists on my screen.) In the above referenced discussion, the person also says "As a matter of fact, if you prefer things this way, you can enable "retain LaTeX on import" in the settings and it will auto-generated any future bibtex imports." However, I cannot find this anywhere in the settings.
So I guess my question is to have (at least) one of the following answered: how do I find the tag selector, so as to be able to tag all my items at once? and where is the "retain LaTeX on import" setting?
Thanks,
Sam
So I guess my question is to have (at least) one of the following answered: how do I find the tag selector, so as to be able to tag all my items at once? and where is the "retain LaTeX on import" setting?
Thanks,
Sam
(If the hotkey won't bring it up, it will be one for the developers.)
Just for interest's sake, I'd like to know how to do the "retain LaTeX on import" also, if you know about that? (I couldn't find any reference to this via Google other than the link above.)
--
Edit: the same goes for #
1. Tag the item with "#LaTeX" (case sensitive)
2. Enter the title as "Emergence of a <pre>$k$</pre>-Core" (this is BBT-specific, and the "pre" stuff will end up in your bibliography if you're generating the bibliography in e.g. Word)
3. Using a postscript: https://retorque.re/zotero-better-bibtex/scripting/#detect-and-protect-latex-math-formulas
/(\$.*?\$)/g is a regular expression which, broken down, means:
1. /( = find and remember
2. \$ = a literal dollar sign (the backslash means literal)
3. .*? = any stretch of characters that is not like the next term (. means any, * means zero or more, ? means "but not the next term")
4. \$ = again a literal dollar sign (so the stretch of characters cannot consume the dollar sign)
5. )/ = done
So that finds anything that looks like "$....$". The next part just replaces that with "<pre>$....$</pre>". "<pre>" means "literal latex, do not touch" to BBT.
It's a heuristic and I'm sure examples can be found where it fails, but a simple synthetic example would be the title "Any price between $4.00 and $5.00".
(on an entirely unrelated note, it would be really nice if the forum supported github-flavored markdown)
I've tried adding the code for the LaTeX formula to the box, but to no avail, unfortunately: the file that is outputted (using Better BibLaTeX) looks exactly the same as without it. I consider myself pretty handy with computers, eg knowing some programming and quite a lot of in-depth troubleshooting, but I can't understand how to do this :/
if (Translator.BetterBibLaTeX) {
is a standard javascript snippet to test whether you're running BetterBibLaTeX as the translator....
}
If you don't know javascript, that's probably out of scope for a humble documentation page to explain.
(in which case option 2 is probably the better bet)
I could do option 2, but option 3 seems far preferable. It looks very basic, just the documentation doesn't say enough if you don't know javascript. By the look of it though, it just a few easy things...
Do I need to be using BetterBibTeX (rather than BetterBibLaTeX) for it to work? And if so, do I just choose Better BibTeX (rather than Better BibLateX) from the drop-down export list?
Thanks :)
if (Translator.BetterBibTeX && this.has.title) {
this.add({ name: 'title', value: item.title.replace(/(\$.*?\$)/g, '<pre>$1</pre>'), replace: true });
}
is all you need, just use copy&paste. That includes the translator test. If you want to use it with BetterBibLaTeX, use
if (Translator.BetterBibLaTeX && this.has.title) {
as the first line.
It is indeed plain javascript. You don't need to understand javascript; the BBT page mentions "but usually you can just open a new issue and ask me to write it, and I’ll add it here".
It's working now perfectly, thank you :)
It might be worth making this feature more obvious. For someone using Zotero for maths stuff, it's really vital. Otherwise the output looks terrible, eg $L^2$ becomes \$L^2\$ which prints out as $L(2 with a hat)$. The postscript facility rectifies this completely, and is very simply to implement :)
Hopefully this discussion will be a useful resource in of itself :)
The real fix is for Zotero to adopt mathjax so math in titles is actually supported, but until that time, a dollar sign that ends up in a title in Zotero just means dollar sign, and that's what ends up in Overleaf. BBT attempts to import LaTeX math into unicode equivalents where possible, and that will work when synced to Overleaf via Zotero Sync. But that is far from perfect, only a minute set of LaTeX math has acceptable unicode equivalents.
Any plan @dstillman ?