From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id KAyIJY5G0WMnEwAAbAwnHQ (envelope-from ) for ; Wed, 25 Jan 2023 16:11:10 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id MN1kJI5G0WPRdAAAG6o9tA (envelope-from ) for ; Wed, 25 Jan 2023 16:11:10 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 33E2CE15 for ; Wed, 25 Jan 2023 16:11:10 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pKhPr-0007GF-Vo; Wed, 25 Jan 2023 10:10:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pKhPp-0007Ef-AK for emacs-orgmode@gnu.org; Wed, 25 Jan 2023 10:10:21 -0500 Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pKhPm-00081W-Pk for emacs-orgmode@gnu.org; Wed, 25 Jan 2023 10:10:21 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 93A7E24054D for ; Wed, 25 Jan 2023 16:10:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1674659415; bh=b7j7fLeN23aA4M02AHPWIKWy2hWmeWZhn1C7IP4Xw/E=; h=From:To:Subject:Date:From; b=L/lAjJgcIDDlz4b4507IEVxCGoHeIOerU2H0OcDb8WZoaLQVes/eYFr2L1YDnnuLk GQa5ovbrSflAm8zteojA7pBGBaTBjCXQUtqyMSYu0cyL1rBdTzLNozUtrt2kB/xXQ0 sDX6tmnAv5eRNktMMk2S8LuXWtgr1yb7aQ9yzciAyRzOG1f/z3vTSErBelAwM7gOJv zqTys1MDQiNubwsShJ2UQVg03sVsPE6OpWcX8JDQjkXSkue0tsRsZJj1vUnNLedjn7 R0TwznCccdWTymemye0hLQ8yihgfU3ByLiAJQYIU5qgEe/yc5AL5+ZJ0B0oHi9/1OT GricieP6pSdmw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4P26hk6Hzpz6tmc for ; Wed, 25 Jan 2023 16:10:14 +0100 (CET) From: Ihor Radchenko To: emacs-orgmode@gnu.org Subject: [PATCH] oc-natbib: Provide a fallback bibliography style Date: Wed, 25 Jan 2023 15:10:47 +0000 Message-ID: <87bkmmlkeg.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.65; envelope-from=yantar92@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=yhetil.org; t=1674659470; a=rsa-sha256; cv=none; b=oXjSWs/QQ7Uv3XwGl7pRFkhjyad/QZS1G+ox1Bw6pq2b6Fsu8WWRRPdk3O0JqYwR1ZMdEv V5P9v+aX9V9WBbfb4FJG7tQOmrEse3qShkwRbcMvcwRu02Dv6TIxwb6NrSnSL1ghFu99a2 bgIBYSrmLolccWuxrEA6JjUoaXZYavMaQFjp20o/4R8PbJKeRBnwNVtWjG3P9sXI/Z/er7 CQyjkk/fRyJS2tAZ3u2cn8oil9dz3OjoskKrti4sYxhtX+uJfr1u5ERcDtmFl82EPjHQxG cesFp5Oe8PXjH3hMpg6gLwM7Ucu/4XVtTj1+8Mx8LTtdi0ef11Q+YLjSbbKRHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1674659470; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=3Eti53QBrZgp6XlVUms4XSKOOTq8ADYQdaPAmeP8Q4E=; b=n3pUhhwJ2GYNVJih/6vWTZp4ca5Zg6nBlVXy2h7Fjgdu9opKYdGS/LjwkBhuEA2ByUTvI2 +HD2qJEBUAMTwGUjMdLvj/bE/ML+Cq4i8SOCbw3UgPT2wZ1mJFiaRriXsZYvoSbyVQmepr 7o/TOqBi6eHqMqOBNsNiHm7oRT8Lc+U5kSnZ5MHj4FL8jdjTgfU6Z304K1ED+zpFjfnIOe xhmtHA6735NE2e7sR5VOB/8cWF0xW4JirWCy8OaWmhsmyosR5uLbrXmz03WJKFPaDBk9ye DzxfyejFhorSCUFCAMdZhpmN6RYAmvrJIK9sLs9RIUrpOopnvQnzH+7F1Z9OHQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b="L/lAjJgc"; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=posteo.net X-Migadu-Scanner: scn0.migadu.com X-Migadu-Spam-Score: -7.84 X-Spam-Score: -7.84 X-Migadu-Queue-Id: 33E2CE15 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b="L/lAjJgc"; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=posteo.net X-TUID: CoZ5qNExoGtG --=-=-= Content-Type: text/plain If we do not specify a bibliography style, LaTeX export will fail. With the attached patch, the following simple-minded Org document will export without errors: #+title: Testing org-cite \LaTeX export #+latex_header: \usepackage{natbib} #+bibliography: bibliography.bib #+options: toc:nil #+cite_export: natbib Hello World! This is a citation: [cite:@citationkey2023] #+print_bibliography: Also, should we provide some commonly available natbib styles in the defcustom? --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-oc-natbib-Provide-a-fallback-bibliography-style.patch >From f27e5b4f66b7e703f9b2fdaa5c1b5d756d38fd33 Mon Sep 17 00:00:00 2001 Message-Id: From: Ihor Radchenko Date: Wed, 25 Jan 2023 18:02:49 +0300 Subject: [PATCH] oc-natbib: Provide a fallback bibliography style * lisp/oc-natbib.el (org-cite-natbib-bibliography-style): New custom option for default bibliography style. (org-cite-natbib-export-bibliography): Use the new custom option. * etc/ORG-NEWS (New ~org-cite-natbib-export-bibliography~ option defining fallback bibliography style): Document the new option. If we do not specify a bibliography style, LaTeX export will fail. After the patch, the following simple-minded Org document will export without errors: #+title: Testing org-cite \LaTeX export #+latex_header: \usepackage{natbib} #+bibliography: bibliography.bib #+options: toc:nil #+cite_export: natbib Hello World! This is a citation: [cite:@citationkey2023] #+print_bibliography: --- etc/ORG-NEWS | 10 ++++++++++ lisp/oc-natbib.el | 21 ++++++++++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 3ef76ec1a..04f6338a9 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -13,6 +13,16 @@ Please send Org bug reports to mailto:emacs-orgmode@gnu.org. * Version 9.7 (not released yet) ** New options +*** New ~org-cite-natbib-export-bibliography~ option defining fallback bibliography style + +~natbib~ citation export processor now uses +~org-cite-natbib-export-bibliography~ (defaults to ~unsrtnat~) as a +fallback bibliography style if none is specified by user in +=#+cite_export:= keyword. + +Previously, export would fail without explicitly selected bibliography +style. + *** New options for the "csl" citation export processor's LaTeX output The ~org-cite-csl-latex-label-separator~ and diff --git a/lisp/oc-natbib.el b/lisp/oc-natbib.el index 855be2a5c..9153afd86 100644 --- a/lisp/oc-natbib.el +++ b/lisp/oc-natbib.el @@ -77,6 +77,15 @@ (defcustom org-cite-natbib-options nil (const :tag "redefine \\thebibliography to issue \\section* instead of \\chapter*" sectionbib) (const :tag "keep all the authors' names in a citation on one line" nonamebreak))) +(defcustom org-cite-natbib-bibliography-style 'unsrtnat + "Default bibliography style." + :group 'org-cite + :package-version '(Org . "9.7") + :type + '(choice + (const unsrtnat) + (symbol :tag "Other"))) + ;;; Internal functions (defun org-cite-natbib--style-to-command (style) @@ -143,11 +152,13 @@ (defun org-cite-natbib-export-bibliography (_keys files style &rest _) "Print references from bibliography FILES. FILES is a list of absolute file names. STYLE is the bibliography style, as a string or nil." - (concat (and style (format "\\bibliographystyle{%s}\n" style)) - (format "\\bibliography{%s}" - (mapconcat #'file-name-sans-extension - files - ",")))) + (concat + (format "\\bibliographystyle{%s}\n" + (or style org-cite-natbib-bibliography-style)) + (format "\\bibliography{%s}" + (mapconcat #'file-name-sans-extension + files + ",")))) (defun org-cite-natbib-export-citation (citation style _ info) "Export CITATION object. -- 2.39.1 --=-=-= Content-Type: text/plain -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at --=-=-=--