From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Thomas S. Dye" Subject: [PATCH]Optional argument to LaTeX caption command Date: Sat, 5 Mar 2011 08:34:34 -1000 Message-ID: <99DCAE9B-40AA-4E12-AFA9-5A4FC536D85E@tsdye.com> Mime-Version: 1.0 (Apple Message framework v936) Content-Type: multipart/mixed; boundary=Apple-Mail-8-1067810919 Return-path: Received: from [140.186.70.92] (port=41474 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PvwJT-00007A-3h for emacs-orgmode@gnu.org; Sat, 05 Mar 2011 13:34:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PvwJR-0004c0-Oj for emacs-orgmode@gnu.org; Sat, 05 Mar 2011 13:34:46 -0500 Received: from cpoproxy1-pub.bluehost.com ([69.89.21.11]:34138) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1PvwJR-0004bO-Co for emacs-orgmode@gnu.org; Sat, 05 Mar 2011 13:34:45 -0500 Received: from cpe-66-91-68-127.hawaii.res.rr.com ([66.91.68.127] helo=[192.168.1.2]) by box472.bluehost.com with esmtpa (Exim 4.69) (envelope-from ) id 1PvwJL-00027w-7M for emacs-orgmode@gnu.org; Sat, 05 Mar 2011 11:34:41 -0700 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Org-mode mailing list --Apple-Mail-8-1067810919 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit 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 --Apple-Mail-8-1067810919 Content-Disposition: attachment; filename=0001-lisp-org-exp.el-initialize-shortn.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-lisp-org-exp.el-initialize-shortn.patch" Content-Transfer-Encoding: quoted-printable =46rom=20c2506b84d7bd85bcafef66056a4e986d5f15acd8=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20Tom=20Dye=20=0ADate:=20Sat,=205=20= Mar=202011=2007:53:29=20-1000=0ASubject:=20[PATCH]=20*=20= lisp/org-exp.el:=20initialize=20shortn=0A=0A---=0A=20lisp/org-exp.el=20=20= =20|=20=20=20=202=20+-=0A=20lisp/org-latex.el=20|=20=20=20=204=20++--=0A=20= 2=20files=20changed,=203=20insertions(+),=203=20deletions(-)=0A=0Adiff=20= --git=20a/lisp/org-exp.el=20b/lisp/org-exp.el=0Aindex=205f0ae5d..7d8a479=20= 100644=0A---=20a/lisp/org-exp.el=0A+++=20b/lisp/org-exp.el=0A@@=20= -1816,7=20+1816,7=20@@=20table=20line.=20=20If=20it=20is=20a=20link,=20= add=20it=20to=20the=20line=20containing=20the=20link."=0A=20=09=09=09=09=20= =20=20'org-label=20label))=0A=20=09(if=20label=20(push=20(cons=20label=20= label)=20target-alist))=0A=20=09(goto-char=20end)=0A-=09(setq=20cap=20= nil=20attr=20nil=20label=20nil)))))=0A+=09(setq=20cap=20nil=20shortn=20= nil=20attr=20nil=20label=20nil)))))=0A=20=20=20target-alist)=0A=20=0A=20= (defun=20org-export-remove-comment-blocks-and-subtrees=20()=0Adiff=20= --git=20a/lisp/org-latex.el=20b/lisp/org-latex.el=0Aindex=20= c8ea77a..5157fec=20100644=0A---=20a/lisp/org-latex.el=0A+++=20= b/lisp/org-latex.el=0A@@=20-2198,12=20+2198,12=20@@=20The=20conversion=20= is=20made=20depending=20of=20STRING-BEFORE=20and=20STRING-AFTER."=0A=20=09= =20=20=20(multicolumnp=20"\\begin{figure*}%placement=0A=20\\centering=0A=20= \\includegraphics[%attr]{%path}=0A-\\caption{%labelcmd%caption}=0A= +\\caption%shortn{%labelcmd%caption}=0A=20\\end{figure*}")=0A=20=09=20=20= =20(floatp=20"\\begin{figure}%placement=0A=20\\centering=0A=20= \\includegraphics[%attr]{%path}=0A-\\caption{%labelcmd%caption}=0A= +\\caption%shortn{%labelcmd%caption}=0A=20\\end{figure}")=0A=20=09=20=20=20= (t=20"\\includegraphics[%attr]{%path}")))=0A=20=0A--=20=0A1.7.1=0A=0A= --Apple-Mail-8-1067810919 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit --Apple-Mail-8-1067810919--