Re: [O] [PATCH] (update) Add :caption attribute to #+ATTR_LATEX property

2013-07-02 Thread Nicolas Goaziou
Hello,

feng shu tuma...@gmail.com writes:

 Thanks all the people! This is V5!

Applied. Thank you!


Regards,

-- 
Nicolas Goaziou



Re: [O] [PATCH] (update) Add :caption attribute to #+ATTR_LATEX property

2013-07-01 Thread Bastien
Hi Feng,

feng shu tuma...@gmail.com writes:

 Thanks for your help. This is V4 patch.

Thanks for the updated patch -- there are more knowledgeable people
for this area of the code, I'll let them apply/rework it or not.

Best,

-- 
 Bastien



Re: [O] [PATCH] (update) Add :caption attribute to #+ATTR_LATEX property

2013-07-01 Thread Nicolas Goaziou
Hello,

feng shu tuma...@gmail.com writes:

 Thanks for your help. This is V4 patch.

Thanks for the update. More comments below.

 +@item :caption
 +By default, you should use @code{#+caption} keyword to add a table caption.
 +If you want to add caption with complex or special latex commands, you can 
 use
 +@code{:caption} attribute. It will precedence over @code{#+caption} keyword.
 +It should be set with raw latex command and nothing in it will be
 +interpreted by Org.

You need to use upper cases for keywords: @code{#+CAPTION}. Also,
sentences are expected to end with two spaces and latex should be typed
@LaTeX{}. Here is a suggestion (note that I'm not a wording expert):

  @code{#+CAPTION} keyword is the simplest way to set a caption for
  a table (@pxref{Images and tables}).  If you need more advanced commands
  for that task, you can use @code{:caption} attribute instead. Its value
  should be raw @LaTeX{} code.  It has precedence over @code{#+CAPTION}.

 +When export the below example to latex, the table caption will be set
 +with latex command @code{\bicaption@{Heading A@}@{Heading B@}} instead of
 +@code{#+CAPTION} keywords.

  In the example below, @LaTeX{} command @code{\bicaption@{Heading
  A@}@{Heading B@}} will set the caption. (I think you can drop the rest
  of the sentence).

 -@code{:width} and @code{:height} attributes.  It is also possible to add any
 -other option with the @code{:options} attribute, as shown in the following
 -example:
 +@code{:width} and @code{:height} attributes. If you want to set image
 +caption with special latex command, you can use @code{:caption} attribute,
 +for example:

Besides the missing two spaces at the end of the sentence, I suggest the
following:

  You can specify specify image width or height with, respectively,
  @code{:width} and @code{:height} attributes.  It is also possible to add any
  other option with the @code{:options} attribute, as shown in the following
  example:

  EXAMPLE

  If you need a specific command for the caption, use @code{:caption}
  attribute.  It will override standard @code{#+CAPTION} value, if any.

  EXAMPLE?

Also, you don't seem to document the feature for special blocks.

 -  (short (org-export-get-caption element t)))
 -(cond
 - ((and (not main) (equal label-str )) )
 - ((not main) (concat label-str \n))
 - ;; Option caption format with short name.
 - (short (format \\caption[%s]{%s%s}\n
 - (org-export-data short info)
 - label-str
 - (org-export-data main info)))
 - ;; Standard caption format.
 - (t (format \\caption{%s%s}\n label-str (org-export-data main 
 info))
 +  (short (org-export-get-caption element t))
 +  (caption-from-attr-latex (org-export-read-attribute :attr_latex 
 element :caption)))
 +(cond ((org-string-nw-p caption-from-attr-latex)
 +(concat caption-from-attr-latex \n))
 +   ((and (not main) (equal label-str )))

Why do you drop the return value (empty string) here?


Regards,

-- 
Nicolas Goaziou



Re: [O] [PATCH] (update) Add :caption attribute to #+ATTR_LATEX property

2013-07-01 Thread feng shu
Thanks all the people! This is V5!


On Tue, Jul 2, 2013 at 5:38 AM, Nicolas Goaziou n.goaz...@gmail.com wrote:

 Hello,

 feng shu tuma...@gmail.com writes:

  Thanks for your help. This is V4 patch.

 Thanks for the update. More comments below.

  +@item :caption
  +By default, you should use @code{#+caption} keyword to add a table
 caption.
  +If you want to add caption with complex or special latex commands, you
 can use
  +@code{:caption} attribute. It will precedence over @code{#+caption}
 keyword.
  +It should be set with raw latex command and nothing in it will be
  +interpreted by Org.

 You need to use upper cases for keywords: @code{#+CAPTION}. Also,
 sentences are expected to end with two spaces and latex should be typed
 @LaTeX{}. Here is a suggestion (note that I'm not a wording expert):




   @code{#+CAPTION} keyword is the simplest way to set a caption for
   a table (@pxref{Images and tables}).  If you need more advanced commands
   for that task, you can use @code{:caption} attribute instead. Its value
   should be raw @LaTeX{} code.  It has precedence over @code{#+CAPTION}.

 I think it's much good than mine. For me, writing documentation is a painful
thing.


  +When export the below example to latex, the table caption will be set
  +with latex command @code{\bicaption@{Heading A@}@{Heading B@}} instead
 of
  +@code{#+CAPTION} keywords.

   In the example below, @LaTeX{} command @code{\bicaption@{Heading
   A@}@{Heading B@}} will set the caption. (I think you can drop the rest
   of the sentence).

  -@code{:width} and @code{:height} attributes.  It is also possible to
 add any
  -other option with the @code{:options} attribute, as shown in the
 following
  -example:
  +@code{:width} and @code{:height} attributes. If you want to set image
  +caption with special latex command, you can use @code{:caption}
 attribute,
  +for example:

 Besides the missing two spaces at the end of the sentence, I suggest the
 following:

   You can specify specify image width or height with, respectively,
   @code{:width} and @code{:height} attributes.  It is also possible to add
 any
   other option with the @code{:options} attribute, as shown in the
 following
   example:

   EXAMPLE

   If you need a specific command for the caption, use @code{:caption}
   attribute.  It will override standard @code{#+CAPTION} value, if any.

   EXAMPLE?

 Also, you don't seem to document the feature for special blocks.

  -  (short (org-export-get-caption element t)))
  -(cond
  - ((and (not main) (equal label-str )) )
  - ((not main) (concat label-str \n))
  - ;; Option caption format with short name.
  - (short (format \\caption[%s]{%s%s}\n
  - (org-export-data short info)
  - label-str
  - (org-export-data main info)))
  - ;; Standard caption format.
  - (t (format \\caption{%s%s}\n label-str (org-export-data main
 info))
  +  (short (org-export-get-caption element t))
  +  (caption-from-attr-latex (org-export-read-attribute :attr_latex
 element :caption)))
  +(cond ((org-string-nw-p caption-from-attr-latex)
  +(concat caption-from-attr-latex \n))
  +   ((and (not main) (equal label-str )))

 Why do you drop the return value (empty string) here?

 It's my mistake!


 Regards,

 --
 Nicolas Goaziou



0001-Add-caption-attribute-to-ATTR_LATEX-property.patch
Description: Binary data


Re: [O] [PATCH] (update) Add :caption attribute to #+ATTR_LATEX property

2013-06-30 Thread Nicolas Goaziou
Hello,

feng shu tuma...@gmail.com writes:

 This is the updated patch of  Add :caption attribute to #+ATTR_LATEX
 property
 If possible, please include it to master

Thanks for your patch.

I agree that #+CAPTION isn't ready for complex caption commands (nor
that it should), so a :caption attribute may be useful. Though, it must
be documented in the manual (see 12.7.4 LaTeX specific attributes). In
particular, documentation should insist on the fact that:

  1. :caption attribute has precedence over #+caption keyword
  2. :caption attribute is only meaningful special caption commands,
 i.e., this isn't the standard way to set a caption in Org.
  3. This is a raw command, nothing in it will be interpreted by Org.

Here are some comments about the code:
 +  (caption-from-attr-latex (plist-get (org-export-read-attribute 
 :attr_latex element) :caption)))

You can use the following slightly shorter sexp:

  (caption-from-attr-latex (org-export-read-attribute :attr_latex element 
:caption))

 +(if (and caption-from-attr-latex (not (equal caption-from-attr-latex 
 )))
 + (concat caption-from-attr-latex \n)
 +  (cond
 +   ((and (not main) (equal label-str )))
 +   ((not main) (concat label-str \n))
 +   ;; Option caption format with short name.
 +   (short (format \\caption[%s]{%s%s}\n
 +   (org-export-data short info)
 +   label-str
 +   (org-export-data main info)))
 +   ;; Standard caption format.
 +   (t (format \\caption{%s%s}\n label-str (org-export-data main 
 info)))

Here you can include the then part in the `cond', and use
`org-string-nw-p':

  (cond ((org-string-nw-p caption-from-attr-latex)
 (concat caption-from-attr-latex \n))
((and (not main) (equal label-str )) )
...)

  (defun org-latex-guess-inputenc (header)
Set the coding system in inputenc to what the buffer is.
 @@ -1655,7 +1658,7 @@ used as a communication channel.
 (cond ((and (not float) (plist-member attr :float)) nil)
   ((string= float wrap) 'wrap)
   ((string= float multicolumn) 'multicolumn)
 - ((or float (org-element-property :caption parent))
 + ((or float (org-element-property :caption parent) 
 (plist-get attr :caption))

Be careful here: (plist-get attr :caption) will be non-nil if :caption
is set to the empty string. It may be bulkier to use:

  (org-string-nw-p (plist-get attr :caption))

'figure
(placement
 (let ((place (plist-get attr :placement)))
 @@ -2333,7 +2336,7 @@ This function assumes TABLE has `org' as its `:type' 
 property and
((and (not float) (plist-member attr :float)) nil)
((string= float sidewaystable) sidewaystable)
((string= float multicolumn) table*)
 -  ((or float (org-element-property :caption table))
 +  ((or float (org-element-property :caption table) 
 (plist-get attr :caption))

Ditto.


Regards,

-- 
Nicolas Goaziou



Re: [O] [PATCH] (update) Add :caption attribute to #+ATTR_LATEX property

2013-06-30 Thread feng shu
Hi

version 3 patch, add document about :caption attribute.


On Sun, Jun 30, 2013 at 7:46 PM, Nicolas Goaziou n.goaz...@gmail.comwrote:

 Hello,

 feng shu tuma...@gmail.com writes:

  This is the updated patch of  Add :caption attribute to #+ATTR_LATEX
  property
  If possible, please include it to master

 Thanks for your patch.

 I agree that #+CAPTION isn't ready for complex caption commands (nor
 that it should), so a :caption attribute may be useful. Though, it must
 be documented in the manual (see 12.7.4 LaTeX specific attributes). In
 particular, documentation should insist on the fact that:

   1. :caption attribute has precedence over #+caption keyword
   2. :caption attribute is only meaningful special caption commands,
  i.e., this isn't the standard way to set a caption in Org.
   3. This is a raw command, nothing in it will be interpreted by Org.

 Here are some comments about the code:
  +  (caption-from-attr-latex (plist-get (org-export-read-attribute
 :attr_latex element) :caption)))

 You can use the following slightly shorter sexp:

   (caption-from-attr-latex (org-export-read-attribute :attr_latex element
 :caption))

  +(if (and caption-from-attr-latex (not (equal
 caption-from-attr-latex )))
  + (concat caption-from-attr-latex \n)
  +  (cond
  +   ((and (not main) (equal label-str )))
  +   ((not main) (concat label-str \n))
  +   ;; Option caption format with short name.
  +   (short (format \\caption[%s]{%s%s}\n
  +   (org-export-data short info)
  +   label-str
  +   (org-export-data main info)))
  +   ;; Standard caption format.
  +   (t (format \\caption{%s%s}\n label-str (org-export-data main
 info)))

 Here you can include the then part in the `cond', and use
 `org-string-nw-p':

   (cond ((org-string-nw-p caption-from-attr-latex)
  (concat caption-from-attr-latex \n))
 ((and (not main) (equal label-str )) )
 ...)

   (defun org-latex-guess-inputenc (header)
 Set the coding system in inputenc to what the buffer is.
  @@ -1655,7 +1658,7 @@ used as a communication channel.
  (cond ((and (not float) (plist-member attr :float)) nil)
((string= float wrap) 'wrap)
((string= float multicolumn) 'multicolumn)
  - ((or float (org-element-property :caption parent))
  + ((or float (org-element-property :caption parent)
 (plist-get attr :caption))

 Be careful here: (plist-get attr :caption) will be non-nil if :caption
 is set to the empty string. It may be bulkier to use:

   (org-string-nw-p (plist-get attr :caption))

 'figure
 (placement
  (let ((place (plist-get attr :placement)))
  @@ -2333,7 +2336,7 @@ This function assumes TABLE has `org' as its
 `:type' property and
 ((and (not float) (plist-member attr :float)) nil)
 ((string= float sidewaystable) sidewaystable)
 ((string= float multicolumn) table*)
  -  ((or float (org-element-property :caption table))
  +  ((or float (org-element-property :caption table)
 (plist-get attr :caption))

 Ditto.


 Regards,

 --
 Nicolas Goaziou



0001-Add-caption-attribute-to-ATTR_LATEX-property.patch
Description: Binary data


Re: [O] [PATCH] (update) Add :caption attribute to #+ATTR_LATEX property

2013-06-30 Thread Bastien
Hi Feng,

feng shu tuma...@gmail.com writes:

 (org-latex--inline-image): Tiny change.
 org-latex--org-table): Tiny change.

The Emacs usage is to write it like this:

  (org-latex--inline-image, org-latex--org-table): Tiny change.

Thanks!

-- 
 Bastien, nitpicking again :)



Re: [O] [PATCH] (update) Add :caption attribute to #+ATTR_LATEX property

2013-06-30 Thread feng shu
Thanks for your help. This is V4 patch.


On Mon, Jul 1, 2013 at 4:27 AM, Bastien b...@gnu.org wrote:

 Hi Feng,

 feng shu tuma...@gmail.com writes:

  (org-latex--inline-image): Tiny change.
  org-latex--org-table): Tiny change.

 The Emacs usage is to write it like this:

   (org-latex--inline-image, org-latex--org-table): Tiny change.

 Thanks!

 --
  Bastien, nitpicking again :)



0001-Add-caption-attribute-to-ATTR_LATEX-property.patch
Description: Binary data


[O] [PATCH] (update) Add :caption attribute to #+ATTR_LATEX property

2013-06-29 Thread feng shu
This is the updated patch of  Add :caption attribute to #+ATTR_LATEX
property
If possible, please include it to master



This feature is very useful when you export org to latex with custom
caption command, for example:

#+ATTR_LATEX: :caption \BiTableCaption{caption 1}{caption 2}
|---+---|
| x | y |
|---+---|
| 1 | 2 |
|---+---|

--


0001-Add-caption-attribute-to-ATTR_LATEX-property.patch
Description: Binary data