emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* section subtitle in latex export
@ 2013-05-02  1:49 Masataro Asai
  2013-05-02  3:26 ` Masataro Asai
  0 siblings, 1 reply; 9+ messages in thread
From: Masataro Asai @ 2013-05-02  1:49 UTC (permalink / raw)
  To: emacs-orgmode

Hi all,

I am currently writing a journal thesis in org-mode and exporting it
to a LaTeX file. It worked well until recently I have updated the
org-mode version
to the latest one.

My problem is that the specified class file for the journal fails to
interpret the subtitle
of the sectioning command e.g.) \section[subtitle]{title} . Is it
possible to turn off that subtitle?
I looked into the source code of ox-latex.el but org-latex-section tells
nothing about it.
I have also checked org-latex-classes but curiously
the sectioning format is just "\\section{%s}" and so on. no subtitle.

org-mode version is the latest devel in the git repository, after 8.0.2,
git commit hash is 00badf1
 and the emacs version is 23.3.1

-- 
Masataro Asai

Department of General Systems Studies
Graduate School of Arts and Sciences, The University of Tokyo

Tel: (81)-44-856-9009
Twitter/github id: guicho271828

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

* Re: section subtitle in latex export
  2013-05-02  1:49 section subtitle in latex export Masataro Asai
@ 2013-05-02  3:26 ` Masataro Asai
  2013-05-02  4:46   ` Aaron Ecay
  2013-05-02  8:26   ` Nicolas Goaziou
  0 siblings, 2 replies; 9+ messages in thread
From: Masataro Asai @ 2013-05-02  3:26 UTC (permalink / raw)
  To: emacs-orgmode

Reply to myself:

I edebugged the ox-latex and studied what's happening.
Who wrote this code? you shouldn't do things like this...
The code is overwriting the defcustom'ed sectioning format, no one knows.

the best answer for this problem would be changing the structure of
org-latex-classes but I dont want to do that right now.
so I just gave an option for alternative-heading.



diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 2a315ef..95e96f0 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -303,6 +303,12 @@ a format string in which the section title will be
added."
                    (string :tag "Closing (unnumbered)"))
              (function :tag "Hook computing sectioning"))))))
 
+(defcustom org-latex-alternative-section-title-enabled t
+  "Output alternative section title such as
+\\section[short title]{Long long very long title}."
+  :group 'org-export-latex
+  :type 'boolean)
+
 (defcustom org-latex-inputenc-alist nil
   "Alist of inputenc coding system names, and what should really be used.
 For example, adding an entry
@@ -1442,7 +1448,7 @@ holding contextual information."
             (org-export-data
              (org-export-get-alt-title headline info) info)
             (and (eq (plist-get info :with-tags) t) tags))))
