emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* multi-line citation export issue
@ 2014-01-12 23:21 Ken Mankoff
  2014-01-12 23:23 ` Ken Mankoff
  2014-01-13  0:02 ` Nicolas Goaziou
  0 siblings, 2 replies; 7+ messages in thread
From: Ken Mankoff @ 2014-01-12 23:21 UTC (permalink / raw)
  To: Org-mode

[-- Attachment #1: Type: text/plain, Size: 207 bytes --]

If I have some text and then \cite{a, b
  c, d, e}, these citations do not export properly
to LaTeX, due to the newline in the \cite{}.

The command is escaped and appears as \cite\{a, b, c, d, e\}.

   -k.

[-- Attachment #2: Type: text/html, Size: 299 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: multi-line citation export issue
  2014-01-12 23:21 multi-line citation export issue Ken Mankoff
@ 2014-01-12 23:23 ` Ken Mankoff
  2014-01-13  0:02 ` Nicolas Goaziou
  1 sibling, 0 replies; 7+ messages in thread
From: Ken Mankoff @ 2014-01-12 23:23 UTC (permalink / raw)
  To: Org-mode

[-- Attachment #1: Type: text/plain, Size: 502 bytes --]

And a slightly more complicated example:

\cite[some text here
where spaces are not optional]{citekey1,citekey2}

Exports as \cite[some text here where spaces are not
optional]\{citekey1,citekey2\}

   -k.


On Sun, Jan 12, 2014 at 6:21 PM, Ken Mankoff <mankoff@gmail.com> wrote:

> If I have some text and then \cite{a, b
>   c, d, e}, these citations do not export properly
> to LaTeX, due to the newline in the \cite{}.
>
> The command is escaped and appears as \cite\{a, b, c, d, e\}.
>
>    -k.
>

[-- Attachment #2: Type: text/html, Size: 1020 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: multi-line citation export issue
  2014-01-12 23:21 multi-line citation export issue Ken Mankoff
  2014-01-12 23:23 ` Ken Mankoff
@ 2014-01-13  0:02 ` Nicolas Goaziou
  2014-01-13  2:04   ` Ken Mankoff
  1 sibling, 1 reply; 7+ messages in thread
From: Nicolas Goaziou @ 2014-01-13  0:02 UTC (permalink / raw)
  To: Ken Mankoff; +Cc: Org-mode

Hello,

Ken Mankoff <mankoff@gmail.com> writes:

> If I have some text and then \cite{a, b
>   c, d, e}, these citations do not export properly
> to LaTeX, due to the newline in the \cite{}.

Use export snippets:

  @@latex:\cite{....}@@

Outside math mode, Org support for LaTeX is very limited.


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: multi-line citation export issue
  2014-01-13  0:02 ` Nicolas Goaziou
@ 2014-01-13  2:04   ` Ken Mankoff
  2014-01-13 11:07     ` Nicolas Goaziou
  0 siblings, 1 reply; 7+ messages in thread
From: Ken Mankoff @ 2014-01-13  2:04 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Org-mode

On Mon, 13 Jan 2014, Nicolas Goaziou wrote:
>
> Use export snippets:
>
>  @@latex:\cite{....}@@
>

I am not familiar with export snippets, but I guess from that syntax 
that I will not be able to export with citations to ODT/DOC. Right 
now one org file exports well to both formats.

I will deal with multiple citations by not having spaces, and find 
some other way (rewording?) to deal with the \cite[foo bar]{baz} 
situation. And maybe someone more versed in org source can file this 
as a bug, even if not a priority.

   -k.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: multi-line citation export issue
  2014-01-13  2:04   ` Ken Mankoff
@ 2014-01-13 11:07     ` Nicolas Goaziou
  2014-01-13 15:23       ` Ken Mankoff
  0 siblings, 1 reply; 7+ messages in thread
From: Nicolas Goaziou @ 2014-01-13 11:07 UTC (permalink / raw)
  To: Ken Mankoff; +Cc: Org-mode

Hello,

Ken Mankoff <mankoff@gmail.com> writes:

> I am not familiar with export snippets, but I guess from that syntax
> that I will not be able to export with citations to ODT/DOC. Right now
> one org file exports well to both formats.

You can also write the same for odt:

  @@odt:\cite{key}@@

So, in your buffer, it would become:

  @@latex:\cite{key}@@@@odt:\cite{key}@@

And you can avoid the implied repetition with a macro:

  #+MACRO: cite @@latex:\cite{$1}@@@@odt:\cite{$1}@@

and write in your document:

  {{{cite(key)}}}

Note that you will need to escape commas (with backslashed) in key.

This also works for your more complicated example :

  #+MACRO: cite2 @@latex:\cite[$1]{$2}@@@@odt:\cite[$1]{$2}@@

> I will deal with multiple citations by not having spaces, and find
> some other way (rewording?) to deal with the \cite[foo bar]{baz}
> situation. And maybe someone more versed in org source can file this
> as a bug, even if not a priority.

This is not a bug. Parsing any LaTeX macro is way out of Org's league.
Org conveniently support some simple macros, that's all.


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: multi-line citation export issue
  2014-01-13 11:07     ` Nicolas Goaziou
@ 2014-01-13 15:23       ` Ken Mankoff
  2014-01-13 21:56         ` Rasmus
  0 siblings, 1 reply; 7+ messages in thread
From: Ken Mankoff @ 2014-01-13 15:23 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Org-mode

Hi Nicolas et al.,

On Mon, 13 Jan 2014, Nicolas Goaziou wrote:

> Ken Mankoff <mankoff@gmail.com> writes:
>
>> I am not familiar with export snippets, but I guess from that 
>> syntax that I will not be able to export with citations to 
>> ODT/DOC. Right now one org file exports well to both formats.
>
> You can also write the same for odt:
>
>  @@odt:\cite{key}@@
>
> So, in your buffer, it would become:
>
>  @@latex:\cite{key}@@@@odt:\cite{key}@@
>
> And you can avoid the implied repetition with a macro:
>
>  #+MACRO: cite @@latex:\cite{$1}@@@@odt:\cite{$1}@@
>
> and write in your document:
>
>  {{{cite(key)}}}
>
> Note that you will need to escape commas (with backslashed) in key.
>
> This also works for your more complicated example :
>
>  #+MACRO: cite2 @@latex:\cite[$1]{$2}@@@@odt:\cite[$1]{$2}@@
>

Wow. I was going point out that citing for both formats is 
cumbersome and makes the document hard-to-read, but the MACRO solves 
this. I was not aware of MACRO's. I guess this is both the beauty 
and pain of Org and emacs, all this customization. And down the 
rabbit-hole I go, because now I need to redefine my RefTeX shortcut 
so that it inserts {{{cite(key)}}} instead of \cite{key}.

Unfortunately this is probably not something I have the skill to do 
right now. Perhaps I could get it for one citation, but the regex 
detect when inside an existing cite command and just insert the key, 
not the latex command wrapping it, is beyond my lisp skill and time. 
I'll just deal with no spaces inside \cite{a,b}.

But thank you for teaching me about MACRO anyway.

   -k.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: multi-line citation export issue
  2014-01-13 15:23       ` Ken Mankoff
@ 2014-01-13 21:56         ` Rasmus
  0 siblings, 0 replies; 7+ messages in thread
From: Rasmus @ 2014-01-13 21:56 UTC (permalink / raw)
  To: emacs-orgmode

Ken Mankoff <mankoff@gmail.com> writes:

> Wow. I was going point out that citing for both formats is cumbersome
> and makes the document hard-to-read, but the MACRO solves this. I was
> not aware of MACRO's. I guess this is both the beauty and pain of Org
> and emacs, all this customization. And down the rabbit-hole I go,
> because now I need to redefine my RefTeX shortcut so that it inserts
> {{{cite(key)}}} instead of \cite{key}.

Another possibility is using links as suggested by Tom S. Dye.  These
do not suffer from the newline problem you encountered.  They do not
format nicely, though, if you have complicated cite-constructions.

Here's an example using biblatex syntax in LaTeX and a cite tag in
HTML:

(org-add-link-type
 "textcite" 'ramus/find-lit
 (lambda (path desc format)
   (cond
    ((eq format 'html)
     (format "(<cite>%s</cite>)" path))
    ((eq format 'odt)
     (format "%s" path))
    ((eq format 'latex)
     (if (or (not desc) (equal 0 (search "cite:" desc)))
         (format "\\textcite{%s}" path)
       (format "\\textcite[%s][%s]{%s}"
               (cadr (split-string desc ";"))
               (car (split-string desc ";"))  path))))))

where rasmus/find-lit opens the correct pdf from my local archive, if
possible.

You can add reftex support in a manner similar to the following:

(with-eval-after-load 'org
  (defun org-mode-reftex-setup ()
    ;; (load-library "reftex")
    (require 'reftex)
    (and (buffer-file-name)
         (file-exists-p (buffer-file-name))
         ;; (reftex-parse-all)
         )
    (make-local-variable 'reftex-cite-format)
    (setq reftex-cite-format 'org)
    (define-key org-mode-map (kbd "C-c )") 'reftex-citation))
  (add-hook 'org-mode-hook 'org-mode-reftex-setup))

(with-eval-after-load 'reftex
  (add-to-list 'reftex-cite-format-builtin
               '(org "Org-mode citation"
                     ((?m . "[[cite:%l]]")
                      (?t . "[[textcite:%l]]")
                      (?p . "[[parencite:%l]]")
                      (?s . "[[citepos:%l]]")
                      (?a . "[[citeauthor:%l]]")
                      (?y . "[[citeyear:%l]]")
                      (?l . "%l")))))


–Rasmus                      

-- 
Send from my Emacs

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-01-13 21:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-12 23:21 multi-line citation export issue Ken Mankoff
2014-01-12 23:23 ` Ken Mankoff
2014-01-13  0:02 ` Nicolas Goaziou
2014-01-13  2:04   ` Ken Mankoff
2014-01-13 11:07     ` Nicolas Goaziou
2014-01-13 15:23       ` Ken Mankoff
2014-01-13 21:56         ` Rasmus

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).