From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: export to latex but *not* export the citations Date: Fri, 19 Jan 2018 12:17:12 -0800 Message-ID: References: <87a7x9ylcr.fsf@skimble.plus.com> <878tctx0f4.fsf@skimble.plus.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="001a114b35b217414f056326c474" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:36278) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecd6D-0003mD-8P for emacs-orgmode@gnu.org; Fri, 19 Jan 2018 15:17:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ecd6B-0006SW-3c for emacs-orgmode@gnu.org; Fri, 19 Jan 2018 15:17:17 -0500 Received: from mail-wm0-x231.google.com ([2a00:1450:400c:c09::231]:42293) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ecd6A-0006Ou-MZ for emacs-orgmode@gnu.org; Fri, 19 Jan 2018 15:17:15 -0500 Received: by mail-wm0-x231.google.com with SMTP id b141so5679115wme.1 for ; Fri, 19 Jan 2018 12:17:14 -0800 (PST) In-Reply-To: <878tctx0f4.fsf@skimble.plus.com> 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" To: Sharon Kimble Cc: org-mode-email --001a114b35b217414f056326c474 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I don't think that it is possible for the snippet I sent to remove the the parentheses as they are not part of the link. You can either replace them all interactively with a regexp, e.g. #+BEGIN_SRC emacs-lisp (goto-char (point-min)) (query-replace-regexp "(\\(cite:.*\\))" "\\1") #+END_SRC That regexp assumes they are all cite links (e.g. no citep, etc), and that there are no spaces between the (). This is what I would do, it should prompt you for each replacement, and you will end up pressing y 381 times. Alternatively, you can use this approach to remove the links from a copy of the buffer right before it is exported. This will leave the original links in place. #+BEGIN_SRC emacs-lisp (let ((org-export-before-processing-hook (lambda (backend) (goto-char (point-max)) (while (re-search-backward "(cite:.*)" nil t) (setf (buffer-substring (match-beginning 0) (match-end 0)) ""))))) (org-latex-export-as-latex)) #+END_SRC John ----------------------------------- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu On Fri, Jan 19, 2018 at 8:45 AM, Sharon Kimble wrote: > John Kitchin writes: > > > You can try this: > > > > * Build :noexport: > > > > Put this heading in your file, and run this block. > > > > #+BEGIN_SRC emacs-lisp > > (flet ((org-ref-format-cite (keyword desc format) "")) > > (org-latex-export-to-latex)) > > #+END_SRC > > > > It will temporarily redefine the cite export function. It appears it > > replaces them with a space, but this should be a problem for latex. > > > Sorry list, I inadvertently sent this direct to John. > > Thanks John for this, its not quite working as I'd like, so I'll explain > it with examples. > > * Case 1 - original setup > > --8<---------------cut here---------------start------------->8--- > Source =3D > > The remaining 'other place' > deaths include over 150 described as 'psychiatric hospitals', 'psychiatri= c > hospitals (security)' or > 'psychiatric unit' (cite:0113). > > Pdf =3D > > The remaining > =E2=80=99other place=E2=80=99 deaths include over 150 described as =E2=80= =99psychiatric > hospitals=E2=80=99, =E2=80=99psychiatric hospitals > (security)=E2=80=99 or =E2=80=99psychiatric unit=E2=80=99 (WILSON , 2015)= . > --8<---------------cut here---------------end--------------->8--- > > > * Case 2 - brackets removed round citation > > --8<---------------cut here---------------start------------->8--- > Source =3D > > The remaining 'other place' > deaths include over 150 described as 'psychiatric hospitals', 'psychiatri= c > hospitals (security)' or > 'psychiatric unit' cite:0113. > > Pdf =3D > > The remaining > =E2=80=99other place=E2=80=99 deaths include over 150 described as =E2=80= =99psychiatric > hospitals=E2=80=99, =E2=80=99psychiatric hospitals > (security)=E2=80=99 or =E2=80=99psychiatric unit=E2=80=99 WILSON , 2015. > --8<---------------cut here---------------end--------------->8--- > > * Case 3 - with John's coding > > --8<---------------cut here---------------start------------->8--- > Source =3D > > The remaining 'other place' > deaths include over 150 described as 'psychiatric hospitals', 'psychiatri= c > hospitals (security)' or > 'psychiatric unit' (cite:0113). > > And with your coding and built as pdf =3D > > The remaining > =E2=80=99other place=E2=80=99 deaths include over 150 described as =E2=80= =99psychiatric > hospitals=E2=80=99, =E2=80=99psychiatric hospitals > (security)=E2=80=99 or =E2=80=99psychiatric unit=E2=80=99 (). > --8<---------------cut here---------------end--------------->8--- > > > * Case 4 - with John's coding > > --8<---------------cut here---------------start------------->8--- > Source =3D > > The remaining 'other place' > deaths include over 150 described as 'psychiatric hospitals', 'psychiatri= c > hospitals (security)' or > 'psychiatric unit' cite:0113. > > And with your coding and built as pdf =3D > > The remaining > =E2=80=99other place=E2=80=99 deaths include over 150 described as =E2=80= =99psychiatric > hospitals=E2=80=99, =E2=80=99psychiatric hospitals > (security)=E2=80=99 or =E2=80=99psychiatric unit=E2=80=99 . > --8<---------------cut here---------------end--------------->8--- > > > - Case 1 is the start point and as it currently is. > - Case 2 is an interim stage, with the circular brackets round the > citation removed. When its exported the sentence looks ugly with out > any differentiation between the text and the citation. > - Case 3 is with John's coding snippet being applied and the whole > exported, and it leaves the circular brackets round the citation > behind but no citation. > - Case 4 is with John's coding snippet applied after the circular > brackets have been removed, and is nirvana! :) > > But it would be a mammoth undertaking going through and removing all the > circular brackets round the citations, and there's 381 references in the > bibliography, so is it possible for your code snippet to temporarily > remove the circular brackets as part of its building the tex file > please? > > Thanks John, I do appreciate it > > Sharon. > > > > Sharon Kimble writes: > > > >> I'm writing a document which currently has 408 pages and over a 1,000 > >> footnotes, and with a size of 1.1 mbs. > >> > >> I'm exporting it to latex using 'org-latex-export-to-latex' and am now > >> wondering is it possible to export it *and* omit the citations? The > >> citations currently are showing in the org-mode source file as > >> '(cite:xxxx)'. > >> > >> So to clarify - the org-mode document is exported to latex and then > >> built into a pdf file in a separate process. The org-mode document has > >> citations, showing in the org-mode document as '(cite:xxxx)', where th= e > >> 'xxxx' is any one of four figures which don't have any impact on reali= ty > >> in org-mode, though org-ref allows them to be seen as a quasi-bibtex > >> display in the mini-buffer. When the pdf file is built they are > >> converted into authoryear citations, and its these citations that I'm > >> looking to *not* display in the pdf file. I would like the citations t= o > >> still show in the org-mode source document but not to show in the fina= l > >> built pdf file. > >> > >> The file, or program, that is building the pdf can be seen at [fn:1]. > >> > >> So how can I do it please? > >> > >> Thanks > >> Sharon. > >> > >> [fn:1] 'pdfbuild' - from tex to PDF - version 2 =3D > http://www.sharons.org.uk/pdfbuild2.html > > -- > A taste of linux =3D http://www.sharons.org.uk > TGmeds =3D http://www.tgmeds.org.uk > DrugFacts =3D https://www.drugfacts.org.uk > Debian 9.3, fluxbox 1.3.7, emacs 25.3.2, org-mode 9.1.6-10-g0c9329-elpapl= us > --001a114b35b217414f056326c474 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I don't think that it is possible for the snippet I se= nt to remove the the parentheses as they are not part of the link.=C2=A0
You can either replace them all interactively with a regex= p, e.g.

