emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Thomas S. Dye" <tsd@tsdye.com>
To: Org-mode mailing list <emacs-orgmode@gnu.org>
Subject: [PATCH]Optional argument to LaTeX caption command
Date: Sat, 5 Mar 2011 08:34:34 -1000	[thread overview]
Message-ID: <99DCAE9B-40AA-4E12-AFA9-5A4FC536D85E@tsdye.com> (raw)

[-- 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 --]



             reply	other threads:[~2011-03-05 18:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-05 18:34 Thomas S. Dye [this message]
2011-03-05 18:42 ` [PATCH]Optional argument to LaTeX caption command Bastien

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=99DCAE9B-40AA-4E12-AFA9-5A4FC536D85E@tsdye.com \
    --to=tsd@tsdye.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).