emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-caption-shortn
@ 2011-02-17  4:23 Thomas S. Dye
  2011-02-17 16:42 ` org-caption-shortn Thomas S. Dye
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas S. Dye @ 2011-02-17  4:23 UTC (permalink / raw)
  To: Org Mode

Aloha all,

I stumbled across code in org-exp.el and org-latex.el that appears to  
my untrained eye to be designed to parse the optional argument to the  
LaTeX \caption command.

This bit in org-exp.el appears to parse out the optional command:

	  (when (string-match "\\[\\(.*\\)\\]{\\(.*\\)}" cap)
	    (setq shortn (match-string 1 cap)
		  cap (match-string 2 cap)))

Then it is easy to find code in org-latex.el by searching for 'shortn'  
that looks like it writes out the full command to the .tex file.

I can't find documentation for this, though.  It looks (to my  
untrained eye) like it should be possible to write something like:

#+CAPTION: [short]{long}

and get

\caption[short]{long} in the .tex file.

But this doesn't work for me.  The [short] part doesn't make it into  
the .tex file.

I don't know enough lisp to figure this out in a reasonable amount of  
time, so have come to the list to ask if anyone familiar with the code  
knows whether this should work or not, and if it should work, how to  
markup the org file.

All the best,
Tom

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

* Re: org-caption-shortn
  2011-02-17  4:23 org-caption-shortn Thomas S. Dye
@ 2011-02-17 16:42 ` Thomas S. Dye
  2011-02-18  1:32   ` org-caption-shortn Thomas S. Dye
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas S. Dye @ 2011-02-17 16:42 UTC (permalink / raw)
  To: Thomas S. Dye; +Cc: Org Mode

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

Aloha all,

First, apologies for my rudimentary programming skills.  The attached  
patch partially answers the query I posed earlier: the shortn argument  
was ignored except for the wrapfigure environment.  The attached patch  
makes other environments aware of shortn.

This works, sort of.  If all the #+CAPTION: lines are of this form # 
+CAPTION: [shortn]{caption}, then all goes well.  If one caption of  
this form is followed by others of this form #+CAPTION: caption, then  
the list of figures contains repeated entries of shortn.  I suspect  
there is code somewhere that clears a variable.  I can try to look for  
it, but I have to tell you that the lisp code to org-mode looks like  
magic spells to my untrained eye.

All the best,
Tom


[-- Attachment #2: 0001-lisp-org-latex.el-Enable-optional-argument-to-LaTeX-.patch --]
[-- Type: application/octet-stream, Size: 973 bytes --]

From 860b3e5a1b1189e800c3b295dea0bc3ff27c9bf8 Mon Sep 17 00:00:00 2001
From: Tom Dye <tsd@tsdye.com>
Date: Thu, 17 Feb 2011 06:29:03 -1000
Subject: [PATCH] * lisp/org-latex.el: Enable optional argument to LaTeX caption command

---
 lisp/org-latex.el |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/org-latex.el b/lisp/org-latex.el
index c558043..efc6f95 100644
--- a/lisp/org-latex.el
+++ b/lisp/org-latex.el
@@ -2196,12 +2196,12 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
 	   (multicolumnp "\\begin{figure*}%placement
 \\centering
 \\includegraphics[%attr]{%path}
-\\caption{%labelcmd%caption}
+\\caption%shortn{%labelcmd%caption}
 \\end{figure*}")
 	   (floatp "\\begin{figure}%placement
 \\centering
 \\includegraphics[%attr]{%path}
-\\caption{%labelcmd%caption}
+\\caption%shortn{%labelcmd%caption}
 \\end{figure}")
 	   (t "\\includegraphics[%attr]{%path}")))
 
-- 
1.7.1


[-- Attachment #3: Type: text/plain, Size: 1393 bytes --]




On Feb 16, 2011, at 6:23 PM, Thomas S. Dye wrote:

> Aloha all,
>
> I stumbled across code in org-exp.el and org-latex.el that appears  
> to my untrained eye to be designed to parse the optional argument to  
> the LaTeX \caption command.
>
> This bit in org-exp.el appears to parse out the optional command:
>
> 	  (when (string-match "\\[\\(.*\\)\\]{\\(.*\\)}" cap)
> 	    (setq shortn (match-string 1 cap)
> 		  cap (match-string 2 cap)))
>
> Then it is easy to find code in org-latex.el by searching for  
> 'shortn' that looks like it writes out the full command to the .tex  
> file.
>
> I can't find documentation for this, though.  It looks (to my  
> untrained eye) like it should be possible to write something like:
>
> #+CAPTION: [short]{long}
>
> and get
>
> \caption[short]{long} in the .tex file.
>
> But this doesn't work for me.  The [short] part doesn't make it into  
> the .tex file.
>
> I don't know enough lisp to figure this out in a reasonable amount  
> of time, so have come to the list to ask if anyone familiar with the  
> code knows whether this should work or not, and if it should work,  
> how to markup the org file.
>
> All the best,
> Tom
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode


[-- Attachment #4: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: org-caption-shortn
  2011-02-17 16:42 ` org-caption-shortn Thomas S. Dye
@ 2011-02-18  1:32   ` Thomas S. Dye
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas S. Dye @ 2011-02-18  1:32 UTC (permalink / raw)
  To: Thomas S. Dye; +Cc: Org Mode

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

Aloha all,

Replying to myself again.  I have only the faintest idea what I'm  
doing, but this patch appears to take care of the problem described  
earlier, where the optional argument to the LaTeX caption command was  
recycled if not replaced by a new optional argument.

The captions exported to LaTeX now can include or not the optional  
argument.  My org-mode document now exports both captions and entries  
in the list of figures correctly.

All the best,
Tom


[-- Attachment #2: 0001-lisp-org-exp.el-Set-shortn-nil-before-parsing-a-capt.patch --]
[-- Type: application/octet-stream, Size: 798 bytes --]

From ccf83187afe11175ed60911e657945d29a7b989c Mon Sep 17 00:00:00 2001
From: Tom Dye <tsd@tsdye.com>
Date: Thu, 17 Feb 2011 15:23:29 -1000
Subject: [PATCH] * lisp/org-exp.el: Set shortn nil before parsing a caption

---
 lisp/org-exp.el |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/lisp/org-exp.el b/lisp/org-exp.el
index 0e525e1..9f0e378 100644
--- a/lisp/org-exp.el
+++ b/lisp/org-exp.el
@@ -1721,6 +1721,7 @@ table line.  If it is a link, add it to the line containing the link."
        ;; there is a caption
        ((match-end 1)
 	(progn
+	  (setq shortn nil)
 	  (setq cap (concat cap (if cap " " "") (org-trim (match-string 1))))
 	  (when (string-match "\\[\\(.*\\)\\]{\\(.*\\)}" cap)
 	    (setq shortn (match-string 1 cap)
-- 
1.7.1


[-- Attachment #3: Type: text/plain, Size: 2347 bytes --]




On Feb 17, 2011, at 6:42 AM, Thomas S. Dye wrote:

> Aloha all,
>
> First, apologies for my rudimentary programming skills.  The  
> attached patch partially answers the query I posed earlier: the  
> shortn argument was ignored except for the wrapfigure environment.   
> The attached patch makes other environments aware of shortn.
>
> This works, sort of.  If all the #+CAPTION: lines are of this form # 
> +CAPTION: [shortn]{caption}, then all goes well.  If one caption of  
> this form is followed by others of this form #+CAPTION: caption,  
> then the list of figures contains repeated entries of shortn.  I  
> suspect there is code somewhere that clears a variable.  I can try  
> to look for it, but I have to tell you that the lisp code to org- 
> mode looks like magic spells to my untrained eye.
>
> All the best,
> Tom
>
> <0001-lisp-org-latex.el-Enable-optional-argument-to-LaTeX-.patch>
>
>
> On Feb 16, 2011, at 6:23 PM, Thomas S. Dye wrote:
>
>> Aloha all,
>>
>> I stumbled across code in org-exp.el and org-latex.el that appears  
>> to my untrained eye to be designed to parse the optional argument  
>> to the LaTeX \caption command.
>>
>> This bit in org-exp.el appears to parse out the optional command:
>>
>> 	  (when (string-match "\\[\\(.*\\)\\]{\\(.*\\)}" cap)
>> 	    (setq shortn (match-string 1 cap)
>> 		  cap (match-string 2 cap)))
>>
>> Then it is easy to find code in org-latex.el by searching for  
>> 'shortn' that looks like it writes out the full command to the .tex  
>> file.
>>
>> I can't find documentation for this, though.  It looks (to my  
>> untrained eye) like it should be possible to write something like:
>>
>> #+CAPTION: [short]{long}
>>
>> and get
>>
>> \caption[short]{long} in the .tex file.
>>
>> But this doesn't work for me.  The [short] part doesn't make it  
>> into the .tex file.
>>
>> I don't know enough lisp to figure this out in a reasonable amount  
>> of time, so have come to the list to ask if anyone familiar with  
>> the code knows whether this should work or not, and if it should  
>> work, how to markup the org file.
>>
>> All the best,
>> Tom
>>
>> _______________________________________________
>> Emacs-orgmode mailing list
>> Please use `Reply All' to send replies to the list.
>> Emacs-orgmode@gnu.org
>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>


[-- Attachment #4: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

end of thread, other threads:[~2011-02-18  1:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-17  4:23 org-caption-shortn Thomas S. Dye
2011-02-17 16:42 ` org-caption-shortn Thomas S. Dye
2011-02-18  1:32   ` org-caption-shortn Thomas S. Dye

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).