Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inquiry about citation commands supported by helm-bibtex package. #431

Closed
hongyi-zhao opened this issue May 11, 2023 · 11 comments
Closed

Inquiry about citation commands supported by helm-bibtex package. #431

hongyi-zhao opened this issue May 11, 2023 · 11 comments

Comments

@hongyi-zhao
Copy link

hongyi-zhao commented May 11, 2023

Hi here,

I am interested in knowing if helm-bibtex supports all the following citation commands in LaTeX:

  • \cite{key}
  • \citet{key}
  • \citep{key}
  • \citeauthor{key}
  • \citeyear{key}

Thank you very much for your time and assistance.

Best regards,
Zhao

@tmalsburg
Copy link
Owner

Please see the documentation of bibtex-completion-cite-commands.

@hongyi-zhao
Copy link
Author

But I cannot find this variable at all:

image

@tmalsburg
Copy link
Owner

A lot of other customization variables are missing in your screenshot. Must be a problem in your configuration because the variable I mentioned does definitely exist as you can easily confirm: https://github.com/tmalsburg/helm-bibtex/blob/master/bibtex-completion.el#L277

@hongyi-zhao
Copy link
Author

hongyi-zhao commented May 12, 2023

In my case, the configuration for helm and helm-bibtex is as follows:

(use-package helm
  :bind (:map helm-command-map
	      ("C-c h" . helm-execute-persistent-action)))

