all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: "Stefanos Carlström" <stefanos.carlstrom@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] Added possibility of overriding PGF inclusion command
Date: Sat, 30 Jul 2016 21:57:12 +0200	[thread overview]
Message-ID: <87wpk2dhlz.fsf@saiph.selenimh> (raw)
In-Reply-To: <1468762532-44794-1-git-send-email-stefanos.carlstrom@gmail.com> ("Stefanos \=\?utf-8\?Q\?Carlstr\=C3\=B6m\=22's\?\= message of "Sun, 17 Jul 2016 15:35:32 +0200")

Hello,

Stefanos Carlström <stefanos.carlstrom@gmail.com> writes:

> * ox-latex.el (org-latex--inline-image): The user can now customize the
>   way PGF images are included by changing the (new) variable
>   `org-latex-inline-pgf-command'.
>
> If the PGF file is stored in a subdirectory and references an external
> image file in the same directory, LaTeX will complain about not finding
> it.  A workaround could be to define a function like this in the
> preamble:
>
> \newcommand\inputpgf[2]{{
>     \let\pgfimageWithoutPath\pgfimage
>     \renewcommand{\pgfimage}[2][]{\pgfimageWithoutPath[##1]{#1/##2}}
>     \input{#1/#2}
>   }}
>
> and customizing `org-latex-inline-pgf-command' to hold this function:
>
> (lambda (path)
>   (let ((dir-name (substring (file-name-directory path) 0 -1))
>         (file-name (file-name-nondirectory path)))
>     (format "\\inputpgf{%s}{%s}" dir-name file-name)))
>
> This way, LaTeX will be able to find the external images.  The idea came
> from here: http://tex.stackexchange.com/a/282110/9742

Thank you for your patch.

However, you can easily achieve the same using a filter, can't you?

If a function needs to be introduced, it would be better to factor out
the whole "tikz" and "pgf" handling, i.e.,

  (progn
    (setq image-code (format "\\input{%s}" path))
    (when (org-string-nw-p options)
      (setq image-code
            (format "\\begin{tikzpicture}[%s]\n%s\n\\end{tikzpicture}"
                    options
                    image-code)))
    (when (or (org-string-nw-p width) (org-string-nw-p height))
      (setq image-code (format "\\resizebox{%s}{%s}{%s}"
                               (if (org-string-nw-p width) width "!")
                               (if (org-string-nw-p height) height "!")
                               image-code))))

and have a variable holding a function to handle this such extensions,
and doing the above as a default.

Anyway, that's just an idea and people more knowledgeable on the subject
may want to chime in.


Regards,

-- 
Nicolas Goaziou

      reply	other threads:[~2016-07-30 19:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-17 13:35 [PATCH] Added possibility of overriding PGF inclusion command Stefanos Carlström
2016-07-30 19:57 ` Nicolas Goaziou [this message]

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wpk2dhlz.fsf@saiph.selenimh \
    --to=mail@nicolasgoaziou.fr \
    --cc=emacs-orgmode@gnu.org \
    --cc=stefanos.carlstrom@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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.