emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <n.goaziou@gmail.com>
To: feng shu <tumashu@gmail.com>
Cc: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Re: [PATCH] bugfix: fix previewing latex fragments with imagemagick
Date: Sun, 14 Jul 2013 10:29:22 +0200	[thread overview]
Message-ID: <87ehb1lf31.fsf@gmail.com> (raw)
In-Reply-To: <CAJpRBmc_0=OcanCj2=4A_dVOS=fbJfUZ6hv0w5D4TwjSMGa3Vw@mail.gmail.com> (feng shu's message of "Sun, 14 Jul 2013 15:06:23 +0800")

Hello,

feng shu <tumashu@gmail.com> writes:

> Previewing and exporting latex fragments with imagemagick has been broken
> when new export system merged.  This is the fix patch.

Thanks for the patch. Here are a few comments.

> Subject: [PATCH] bugfix: fix generating formula image with imagemagick when
>  previewing and exporting

Prefer "Fix generating LaTeX formula images" as subject.

> -@file{dvipng} is used to create images, any @LaTeX{} environment will be
> -handled.}.  The only requirement is that the @code{\begin} and @code{\end}
> -statements appear on a new line, at the beginning of the line or after
> -whitespaces only.
> +@file{dvipng} program or @file{imagemagick} suite is used to create images, 
> +any @LaTeX{} environment will be handled.}.  The only requirement is that the
> +@code{\begin} and @code{\end} statements appear on a new line, at the
> +beginning of the line or after whitespaces only.
>  @item
>  Text within the usual @LaTeX{} math delimiters.  To avoid conflicts with
>  currency specifications, single @samp{$} characters are only recognized as
> @@ -10196,10 +10196,11 @@ You can also set this variable on a per-file basis using one of these
>  lines:
>  
>  @example
> -#+OPTIONS: tex:t          @r{Do the right thing automatically (MathJax)}
> -#+OPTIONS: tex:dvipng     @r{Force using dvipng images}
> -#+OPTIONS: tex:nil        @r{Do not process @LaTeX{} fragments at all}
> -#+OPTIONS: tex:verbatim   @r{Verbatim export, for jsMath or so}
> +#+OPTIONS: tex:t                   @r{Do the right thing automatically (MathJax)}
> +#+OPTIONS: tex:dvipng              @r{Force using dvipng images}
> +#+OPTIONS: tex:imagemagick         @r{Force using images converted by imagemagick}
> +#+OPTIONS: tex:nil                 @r{Do not process @LaTeX{} fragments at all}
> +#+OPTIONS: tex:verbatim            @r{Verbatim export, for jsMath or so}
>  @end example

It should be:

  @example
  #+OPTIONS: tex:t          @r{Do the right thing automatically (MathJax)}
  #+OPTIONS: tex:nil        @r{Do not process @LaTeX{} fragments at all}
  #+OPTIONS: tex:verbatim   @r{Verbatim export, for jsMath or so}
  @end example

because `org-export-with-latex' provides neither `dvipng' nor
`imagemagick' options. Those are added by some back-ends (e.g.,
`org-html-with-latex').

>  @node Previewing @LaTeX{} fragments, CDLaTeX mode, @LaTeX{} fragments, Embedded @LaTeX{}
> @@ -10207,8 +10208,8 @@ lines:
>  @cindex @LaTeX{} fragments, preview
>  
>  @vindex org-latex-create-formula-image-program
> -If you have @file{dvipng} or @file{imagemagick} installed@footnote{Choose the
> -converter by setting the variable
> +If you have @file{dvipng} program  or @file{imagemagick} suite
> +installed@footnote{Choose the converter by setting the variable

Does this change really matter?

> -@cindex dvipng
> +@cindex dvipng or imagemagick

Use

  @cindex dvipng
  @cindex imagemagick

instead.

>  @LaTeX{} math snippets (@pxref{@LaTeX{} fragments}) can be displayed in two
>  different ways on HTML pages.  The default is to use the
> @@ -11282,13 +11283,21 @@ this line.
>  If you prefer, you can also request that @LaTeX{} fragments are processed
>  into small images that will be inserted into the browser page.  Before the
>  availability of MathJax, this was the default method for Org files.  This
> -method requires that the @file{dvipng} program is available on your system.
> -You can still get this processing with
> +method requires that the @file{dvipng} program  or @file{imagemagick} suite is
> +available on your system.You can still get this processing with

Mind the spaces: too many before "or", not enough before "You".

> +or:
> +
> +@example
> +#+OPTIONS: tex:imagemagick
> +@end example
> +
> +
> +

Nitpick: No need for so many blank lines.

> -@cindex dvipng
> +@cindex dvipng or imagemagick

See above.

>  @item PNG images
>  
>  This option is activated on a per-file basis with
> @@ -12273,9 +12282,16 @@ This option is activated on a per-file basis with
>  #+OPTIONS: LaTeX:dvipng
>  @end example
>  
> +or:
> +
> +@example
> +#+OPTIONS: LaTeX:imagemagick
> +@end example
> +

OK. But documentation is still wrong here. It should be "tex:dvipng" and
"tex:imagemagick".

> -that the @file{dvipng} program be available on your system.
> +that the @file{dvipng} program  or @file{imagemagick} suite be available on
> +your system.

Check white spaces.

> -	 (dpi (number-to-string (* scale (floor (* 0.9 (if buffer fnh 140.))))))
> +	 (dpi (number-to-string (* scale (floor (if buffer fnh 120.)))))

Note sure about this change. Why do you think it is needed?

> -      (dvipng
> +      ((or dvipng imagemagick)

It should be:

  ((dvipng imagemagick)

See `case' documentation.

> -      (dvipng
> +      ((or dvipng imagemagick)

Ditto.

> -      (dvipng
> +      ((or dvipng imagemagick)

Ditto.

>         (unless (and (org-check-external-command "latex" "" t)
> -		    (org-check-external-command "dvipng" "" t))
> +		    (org-check-external-command "dvipng" "" t)
> +		    (org-check-external-command "convert" "" t))

There's a missing `or':

  (or (org-check-external-command "dvipng" "" t)
      (org-check-external-command "convert" "" t))

>  				(case processing-type
> -				  (dvipng "ltxpng/")
> +				  ((or dvipng imagemagick) "ltxpng/")

See above.

>  		  (case processing-type
> -		    (dvipng (format "Creating LaTeX Image %d..." count))
> +		    ((or dvipng imagemagick) (format "Creating LaTeX Image %d..." count))

See above.


Regards,

-- 
Nicolas Goaziou

  reply	other threads:[~2013-07-14  8:29 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-14  7:02 [PATCH] bugfix: fix previewing latex fragments with imagemagick feng shu
2013-07-14  7:06 ` feng shu
2013-07-14  8:29   ` Nicolas Goaziou [this message]
2013-07-14  8:35     ` Nicolas Goaziou
2013-07-14 13:08       ` Feng Shu
2013-07-15  7:43         ` Nicolas Goaziou
2013-07-14 13:03     ` Feng Shu

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=87ehb1lf31.fsf@gmail.com \
    --to=n.goaziou@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=tumashu@gmail.com \
    /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).