#+BEGIN_SRC emacs-lisp
(got= o-char (point-min))
(query-replace-regexp "(\\(cite:.*\\))&q= uot; "\\1")
#+END_SRC

Th= at regexp assumes they are all cite links (e.g. no citep, etc), and that th= ere are no spaces between the (). This is what I would do, it should prompt= you for each replacement, and you will end up pressing y 381 times.
<= div>
Alternatively, you can use this approach to remove the l= inks from a copy of the buffer right before it is exported. This will leave= the original links in place.

#+BEGIN_SR= C emacs-lisp
(let ((org-export-before-processing-hook (lambda (ba= ckend)
=C2=A0 =C2=A0(= goto-char (point-max))
=C2=A0 =C2=A0(while (re-search-backward "(cite:.*)" nil t)
=C2=A0 =C2=A0 =C2=A0(setf= (buffer-substring (match-beginning 0) (match-end 0)) "")))))
=C2=A0 (org-latex-export-as-latex))
#+END_SRC
<= /div>

<= div dir=3D"ltr">John

-----------------------------------
Professo= r John Kitchin=C2=A0
Doherty Hall A207F
Department of Chemical Engine= ering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803=

On Fri, Jan 19, 2018 at 8:45 AM, Sharon Kimb= le <boudiccas@skimble.plus.com> wrote:
John Kitchin <jkitchin@andrew.cmu.edu> writes:

> You can try this:
>
> * Build :noexport:
>
> Put this heading in your file, and run this block.
>
> #+BEGIN_SRC emacs-lisp
> (flet ((org-ref-format-cite (keyword desc format) ""))
>=C2=A0 (org-latex-export-to-latex))
> #+END_SRC
>
> It will temporarily redefine the cite export function. It appears it > replaces them with a space, but this should be a problem for latex. >
Sorry list, I inadvertently sent this direct to John.

Thanks John for this, its not quite working as I'd like, so I'll ex= plain it with examples.

* Case 1 - original setup

--8<---------------cut here---------------start------------->8--= -
Source =3D

The remaining 'other place'
deaths include over 150 described as 'psychiatric hospitals', '= psychiatric hospitals (security)' or
'psychiatric unit' (cite:0113).

Pdf =3D

The remaining
=E2=80=99other place=E2=80=99 deaths include over 150 described as =E2=80= =99psychiatric hospitals=E2=80=99, =E2=80=99psychiatric hospitals
(security)=E2=80=99 or =E2=80=99psychiatric unit=E2=80=99 (WILSON , 2015).<= br> --8<---------------cut here---------------end--------------->8--= -


* Case 2 - brackets removed round citation

--8<---------------cut here---------------start------------->8--= -
Source =3D

The remaining 'other place'
deaths include over 150 described as 'psychiatric hospitals', '= psychiatric hospitals (security)' or
'psychiatric unit' cite:0113.

Pdf =3D

The remaining
=E2=80=99other place=E2=80=99 deaths include over 150 described as =E2=80= =99psychiatric hospitals=E2=80=99, =E2=80=99psychiatric hospitals
(security)=E2=80=99 or =E2=80=99psychiatric unit=E2=80=99 WILSON , 2015. --8<---------------cut here---------------end--------------->8--= -

* Case 3 - with John's coding

--8<---------------cut here---------------start------------->8--= -
Source =3D

The remaining 'other place'
deaths include over 150 described as 'psychiatric hospitals', '= psychiatric hospitals (security)' or
'psychiatric unit' (cite:0113).

And with your coding and built as pdf =3D

The remaining
=E2=80=99other place=E2=80=99 deaths include over 150 described as =E2=80= =99psychiatric hospitals=E2=80=99, =E2=80=99psychiatric hospitals
(security)=E2=80=99 or =E2=80=99psychiatric unit=E2=80=99 ().
--8<---------------cut here---------------end--------------->8--= -


* Case 4 - with John's coding

--8<---------------cut here---------------start------------->8--= -
Source =3D

The remaining 'other place'
deaths include over 150 described as 'psychiatric hospitals', '= psychiatric hospitals (security)' or
'psychiatric unit' cite:0113.

And with your coding and built as pdf =3D

The remaining
=E2=80=99other place=E2=80=99 deaths include over 150 described as =E2=80= =99psychiatric hospitals=E2=80=99, =E2=80=99psychiatric hospitals
(security)=E2=80=99 or =E2=80=99psychiatric unit=E2=80=99 .
--8<---------------cut here---------------end--------------->8--= -


- Case 1 is the start point and as it currently is.
- Case 2 is an interim stage, with the circular brackets round the
=C2=A0 citation removed. When its exported the sentence looks ugly with out=
=C2=A0 any differentiation between the text and the citation.
- Case 3 is with John's coding snippet being applied and the whole
=C2=A0 exported, and it leaves the circular brackets round the citation
=C2=A0 behind but no citation.
- Case 4 is with John's coding snippet applied after the circular
=C2=A0 brackets have been removed, and is nirvana! :)