(use-package helm-bibtex
  :init
  (setq
   bibtex-completion-pdf-field "File"
   ;;https://github.com/tmalsburg/helm-bibtex#insert-latex-cite-commands
   bibtex-completion-cite-prompt-for-optional-arguments nil)

  :bind-keymap
  ("<menu>" . helm-command-prefix)
  :bind
  (
   :map helm-command-map
   ("b" . helm-bibtex)
   ("B" . helm-bibtex-with-local-bibliography)
   ("n" . helm-bibtex-with-notes)
   ("<menu>" . helm-resume)
   )

  :config
  (require 'helm-config)
  ;;https://github.com/tmalsburg/helm-bibtex#application-used-for-opening-pdfs
  ;;https://github.com/tmalsburg/helm-bibtex/issues/386
  (defun bibtex-completion-open-pdf-external (keys &optional fallback-action)
    (let ((bibtex-completion-pdf-open-function
	   (lambda (fpath) (start-process "evince" "*helm-bibtex-evince*" "/usr/bin/evince" fpath))))
      (bibtex-completion-open-pdf keys fallback-action)))

  (helm-bibtex-helmify-action bibtex-completion-open-pdf-external helm-bibtex-open-pdf-external)

  (helm-add-action-to-source
   'helm-bibtex
   '(("P" helm-bibtex-open-pdf-external "Open PDF file in external viewer (if present)")))

  ;;https://github.com/tmalsburg/helm-bibtex#browser-used-for-opening-urls-and-dois
  (setq bibtex-completion-browser-function
	(lambda (url _) (start-process "firefox" "*firefox*" "firefox" url)))

  )

I confirm the above configuration alone when testing with emacs -Q doesn't trigger the problem here. So, it must be caused by other settings.

@hongyi-zhao
Copy link
Author

On the other hand, the current predefined value of bibtex-completion-cite-commands doesn't include the following entries:

\citet{key}
\citep{key}

@tmalsburg
Copy link
Owner

Please feel free to make a pull request if you have ideas for improvements.

@hongyi-zhao
Copy link
Author

An exhaustive grep via ug gives me the following list, but I don't know whether they are all related to this variable:

werner@X10DAi:/opt/texlive/2023$ ug -Ii -oh '\{[a-zA-Z0-9]*cite[a-zA-Z0-9]*\}' | sort -u | tr '{}' ' ' |awk '{print "\""$1"\""}' |paste -sd,
"ABCIciteoptionwasused","ABCItextondemand","abntcite","abntex2cite","ABNTovercite","acrocite","acrogroupcite","agsmcite","aiDataCite","ALCitem","allnocited","anbtex2cite","andincite","andincitecn","andothersincite","andothersincitecn","apacite","apaciteclassic","apacitex","atcite","AtEachCitekey","AtEveryCite","AtEveryCitekey","AtEveryMultiCite","AtIntrocite","AtMultiEveryCite","AtNextCite","AtNextCitekey","AtNextMultiCite","atpcite","AtVolcite","AtXrefcite","authornumcite","autocite","Autocite","autocites","Autocites","AutoPuncItemize","AutoPuncItemizeE","AutoPuncItemizeO","autopuncitems","AutoPuncItems","AutoPuncItemsE","AutoPuncItemsO","avolcite","Avolcite","avolcites","Avolcites","backcite","backcitepages","backcitesections","badciteauthor","badcitefullauthor","badcitekey","badciteyear","bibcite","bibcitefn","bibcitelabel","bibentrycite","biblikecite","bibliographycite","biblistcite","blockcite","bplsecitems","breakcites","breakffcites","btCiteSect","btPrintCited","btPrintNotCited","btxcite","btxcitereference","btxcitevariant","calcite","Capacite","cc2cite","cccite","ccite","cfcite","checkcites","ChemCite","chicitecommande","chicitecommandechars","chicitecommandelarge","chscite","chslacite","cite","Cite","CITE","citeaffixed","citeall","citeallclaves","citealldefaultcite","citeallfinentry","citeallgroupseparator","citeallseparator","citealn","citealp","citealt","CiteAltPunct","citeannotesep","citeasnoun","citeathn","citeauthor","Citeauthor","citeauthorformat","citeauthorlist","citeauthorname","citeauthoronline","citeauthorstar","citeauthoryear","citeautoscript","citeb","citebib","citebibtex","citebook","citebordercolor","CiteByAuthor","CiteByFootnote","CiteByNumber","CiteBySuperscript","CiteByTag","citecfilm","citecmd","citecolor","CiteColor","citecolour","citecommand","citecompletefilm","citeconference","citecount","citecounter","citecountnopage","citecountpage","citecountpages","cited","citedas","citedash","citedate","citedby","citedbypage","citedbytitle","citedest","citedoi","citedornocited","citedstring","citeepisode","citeeprint","citefield","citefilm","citefinalnamedelim","citefirst","citefn","citeform","citefull","citefullauthor","Citefullauthor","citefullfilm","citefulltitle","citehack","citehandout","citeheading","citehyperref","citeincite","citeincitef","citeincites","citeindex","citeindexfile","citeinit","citeinxref","citeisbn","citeissue","citeissues","citejournal","citejournaltitle","citejz","citekey","citeKey","CiteKey","citelabel","citelabeldate","citelatex","citeleft","citelet","citelist","CiTelWork","citemid","citemidpenalty","citemize","cItemList","CiteMoveChars","citemultinamedelim","citen","citename","citenotitle","citenum","citenumfont","citeonce","citeonline","citeonly","citeopt","citeoption","citeorder","citep","Citep","citepack","citepackcode","citepage","citepages","citepalias","citepaper","citeprefix","citeprepenalty","CitePropriete","citepunct","citepunctpenalty","citequote","citequoteparenv","citerange","citeref","Citeref","citerequest","citereset","citerevsdnamedelim","citeright","cites","Cites","citesavefn","citeseen","citesel","CITESEL","citesep","citeseries","citesetup","citeshorthand","citeshortin","citesnum","citesort","citestyle","citet","Citet","citeta","citetalias","citetitle","Citetitle","citetlist","citetoend","citetotal","citetracker","citetrackerfalse","citetrackertrue","citetranslator","citeurl","citeURL","citeurlpost","citeurlpre","citex","citexref","citeyear","citeyearpar","cmscitesortdate","cmsciteyear","colorforcite","combcite","compactcite","compcitedelim","crosscite","datacite","DBIBcitekey","dcucite","DeclareAutoCiteCommand","DeclareCiteCommand","DeclareCitePunctuationPosition","DeclareInnerCiteDelim","DeclareInnerCiteDelimAlias","DeclareInnerCiteDelims","DeclareInnerCiteDelimsAlias","DeclareMultiCiteCommand","DeclareOuterCiteDelim","DeclareOuterCiteDelimAlias","DeclareOuterCiteDelims","DeclareOuterCiteDelimsAlias","defcitealias","DeferNextCitekeyHook","delimandincite","delimandincitecn","delimandothersincite","descitem","detailcite","detailscite","detailscites","docitem","DocItem","drftcite","Drftcite","drftffcite","DSMcite","DTLcite","DTLnocite","dvngcite","egcite","emojicite","endmcitethebibliography","entrynocite","expcites","explicite","Explicite","explicitement","extracites","extradateonlycompcitedelim","extradateonlycompciterangedelim","extranameonlycompcitedelim","extranameonlycompciterangedelim","fciteissue","fciteissues","ffciteform","ffciteleft","ffcitemid","ffcitepunct","ffciteright","filmcite","firstcite","firstcitefull","fixcitedash","fnotecite","footcite","footcitecount","footcitelabeldate","footcites","Footcites","footcitestar","footcitet","footcitetext","footcitetextlabeldate","footcitetexts","footcitetotal","footfullcite","footidemcite","footidemcites","foottextcite","foottextcites","fshowcited","ftvolcite","fulcite","fullcite","fullcitefilm","fullciteincite","fullciteincites","fullocite","fvolcite","Fvolcite","fvolcites","Fvolcites","gbcitecomp","gbcitelabel","gbcitelocal","gbcitelocalcase","gbcitepunctcn","gcite","gentextcite","gentextcites","globalcitecopy","glstopicItem","GOCiter","harvardcite","headlesscite","Headlesscite","headlesscites","headlessfullcite","headlessparencite","headlessparenshortcite","HMcitecolor","howcited","hycitebordercolor","hycitecolor","hypercite","icite","idemcite","idemcites","ideographiciterationmark","ifciteibid","ifciteidem","ifciteindex","ifciteseen","ifciteuseshorthand","iffirstcitekey","iflastcitekey","ifnocite","ifvolcite","Implicite","indxcite","inlinecite","inparencite","inreferencesasfullcite","intciteorder","introcite","introcitebreak","introcitepunct","introcitesep","introcitewidth","invalidcitestyle","jbusehowcitedforcite","jdcite","klucite","Latincite","lexcitecountinteger","mancite","mancitepar","markdownRendererCite","markdownRendererTextCite","mautocite","Mautocite","maxcitecounter","maxcitenames","mcite","mcitebibitemcount","mciteheadsortkey","mciteplus","mcitesubitemcount","MciteSubReferenceLabel","mcitethebibliography","mincitenames","mincitesep","miscItem","mkinnercitedelims","mkinnerfootcitedelims","mkinnerparencitedelims","mkinnertextcitedelims","mkoutercitedelims","mkouterfootcitedelims","mkouterparencitedelims","mkoutersupercitedelims","mkoutertextcitedelims","mkshcite","mkvolcitenote","mlarepeatedcites","multicite","multicitecount","multicitedelim","multiciterangedelim","multicites","multicitesubentrydelim","multicitesubentryrangedelim","multicitetotal","mycitecolor","natcite","neutralcite","newcites","nmbibcitenumber","nmbibSetCiteall","noapacite","nocccite","nocite","nocitecount","nocited","nocitemeta","nocites","nocitetags","noffcitecount","normalcite","notcite","notecite","Notecite","notffcite","notoccite","nptextcite","numcites","numCites","nwejmfootcite","ocite","ocites","onlinecite","Opacite","opcited","opencite","origcite","overcite","Overcite","OverciteFont","pagescite","parcitename","parencite","Parencite","parencitelabeldate","parencites","Parencites","parenfullcite","partofcited","partofcitedflag","pcite","pciteissue","pciteissues","pcitenote","pdfcitecolor","pincite","pnotecite","Pnotecite","poormancitea","posscite","Posscite","posscites","Posscites","possesivcite","possessivecite","ppexplicite","ppExplicite","PPexplicite","PPExplicite","prevcite","previewcite","Previewcite","previewcites","Previewcites","printscrcite","ProCite","pvolcite","Pvolcite","pvolcites","Pvolcites","rawcite","realcitepagesomitcmd","redefcite","refcite","RegisterCiteDelims","reviewcite","Reviewcite","reviewcites","Reviewcites","runcite","savedcitecounter","scauthorcite","scauthorscite","sccite","scite","SciTE","scitehere","sciteissue","sdcite","sentencecitename","SetCiteCommand","setcitestyle","setupcite","sfcite","sfcites","shcite","shortcite","shortformcite","shortformcites","shorthandcite","shorthandrefcite","shortrefcite","showcites","sidecite","skbslidecite","skelcite","smartcite","Smartcite","smartcites","Smartcites","sortcites","starnocited","strongcitedelim","subcite","supercite","supercitedelim","superciterangedelim","supercites","supercitesubentrydelim","supercitesubentryrangedelim","surnamecite","svolcite","Svolcite","svolcites","Svolcites","tcite","textcite","Textcite","textcitecount","textcitedelim","textcitehyperref","textcitelabeldate","textcitemaxnames","textcites","Textcites","textcitesdelim","textcitestar","textcitetotal","textpreviewcite","textreviewcite","Textreviewcite","textreviewcites","Textreviewcites","thiscite","totalcites","tvolcite","Tvolcite","tvolcites","Tvolcites","UndeclareCiteDelims","UndeclareInnerCiteDelim","UndeclareInnerCiteDelims","UndeclareOuterCiteDelim","UndeclareOuterCiteDelims","uppercasecite","usecitecmd","UseEveryCiteHook","UseEveryCitekeyHook","UseEveryMultiCiteHook","usefullcite","UseNextCiteHook","UseNextCitekeyHook","UseNextMultiCiteHook","UseVolciteHook","volcite","Volcite","volcitedelim","volcitenote","volcitepages","volcites","Volcites","volcitevolume","workscited","xcite","xcitebordercolor","xrefcite","xrefcitedascheck","ycite","ycites","yearcite","yearpagescite"

@tmalsburg
Copy link
Owner

I'm not sure whether it makes sense to include all cite commands in existence as this would make tab-completion for citations commands much less useful. I think a good default would be to include something like the top-10 most used citation commands. Not trivial though to find out what they are.

@hongyi-zhao
Copy link
Author

I think a good default would be to include something like the top-10 most used citation commands. Not trivial though to find out what they are.

See the answer given by GPT-4:

Here are the top 20 most commonly used citation commands in LaTeX:

1. `\cite{}`: Cite a single reference.
2. `\citep{}`: Cite a reference in parentheses.
3. `\citet{}`: Cite a reference in the text itself, without parentheses.
4. `\citeauthor{}`: Cite only the author(s) of a reference.
5. `\citeyear{}`: Cite only the year of a reference.
6. `\nocite{}`: Include a reference in the bibliography without citing it in the text.
7. `\footnote{\cite{}}`: Create a footnote citation.
8. `\citep*{}`: Cite a reference with all authors' names included.
9. `\citealt{}`: Cite a reference without parentheses.
10. `\citeauthor*{}`: Cite a reference with all authors' names included, without using "et al.".
11. `\citep[][]{}`: Cite a reference with multiple optional parameters.
12. `\citealp{}`: Cite a reference without parentheses and with author names separated by commas.
13. `\citeauthor[][p.~]{}`: Cite a reference with page numbers and additional text before the citation.
14. `\citep{A, B}`: Cite multiple references in a single citation, separated by commas.
15. `\citeauthor{A, B}`: Cite multiple references with author names in a single citation, separated by commas.
16. `\citeyearpar{}`: Cite a reference in parentheses with the year.
17. `\citepalias{}`: Cite a reference with an alias (a short name for the citation).
18. `\citeauthoryear{}`: Cite a reference with both author names and year.
19. `\citeyear[][p.~]{}`: Cite a reference with the year and additional text before the citation.
20. `\citet*{}`: Cite a reference with all authors' names included, for use in the text.

These are 20 of the most commonly used citation commands in LaTeX. Remember to replace "A" and "B" with the actual reference keys you are citing.

@tmalsburg
Copy link
Owner

Hm, it's not clear that GPT-4 actually has internal access to the frequencies of commands. Also not that the biblatex standard commands parencite and textcite are missing in the list. Seems slightly suspicious to me. But there are certainly some commands in that list that should be included, notably nocite, citet, citep.

@hongyi-zhao
Copy link
Author

Also not that the biblatex standard commands parencite and textcite are missing in the list.

It seems that you originally intended to express Also, it's worth noting that ....

dankessler added a commit to dankessler/helm-bibtex that referenced this issue Feb 20, 2024
As was discussed in tmalsburg#431, add support for some additional typical citation commands in `natbib`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants