emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH]Optional argument to LaTeX caption command
@ 2011-03-05 18:34 Thomas S. Dye
  2011-03-05 18:42 ` Bastien
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas S. Dye @ 2011-03-05 18:34 UTC (permalink / raw)
  To: Org-mode mailing list

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

Aloha all,

I proposed a similar patch a few weeks ago, but it seems to have  
slipped through the cracks or was ignored.  I'm proposing it again  
because Org-mode's handling of captions during LaTeX export is  
inconsistent and limiting.

The optional argument to the LaTeX caption command is used to set the  
caption in the List of Figures, List of Tables, and similar lists at  
the beginning of an article or the front matter of a book.  Nowadays,  
the caption under a figure is often quite long, and frequently  
includes the caption proper and the legend.  The optional argument to  
the LaTeX caption command is typically used to pass the caption proper  
to the List of Figures, etc., without the legend.  One goal of the  
typesetter here is to keep each entry in the List of Figures, etc. to  
one line, even when the corresponding caption (plus legend) under the  
figure spans many lines.  Even with captions that fit on a single  
line, it is often the case that the optional argument to the caption  
command is used to pass a version of the caption that doesn't end in a  
period.  Many LaTeX List of Figure, etc. styles run a line of dots  
from the caption to the page number.  If the caption ends in a period,  
then the line of dots is irregular, which looks inelegant.

Now, currently Org-mode correctly parses a caption command of the form:
#+CAPTION: [Caption to list]{Caption to figure.}
The part in square brackets is put in a variable =shortn= and the part  
in curly braces is put in a variable =cap= in the source file org- 
exp.el.

During export to LaTeX, the =shortn= variable is recognized if the  
figure is wrapped by text, but not if it is set as a float in either a  
single or multicolumn layout.  There is no logical reason for this to  
be so.  The optional argument to the caption command is needed in all  
three cases.

The attached patch corrects a bug in org-exp.el and makes the =shortn=  
variable available to captions of floats in single and multicolumn  
layouts in org-latex.el.  In org-exp.el, the =shortn= variable was not  
being initialized with the other variables having to do with captions  
and labels.  This meant that the optional argument used in one figure  
would be used for a subsequent figure that lacked an optional argument.

I believe this qualifies as a minor patch; it is only 3 lines.  I have  
signed the FSF papers needed to contribute to Org-mode, but for many  
months have waited in vain for a response from FSF.  At any rate, I  
don't believe there are any legal barriers to applying the patch.

I've been using the patch for a while now and haven't discovered any  
ill side effects.

All the best,
Tom


[-- Attachment #2: 0001-lisp-org-exp.el-initialize-shortn.patch --]
[-- Type: application/octet-stream, Size: 1459 bytes --]

From c2506b84d7bd85bcafef66056a4e986d5f15acd8 Mon Sep 17 00:00:00 2001
From: Tom Dye <tsd@tsdye.com>
Date: Sat, 5 Mar 2011 07:53:29 -1000
Subject: [PATCH] * lisp/org-exp.el: initialize shortn

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

diff --git a/lisp/org-exp.el b/lisp/org-exp.el
index 5f0ae5d..7d8a479 100644
--- a/lisp/org-exp.el
+++ b/lisp/org-exp.el
@@ -1816,7 +1816,7 @@ table line.  If it is a link, add it to the line containing the link."
 				   'org-label label))
 	(if label (push (cons label label) target-alist))
 	(goto-char end)
-	(setq cap nil attr nil label nil)))))
+	(setq cap nil shortn nil attr nil label nil)))))
   target-alist)
 
 (defun org-export-remove-comment-blocks-and-subtrees ()
diff --git a/lisp/org-latex.el b/lisp/org-latex.el
index c8ea77a..5157fec 100644
--- a/lisp/org-latex.el
+++ b/lisp/org-latex.el
@@ -2198,12 +2198,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: 1 bytes --]



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

* Re: [PATCH]Optional argument to LaTeX caption command
  2011-03-05 18:34 [PATCH]Optional argument to LaTeX caption command Thomas S. Dye
@ 2011-03-05 18:42 ` Bastien
  0 siblings, 0 replies; 2+ messages in thread
From: Bastien @ 2011-03-05 18:42 UTC (permalink / raw)
  To: Thomas S. Dye; +Cc: Org-mode mailing list

Hi Thomas,

just to let you know I didn't ignore your patch -- I will give 
feedback on this soon.  

If others can give feedback as well, all the better.

Thanks a lot!

-- 
 Bastien

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

end of thread, other threads:[~2011-03-05 18:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-05 18:34 [PATCH]Optional argument to LaTeX caption command Thomas S. Dye
2011-03-05 18:42 ` Bastien

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