emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* latex fragment png's size too small
@ 2016-05-13  7:00 tumashu
  2016-05-14  8:56 ` Nicolas Goaziou
  0 siblings, 1 reply; 6+ messages in thread
From: tumashu @ 2016-05-13  7:00 UTC (permalink / raw)
  To: emacs-orgmode

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

The preview png of latex fragment seem to small, what about change default `org-format-latex-options'  :scale from 1.0 to 2.0?

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

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

* Re: latex fragment png's size too small
  2016-05-13  7:00 latex fragment png's size too small tumashu
@ 2016-05-14  8:56 ` Nicolas Goaziou
  2016-05-14  9:42   ` tumashu
  0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Goaziou @ 2016-05-14  8:56 UTC (permalink / raw)
  To: tumashu; +Cc: emacs-orgmode

Hello,

tumashu <tumashu@163.com> writes:

> The preview png of latex fragment seem to small, what about change
> default `org-format-latex-options'  :scale from 1.0 to 2.0?

As a data point, I use :scale 1.2. A factor of 2 may be too large for
some users.

In any case, the manual already highlights it:

     You can customize the variable ‘org-format-latex-options’ to
  influence some aspects of the preview.  In particular, the ‘:scale’ (and
  for HTML export, ‘:html-scale’) property can be used to adjust the size
  of the preview images.

Since there may not be a more reasonable default value, the best thing
to do could be to leave it up to the user to set his own factor.

WDYT?


Regards,

-- 
Nicolas Goaziou

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

* Re: latex fragment png's size too small
  2016-05-14  8:56 ` Nicolas Goaziou
@ 2016-05-14  9:42   ` tumashu
  2016-05-14 12:14     ` Nicolas Goaziou
  0 siblings, 1 reply; 6+ messages in thread
From: tumashu @ 2016-05-14  9:42 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode

The problem is that the pic is too small and nearly can not see the words in the picture, it will force user config it, if we use a larger pic, it can work although it is ugly
在 2016-05-14 16:56:15,"Nicolas Goaziou" <mail@nicolasgoaziou.fr> 写道:
Hello,

tumashu <tumashu@163.com> writes:

> The preview png of latex fragment seem to small, what about change
> default `org-format-latex-options'  :scale from 1.0 to 2.0?

As a data point, I use :scale 1.2. A factor of 2 may be too large for
some users.

In any case, the manual already highlights it:

     You can customize the variable ‘org-format-latex-options’ to
  influence some aspects of the preview.  In particular, the ‘:scale’ (and
  for HTML export, ‘:html-scale’) property can be used to adjust the size
  of the preview images.

Since there may not be a more reasonable default value, the best thing
to do could be to leave it up to the user to set his own factor.

WDYT?


Regards,

-- 
Nicolas Goaziou

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

* Re: latex fragment png's size too small
  2016-05-14  9:42   ` tumashu
@ 2016-05-14 12:14     ` Nicolas Goaziou
  2016-05-14 12:47       ` Feng Shu
  0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Goaziou @ 2016-05-14 12:14 UTC (permalink / raw)
  To: tumashu; +Cc: emacs-orgmode

tumashu <tumashu@163.com> writes:

> The problem is that the pic is too small and nearly can not see the
> words in the picture, it will force user config it, if we use a larger
> pic, it can work although it is ugly

Then is :scale 1.2 enough?

If it is too ugly, it will also force users configuring it anyway.

Regards,

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

* Re: latex fragment png's size too small
  2016-05-14 12:14     ` Nicolas Goaziou
@ 2016-05-14 12:47       ` Feng Shu
  2016-05-14 13:22         ` Feng Shu
  0 siblings, 1 reply; 6+ messages in thread
From: Feng Shu @ 2016-05-14 12:47 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Feng Shu

Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> tumashu <tumashu@163.com> writes:
>
>> The problem is that the pic is too small and nearly can not see the
>> words in the picture, it will force user config it, if we use a larger
>> pic, it can work although it is ugly
>
> Then is :scale 1.2 enough?

I tested in bare emacs, 1.2 seem ok.

> If it is too ugly, it will also force users configuring it anyway.
>
> Regards,

-- 

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

* Re: latex fragment png's size too small
  2016-05-14 12:47       ` Feng Shu
@ 2016-05-14 13:22         ` Feng Shu
  0 siblings, 0 replies; 6+ messages in thread
From: Feng Shu @ 2016-05-14 13:22 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Feng Shu

"Feng Shu" <tumashu@163.com> writes:

> Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:
>
>> tumashu <tumashu@163.com> writes:
>>
>>> The problem is that the pic is too small and nearly can not see the
>>> words in the picture, it will force user config it, if we use a larger
>>> pic, it can work although it is ugly
>>
>> Then is :scale 1.2 enough?
>
> I tested in bare emacs, 1.2 seem ok. 

I have found the other problem, the below two version of
org-create-formula-image-with-dvipng generate different size png,
for they use different dpi.

I think, we should hold :scale to 1.0 and fix size problem in function
`org-create-formula-image-with-dvipng'.

