emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Adding latex packages
@ 2007-04-03 16:00 Matthieu Lemerre
  2007-04-13  8:41 ` Carsten Dominik
  0 siblings, 1 reply; 2+ messages in thread
From: Matthieu Lemerre @ 2007-04-03 16:00 UTC (permalink / raw)
  To: emacs-orgmode


Hello,

I wondered if it was possible to include custom Latex packages when
processing embedded LaTeX fragments in org. This would require only a
simple change in org-create-formula-image:

  (defun org-create-formula-image (string tofile options)
    (let* ((tmpdir (if (featurep 'xemacs)
  		     (temp-directory)
  		   temporary-file-directory))
  	 (texfilebase (make-temp-name
  		       (expand-file-name "orgtex" tmpdir)))
  
  ;(texfilebase (make-temp-file "orgtex"))
  ;	 (dummy (delete-file texfilebase))
  	 (texfile (concat texfilebase ".tex"))
  	 (dvifile (concat texfilebase ".dvi"))
  	 (pngfile (concat texfilebase ".png"))
  	 (scale (number-to-string (* 1000 (or (plist-get options :scale) 1.0))))
  	 (fg (or (plist-get options :foreground) "Black"))
  	 (bg (or (plist-get options :background) "Transparent")))
      (with-temp-file texfile
        (insert "\\documentclass{article}
  \\usepackage{fullpage}
  \\usepackage{amssymb}
  \\usepackage[usenames]{color}
  \\usepackage{amsmath}
  \\usepackage{latexsym}
  \\usepackage[mathscr]{eucal}

XXX insert custom packages here

  \\pagestyle{empty}
  \\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)
        (call-process "dvipng" nil nil nil
  		    "-E" "-fg" fg "-bg" bg
  		    "-x" scale "-y" scale "-T" "tight"
  		    "-o" pngfile
  		    dvifile)
        (if (not (file-exists-p pngfile))
  	  (progn (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") do
  	      (delete-file (concat texfilebase e)))
  	pngfile))))
  

This should be global or per-file options. The point is that there are
plenty of good LaTeX environments that it would be useful to have in
org (for instance algorithm or tikz).

One of these environments is tikzpicture, and using tikzpicture in org
would allow to create high-quality graphics in org documents. There is
one remaining difficulty though; tikz pictures aren't extracted with
dvipng.

What do you think?

Thanks,
Matthieu Lemerre

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

* Re: Adding latex packages
  2007-04-03 16:00 Adding latex packages Matthieu Lemerre
@ 2007-04-13  8:41 ` Carsten Dominik
  0 siblings, 0 replies; 2+ messages in thread
From: Carsten Dominik @ 2007-04-13  8:41 UTC (permalink / raw)
  To: Matthieu Lemerre; +Cc: emacs-orgmode


On Apr 3, 2007, at 18:00, Matthieu Lemerre wrote:

>
> Hello,
>
> I wondered if it was possible to include custom Latex packages when
> processing embedded LaTeX fragments in org.

In 4.71, the entire header will be contained in the option
`org-format-latex-header'.

> This should be global or per-file options. The point is that there are
> plenty of good LaTeX environments that it would be useful to have in
> org (for instance algorithm or tikz).
>
> One of these environments is tikzpicture, and using tikzpicture in org
> would allow to create high-quality graphics in org documents. There is
> one remaining difficulty though; tikz pictures aren't extracted with
> dvipng.

I guess this last issue you have to take up with the dvipng maintainers.

> What do you think?

Good idea, thanks!

- Carsten



--
Carsten Dominik
Sterrenkundig Instituut "Anton Pannekoek"
Universiteit van Amsterdam
Kruislaan 403
NL-1098SJ Amsterdam
phone: +31 20 525 7477

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

end of thread, other threads:[~2007-04-13  8:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-03 16:00 Adding latex packages Matthieu Lemerre
2007-04-13  8:41 ` Carsten Dominik

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