From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: ox-bibtex.el -- how to join sequential citations Date: Tue, 26 Nov 2013 06:16:08 -0700 Message-ID: <8738mjmhfh.fsf@gmail.com> References: <87siunf5lq.fsf@gmail.com> <878uwemrni.fsf@news.tumashu-localhost.org> <8761ri6sr9.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:52614) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VlIWi-0007J1-DL for emacs-orgmode@gnu.org; Tue, 26 Nov 2013 08:18:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VlIWd-0001iy-8L for emacs-orgmode@gnu.org; Tue, 26 Nov 2013 08:18:04 -0500 Received: from mail-pd0-x22a.google.com ([2607:f8b0:400e:c02::22a]:35869) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VlIWd-0001ii-1D for emacs-orgmode@gnu.org; Tue, 26 Nov 2013 08:17:59 -0500 Received: by mail-pd0-f170.google.com with SMTP id g10so7674089pdj.15 for ; Tue, 26 Nov 2013 05:17:58 -0800 (PST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Nicolas Goaziou Cc: Feng Shu , emacs-orgmode@gnu.org Nicolas Goaziou writes: > Hello, > > Feng Shu writes: > >> Eric Schulte writes: >> >>> When exporting multiple sequential citations e.g., cite:foo cite:bar >>> etc... I would like to see something like the following (latex used for >>> this example) "\cite{foo, bar}", but instead I'm getting "\cite{foo} >>> \cite{bar}", which leads to poorly formed PDFs (a similar thing happens >>> for HTML export). >> >> May be you should use \cite{foo, bar} directly in org file. > > That was, indeed, the original way to handle citations in the former > org-export-bibtex.el. It is still supported in both LaTeX, obviously, > and HTML (which will split the above among two anchors). > > "cite" link support was added later, and is lacking in this area. > >>> My question is how best to fix this, should I write a filter function, >>> or does the export engine already have processes in place to handle >>> these sorts of export context issues? > > At the user level, a filter is definitely the way to go. > Thanks, the following seems to be working. Perhaps the filter function should be added to ox-bibtex.el? (defun org-bibtex-group-citations (text backend info) "Convert begin/end{verbatim} to begin/end{Verbatim}. Allows use of the fancyvrb latex package." (with-temp-buffer (insert text) (goto-char (point-min)) (cond ((org-export-derived-backend-p backend 'latex) (while (re-search-forward "\\\\cite{\\([^[:space:]\n\r]+\\)}[[:space:]\n\r]*\\\\cite{" nil t) (replace-match "\\\\cite{\\1,") (goto-char (point-min)))) ((org-export-derived-backend-p backend 'html) (while (re-search-forward "\\(#[[:alnum:]]+\">[0-9]+<\/a>\\)\\][[:space:]\n\r]*\\[\\([0-9]+<\/a>\\)" nil t) (replace-match "\\1,\\2") (goto-char (point-min))))) (buffer-string))) (add-to-list 'org-export-filter-final-output-functions 'org-bibtex-group-citations) Cheers, > > Though, it is an interesting feature to implement in ox-bibtex.el. One > idea would be to write another parse-tree filter function which would > change cite links into \cite{...} commands and consecutive cite links > into \cite{..., ...} commands. > > This would also allow us to get rid of both `org-html-link' and > `org-latex-link' advices, as no more cite link would be left in the > parse tree anyway. > > What do you think? > > > Regards, -- Eric Schulte https://cs.unm.edu/~eschulte PGP: 0x614CA05D