#+BEGIN_SRC emacs-lisp
;; Old version
(defun org-create-formula-image-with-dvipng (string tofile options buffer)
  "This calls dvipng."
  (require 'ox-latex)
  (let* ((tmpdir (if (featurep 'xemacs)
             (temp-directory)
           temporary-file-directory))
     (texfilebase (make-temp-name
               (expand-file-name "orgtex" tmpdir)))
     (texfile (concat texfilebase ".tex"))
     (dvifile (concat texfilebase ".dvi"))
     (pngfile (concat texfilebase ".png"))
     (fnh (if (featurep 'xemacs)
                  (font-height (face-font 'default))
                (face-attribute 'default :height nil)))
     (scale (or (plist-get options (if buffer :scale :html-scale)) 1.0))
     (dpi (number-to-string (* scale (floor (* 0.9 (if buffer fnh 140.))))))
     (fg (or (plist-get options (if buffer :foreground :html-foreground))
         "Black"))
     (bg (or (plist-get options (if buffer :background :html-background))
             "Transparent")))
    (princ (format "dpi:%s" dpi))
    (if (eq fg 'default) (setq fg (org-dvipng-color :foreground))
      (unless (string= fg "Transparent") (setq fg (org-dvipng-color-format fg))))
    (if (eq bg 'default) (setq bg (org-dvipng-color :background))
      (unless (string= bg "Transparent") (setq bg (org-dvipng-color-format bg))))
    (let ((latex-header (org-create-formula--latex-header)))
      (with-temp-file texfile
    (insert latex-header)
    (insert "\n\\begin{document}\n" string "\n\\end{document}\n")))
    (let ((dir default-directory))
      (condition-case nil
      (progn
        (cd tmpdir)
        (call-process "latex" nil nil nil texfile))
    (error nil))
      (cd dir))
    (if (not (file-exists-p dvifile))
    (progn (message "Failed to create dvi file from %s" texfile) nil)
      (condition-case nil
      (if (featurep 'xemacs)
          (call-process "dvipng" nil nil nil
                "-fg" fg "-bg" bg
                "-T" "tight"
                "-o" pngfile
                dvifile)
        (call-process "dvipng" nil nil nil
              "-fg" fg "-bg" bg
              "-D" dpi
              ;;"-x" scale "-y" scale
              "-T" "tight"
              "-o" pngfile
              dvifile))
    (error nil))
      (if (not (file-exists-p pngfile))
      (if org-format-latex-signal-error
          (error "Failed to create png file from %s" texfile)
        (message "Failed to create png file from %s" texfile)
        nil)
    ;; Use the requested file name and clean up
    (copy-file pngfile tofile 'replace)
    (loop for e in '(".dvi" ".tex" ".aux" ".log" ".png" ".out") do
          (if (file-exists-p (concat texfilebase e))
          (delete-file (concat texfilebase e))))
    pngfile))))

;; New version
(defun org-create-formula-image-with-dvipng (string tofile options buffer)
  "This calls dvipng."
  (require 'ox-latex)
  (let* ((tmpdir (if (featurep 'xemacs)
             (temp-directory)
           temporary-file-directory))
     (texfilebase (make-temp-name
               (expand-file-name "orgtex" tmpdir)))
     (texfile (concat texfilebase ".tex"))
     (dvifile (concat texfilebase ".dvi"))
     (pngfile (concat texfilebase ".png"))
     (scale (or (plist-get options (if buffer :scale :html-scale)) 1.0))
     ;; This assumes that the display has the same pixel width in
     ;; the horizontal and vertical directions
     (dpi (number-to-string (* scale (if buffer (org--get-display-dpi) 120))))
     (fg (or (plist-get options (if buffer :foreground :html-foreground))
         "Black"))
     (bg (or (plist-get options (if buffer :background :html-background))
             "Transparent")))
    (princ (format "dpi: %s" dpi))
    (if (eq fg 'default) (setq fg (org-dvipng-color :foreground))
      (unless (string= fg "Transparent") (setq fg (org-dvipng-color-format fg))))
    (if (eq bg 'default) (setq bg (org-dvipng-color :background))
      (unless (string= bg "Transparent") (setq bg (org-dvipng-color-format bg))))
    (let ((latex-header (org-create-formula--latex-header)))
      (with-temp-file texfile
    (insert latex-header)
    (insert "\n\\begin{document}\n" string "\n\\end{document}\n")))
    (let ((dir default-directory))
      (ignore-errors
    (cd tmpdir)
    (call-process "latex" nil nil nil texfile))
      (cd dir))
    (if (not (file-exists-p dvifile))
    (progn (message "Failed to create dvi file from %s" texfile) nil)
      (ignore-errors
    (if (featurep 'xemacs)
        (call-process "dvipng" nil nil nil
              "-fg" fg "-bg" bg
              "-T" "tight"
              "-o" pngfile
              dvifile)
      (call-process "dvipng" nil nil nil
            "-fg" fg "-bg" bg
            "-D" dpi
            ;;"-x" scale "-y" scale
            "-T" "tight"
            "-o" pngfile
            dvifile)))
      (if (not (file-exists-p pngfile))
      (if org-format-latex-signal-error
          (error "Failed to create png file from %s" texfile)
        (message "Failed to create png file from %s" texfile)
        nil)
    ;; Use the requested file name and clean up
    (copy-file pngfile tofile 'replace)
    (dolist (e '(".dvi" ".tex" ".aux" ".log" ".png" ".out"))
      (when (file-exists-p (concat texfilebase e))
        (delete-file (concat texfilebase e))))
    pngfile))))
#+END_SRC



>
>> If it is too ugly, it will also force users configuring it anyway.
>>
>> Regards,

--

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

end of thread, other threads:[~2016-05-14 13:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-13  7:00 latex fragment png's size too small tumashu
2016-05-14  8:56 ` Nicolas Goaziou
2016-05-14  9:42   ` tumashu
2016-05-14 12:14     ` Nicolas Goaziou
2016-05-14 12:47       ` Feng Shu
2016-05-14 13:22         ` Feng Shu

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