-      (if (and numberedp opt-title
+      (if (and numberedp opt-title
org-latex-alternative-section-title-enabled
            (string-match "\\`\\\\\\(.*?[^*]\\){" section-fmt))
           (format (replace-match "\\1[%s]" nil nil section-fmt 1)
               ;; Replace square brackets with parenthesis



On 2013年05月02日 10:49, Masataro Asai wrote:
> Hi all,
>
> I am currently writing a journal thesis in org-mode and exporting it
> to a LaTeX file. It worked well until recently I have updated the
> org-mode version
> to the latest one.
>
> My problem is that the specified class file for the journal fails to
> interpret the subtitle
> of the sectioning command e.g.) \section[subtitle]{title} . Is it
> possible to turn off that subtitle?
> I looked into the source code of ox-latex.el but org-latex-section tells
> nothing about it.
> I have also checked org-latex-classes but curiously
> the sectioning format is just "\\section{%s}" and so on. no subtitle.
>
> org-mode version is the latest devel in the git repository, after 8.0.2,
> git commit hash is 00badf1
>  and the emacs version is 23.3.1
>


-- 
Masataro Asai

Department of General Systems Studies
Graduate School of Arts and Sciences, The University of Tokyo

Tel: (81)-44-856-9009
Twitter/github id: guicho271828

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

* Re: section subtitle in latex export
  2013-05-02  3:26 ` Masataro Asai
@ 2013-05-02  4:46   ` Aaron Ecay
  2013-05-02  8:06     ` Rasmus
  2013-05-02  8:29     ` Nicolas Goaziou
  2013-05-02  8:26   ` Nicolas Goaziou
  1 sibling, 2 replies; 9+ messages in thread
From: Aaron Ecay @ 2013-05-02  4:46 UTC (permalink / raw)
  To: Masataro Asai; +Cc: emacs-orgmode

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

Hi Masataro,

I agree that it is weird for org to insert the alternate header when it
is identical to the regular header.  I think it is unnecessary
complication to introduce a new option to control this, though – it can
be automatic.  Try the patch attached to this email.  It simply avoids
inserting the alternate heading whenever it is identical to the standard
one.

(Nicolas, I’m waiting to see if you have any thoughts before pushing
this patch to the org repo.)

2013ko maiatzak 1an, Masataro Asai-ek idatzi zuen:

[...]


> @@ -1442,7 +1448,7 @@ holding contextual information."
>              (org-export-data
>               (org-export-get-alt-title headline info) info)
>              (and (eq (plist-get info :with-tags) t) tags))))
> -      (if (and numberedp opt-title
> +      (if (and numberedp opt-title
> org-latex-alternative-section-title-enabled

It looks like your patch got line-wrapped here.  Better to send patches
as attachments to avoid this.


[-- Attachment #2: 0001-ox-latex.el-org-latex-headline-Don-t-insert-alternat.patch --]
[-- Type: text/x-patch, Size: 1643 bytes --]

From f84800fb82d432112a06918bbe389a00968773bc Mon Sep 17 00:00:00 2001
From: Aaron Ecay <aaronecay@gmail.com>
Date: Thu, 2 May 2013 00:36:44 -0400
Subject: [PATCH] =?UTF-8?q?ox-latex.el=20(org-latex-headline):=20Don?=
 =?UTF-8?q?=E2=80=99t=20insert=20alternate=20title=20if=20identical=20to?=
 =?UTF-8?q?=20regular=20one?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* lisp/ox-latex.el (org-latex-headline): Don’t insert alternate title if
  identical to regular one.
---
 lisp/ox-latex.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 2a315ef..66eefa1 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -1435,7 +1435,8 @@ holding contextual information."
 	       (format "\n\\\\end{%s}" (if numberedp 'enumerate 'itemize))
 	       low-level-body)))
 	;; This is a standard headline.  Export it as a section.  Add
-	;; an alternative heading when possible.
+	;; an alternative heading when possible, and when this is not
+	;; identical to the usual heading.
 	(let ((opt-title
 	       (funcall org-latex-format-headline-function
 			todo todo-type priority
@@ -1443,6 +1444,7 @@ holding contextual information."
 			 (org-export-get-alt-title headline info) info)
 			(and (eq (plist-get info :with-tags) t) tags))))
 	  (if (and numberedp opt-title
+		   (not (equal opt-title full-text))
 		   (string-match "\\`\\\\\\(.*?[^*]\\){" section-fmt))
 	      (format (replace-match "\\1[%s]" nil nil section-fmt 1)
 		      ;; Replace square brackets with parenthesis
-- 
1.8.2.2


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


-- 
Aaron Ecay

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

* Re: section subtitle in latex export
  2013-05-02  4:46   ` Aaron Ecay
@ 2013-05-02  8:06     ` Rasmus
  2013-05-02  8:29     ` Nicolas Goaziou
  1 sibling, 0 replies; 9+ messages in thread
From: Rasmus @ 2013-05-02  8:06 UTC (permalink / raw)
  To: emacs-orgmode

Aaron Ecay <aaronecay@gmail.com> writes:

> Try the patch attached to this email.  It simply avoids
> inserting the alternate heading whenever it is identical to the
> standard
> one.

Sounds good to me.  Aesthetically, the insertion of \section[·]{·} has
bothered me. . .

–Rasmus

-- 
⠠⠵

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

* Re: section subtitle in latex export
  2013-05-02  3:26 ` Masataro Asai
  2013-05-02  4:46   ` Aaron Ecay
@ 2013-05-02  8:26   ` Nicolas Goaziou
  2013-05-02 11:05     ` Masataro Asai
  1 sibling, 1 reply; 9+ messages in thread
From: Nicolas Goaziou @ 2013-05-02  8:26 UTC (permalink / raw)
  To: Masataro Asai; +Cc: emacs-orgmode

Hello,

Masataro Asai <guicho2.71828@gmail.com> writes:

> Reply to myself:
>
> I edebugged the ox-latex and studied what's happening.
> Who wrote this code?

Obviously, not you.

> you shouldn't do things like this... The code is overwriting the
> defcustom'ed sectioning format, no one knows.

Doing what? Would you mind giving an example of that overwriting thing?

> the best answer for this problem would be changing the structure of
> org-latex-classes

Really?

> but I dont want to do that right now. so I just gave an option for
> alternative-heading.

Why would you want to remove every optional title? That would break
things like tags:not-in-toc and ALT_TITLE properties.


Regards,

-- 
Nicolas Goaziou

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

* Re: section subtitle in latex export
  2013-05-02  4:46   ` Aaron Ecay
  2013-05-02  8:06     ` Rasmus
@ 2013-05-02  8:29     ` Nicolas Goaziou
  2013-05-03  8:18       ` Aaron Ecay
  1 sibling, 1 reply; 9+ messages in thread
From: Nicolas Goaziou @ 2013-05-02  8:29 UTC (permalink / raw)
  To: Masataro Asai; +Cc: emacs-orgmode

Hello,

Aaron Ecay <aaronecay@gmail.com> writes:

> (Nicolas, I’m waiting to see if you have any thoughts before pushing
> this patch to the org repo.)

That's good. Please push it into maint branch.


Regards,

-- 
Nicolas Goaziou

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

* Re: section subtitle in latex export
  2013-05-02  8:26   ` Nicolas Goaziou
@ 2013-05-02 11:05     ` Masataro Asai
  2013-05-02 14:00       ` Nicolas Goaziou
  0 siblings, 1 reply; 9+ messages in thread
From: Masataro Asai @ 2013-05-02 11:05 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode

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

Nicolas,

sorry for my offending remarks in the second message. i was just a little
nervous about that unexpected behavior for me.

org latex classes can be considererd as a template. template is somewhat
similer to lambda. you wouldnt want any function to be modified by another
function which recieved it as its argument.

so if something may be inserted in the template without notice, instead it
should be better if it has more arguments. say additional %s. if only there
is two of them in the template you can add alternative title, this may be
an option. amother option is, giving altered version explicitly. which may
make it accept four templates per sectioning,
numbered,unnumbered,alternative numbered, altered unnumbered. some people,
at least not me, may want this feature.

if user can modify that behavior it would be definitrly better. well, that
may inflate the list of vars in customs, but thats another ploblem.

the reason of cancelling the alt title, the situation im in is written in
the
first message. one journal template throws an error because it does not
recognize altered titles.
maybe i can write a script which regex all alt titles out, but i wanted to
contribute to the development of org.

sorry for many typos, im currentry wrting on android.

masataro
 2013/05/02 17:26 "Nicolas Goaziou" <n.goaziou@gmail.com>:

> Hello,
>
> Masataro Asai <guicho2.71828@gmail.com> writes:
>
> > Reply to myself:
> >
> > I edebugged the ox-latex and studied what's happening.
> > Who wrote this code?
>
> Obviously, not you.
>
> > you shouldn't do things like this... The code is overwriting the
> > defcustom'ed sectioning format, no one knows.
>
> Doing what? Would you mind giving an example of that overwriting thing?
>
> > the best answer for this problem would be changing the structure of
> > org-latex-classes
>
> Really?
>
> > but I dont want to do that right now. so I just gave an option for
> > alternative-heading.
>
> Why would you want to remove every optional title? That would break
> things like tags:not-in-toc and ALT_TITLE properties.
>
>
> Regards,
>
> --
> Nicolas Goaziou
>

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

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

* Re: section subtitle in latex export
  2013-05-02 11:05     ` Masataro Asai
@ 2013-05-02 14:00       ` Nicolas Goaziou
  0 siblings, 0 replies; 9+ messages in thread
From: Nicolas Goaziou @ 2013-05-02 14:00 UTC (permalink / raw)
  To: Masataro Asai; +Cc: emacs-orgmode

Masataro Asai <guicho2.71828@gmail.com> writes:

> org latex classes can be considererd as a template. template is somewhat
> similer to lambda. you wouldnt want any function to be modified by another
> function which recieved it as its argument.

Of course, `org-latex-classes' is a template. But it doesn't apply on
table of contents. However, Org needs some ways to control them.
Therefore it needs to handle optional arguments in \section macros and
alike.

> so if something may be inserted in the template without notice, instead it
> should be better if it has more arguments. say additional %s. if only there
> is two of them in the template you can add alternative title,

There are already other ways to control the alternative title. See
below.

> this may be an option. amother option is, giving altered version
> explicitly. 

There is the ALT_TITLE property, which allows to set an alternate title
for a given headline.

[...]

> the reason of cancelling the alt title, the situation im in is written in
> the
> first message. one journal template throws an error because it does not
> recognize altered titles.
> maybe i can write a script which regex all alt titles out, 

You can indeed write a filter for headlines which would remove every
optional title (see `org-export-filter-headline-functions'). Though,
Aaron Ecay's patch should solve most of the cases: no alternate title
will be added if you don't use ALT_TITLE or tags:not-in-toc option.

> but i wanted to contribute to the development of org.

You're welcome. But for the problem at hand, your patch isn't, IMO, an
acceptable solution.


Regards,

-- 
Nicolas Goaziou

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

* Re: section subtitle in latex export
  2013-05-02  8:29     ` Nicolas Goaziou
@ 2013-05-03  8:18       ` Aaron Ecay
  0 siblings, 0 replies; 9+ messages in thread
From: Aaron Ecay @ 2013-05-03  8:18 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Masataro Asai, emacs-orgmode

Hello Nicolas,

2013ko maiatzak 2an, Nicolas Goaziou-ek idatzi zuen:

> That's good. Please push it into maint branch.

Done.  I then merged the patch into the master branch.

Thanks,

-- 
Aaron Ecay

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

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

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-02  1:49 section subtitle in latex export Masataro Asai
2013-05-02  3:26 ` Masataro Asai
2013-05-02  4:46   ` Aaron Ecay
2013-05-02  8:06     ` Rasmus
2013-05-02  8:29     ` Nicolas Goaziou
2013-05-03  8:18       ` Aaron Ecay
2013-05-02  8:26   ` Nicolas Goaziou
2013-05-02 11:05     ` Masataro Asai
2013-05-02 14:00       ` Nicolas Goaziou

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