But it would be a mammoth undertaking going through and removing all the circular brackets round the citations, and there's 381 references in th= e
bibliography, so is it possible for your code snippet to temporarily
remove the circular brackets as part of its building the tex file
please?

Thanks John, I do appreciate it

Sharon.


> Sharon Kimble writes:
>
>> I'm writing a document which currently has 408 pages and over = a 1,000
>> footnotes, and with a size of 1.1 mbs.
>>
>> I'm exporting it to latex using 'org-latex-export-to-latex= ' and am now
>> wondering is it possible to export it *and* omit the citations? Th= e
>> citations currently are showing in the org-mode source file as
>> '(cite:xxxx)'.
>>
>> So to clarify - the org-mode document is exported to latex and the= n
>> built into a pdf file in a separate process. The org-mode document= has
>> citations, showing in the org-mode document as '(cite:xxxx)= 9;, where the
>> 'xxxx' is any one of four figures which don't have any= impact on reality
>> in org-mode, though org-ref allows them to be seen as a quasi-bibt= ex
>> display in the mini-buffer. When the pdf file is built they are >> converted into authoryear citations, and its these citations that = I'm
>> looking to *not* display in the pdf file. I would like the citatio= ns to
>> still show in the org-mode source document but not to show in the = final
>> built pdf file.
>>
>> The file, or program, that is building the pdf can be seen at [fn:= 1].
>>
>> So how can I do it please?
>>
>> Thanks
>> Sharon.
>>
>> [fn:1] 'pdfbuild' - from tex to PDF - version 2 =3D http://www.sharons.org.uk/pdfbuild2.html

--
A taste of linux =3D http://= www.sharons.org.uk
TGmeds =3D http://www.tgmeds.org.uk
DrugFacts =3D https://www.drugfacts.org.uk
Debian 9.3, fluxbox 1.3.7, emacs 25.3.2, org-mode 9.1.6-10-g0c9329-elpaplus=

--001a114b35b217414f056326c474--