emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* how to replace includegraphics?
@ 2017-05-31  3:37 edgar
  2017-05-31 13:55 ` John Hendy
  2017-05-31 17:01 ` Charles C. Berry
  0 siblings, 2 replies; 6+ messages in thread
From: edgar @ 2017-05-31  3:37 UTC (permalink / raw)
  To: emacs-orgmode

Hello dear list,

* Summary
I want to know if someone could tell me how to replace (the macro, 
function, string) includegraphics for something else when exporting to 
LaTeX. In my case, simplesvg.

* Why
I have my own version of the svg package (I only extracted bits and 
pieces from it long time ago), and I want to make clear for others who 
may use my files that I'm not using includesvg (I could just change the 
definition of simplesvg to includesvg).

* What I have tried
** Stealing from the webz
This does not work. I think that the list doesn't exist in org-mode 
anymore:
#+BEGIN_SRC emacs-lisp
   ;; Export svg (does not work)
   ;; 
https://lists.gnu.org/archive/html/emacs-orgmode/2013-08/msg00221.html
   ;; 
https://github.com/tsdye/tufte-org-mode/blob/master/ox-tufte-latex.el
   (defun my-svg-graphics (contents backend info)
     (when (eq backend 'latex)
       (replace-regexp-in-string 
"\\`\\\\includegraphics.+\\({.+\.svg}\\)"
                                 "\\\\simplesvg\1" contents))
     )
   (add-to-list 'org-export-filter-link-functions 'my-svg-graphics)
#+END_SRC

** Looking into org (ox-latex.el)
I found this (around line 2375 in ox-latex.el):
#+BEGIN_SRC emacs-lisp
(when (equal filetype "svg")
   (setq image-code (replace-regexp-in-string "^\\\\includegraphics"
                                              "\\includesvg"
                                              image-code
                                              nil t))
   (setq image-code (replace-regexp-in-string "\\.svg}"
                                              "}"
                                              image-code
                                              nil t)))
#+END_SRC

I could just change the code here (simplesvg instead of includesvg), but 
before f\#\#cking up my system, I would like to know if there is another 
alternative.

Thanks, as always :D !

-------------------------------------------------

ONLY AT VFEmail! - Use our Metadata Mitigator to keep your email out of the NSA's hands!
$24.95 ONETIME Lifetime accounts with Privacy Features!  
15GB disk! No bandwidth quotas!
Commercial and Bulk Mail Options!  

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

* Re: how to replace includegraphics?
  2017-05-31  3:37 how to replace includegraphics? edgar
@ 2017-05-31 13:55 ` John Hendy
  2017-05-31 22:35   ` edgar
  2017-05-31 17:01 ` Charles C. Berry
  1 sibling, 1 reply; 6+ messages in thread
From: John Hendy @ 2017-05-31 13:55 UTC (permalink / raw)
  To: edgar; +Cc: emacs-orgmode

On Tue, May 30, 2017 at 10:37 PM,  <edgar@openmail.cc> wrote:
> Hello dear list,
>
> * Summary
> I want to know if someone could tell me how to replace (the macro, function,
> string) includegraphics for something else when exporting to LaTeX. In my
> case, simplesvg.

This made me think of the various times someone wants to use endnotes
instead of footnotes. Have you considered just changing the definition
in LaTeX instead? [1] [2]

#+LaTeX_HEADER: \usepackage{endnotes}
#+LaTeX_HEADER: \let\footnote=\endnote

In other words, utilize the fact that Org already handles images
flawlessly and then just define \includegraphics to be something else
on the LaTeX end of things.


John

[1] http://perlstalker.vuser.org/blog/2014/07/15/endnotes-org-mode/
[2] https://tex.stackexchange.com/questions/53895/converting-footnotemarks-to-endnotes

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

* Re: how to replace includegraphics?
  2017-05-31  3:37 how to replace includegraphics? edgar
  2017-05-31 13:55 ` John Hendy
@ 2017-05-31 17:01 ` Charles C. Berry
  2017-05-31 22:36   ` edgar
  1 sibling, 1 reply; 6+ messages in thread
From: Charles C. Berry @ 2017-05-31 17:01 UTC (permalink / raw)
  To: edgar; +Cc: emacs-orgmode

On Wed, 31 May 2017, edgar@openmail.cc wrote:

> Hello dear list,
>
> * Summary
> I want to know if someone could tell me how to replace (the macro, function, 
> string) includegraphics for something else when exporting to LaTeX. In my 
> case, simplesvg.
>

This is what filters are for.  In your case `:filter-link' needs to have a 
function that changes `includegraphics' to `simplesvg', if I get what you 
want.

Check out the manual:

 	(info "(org) Advanced configuration")

maybe run the example here:

 	http://orgmode.org/worg/exporters/filter-markup.html

and consult the part about filters here:

 	http://orgmode.org/worg/dev/org-export-reference.html

There are examples in the ox-*.el files, too. So, grep these for 
`filters-alist' to see some examples.

HTH,

Chuck

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

* Re: how to replace includegraphics?
  2017-05-31 13:55 ` John Hendy
@ 2017-05-31 22:35   ` edgar
  2017-05-31 23:29     ` John Hendy
  0 siblings, 1 reply; 6+ messages in thread
From: edgar @ 2017-05-31 22:35 UTC (permalink / raw)
  To: John Hendy; +Cc: emacs-orgmode

Hello John,

> instead of footnotes. Have you considered just changing the definition
> in LaTeX instead? [1] [2]
Yes, may be the redaction of my request was not very clear, I'm sorry. I 
did not want to do that, because I foresee that someone may think that 
my \includesvg is the \includesvg from the svg package. However, the two 
do not work in the same way, and may lead to problems.

If my previous e-mail was indeed clear, may be I'm not getting what you 
are trying to say, sorry.

Thank you.


Edgar

-------------------------------------------------

ONLY AT VFEmail! - Use our Metadata Mitigator to keep your email out of the NSA's hands!
$24.95 ONETIME Lifetime accounts with Privacy Features!  
15GB disk! No bandwidth quotas!
Commercial and Bulk Mail Options!  

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

* Re: how to replace includegraphics?
  2017-05-31 17:01 ` Charles C. Berry
@ 2017-05-31 22:36   ` edgar
  0 siblings, 0 replies; 6+ messages in thread
From: edgar @ 2017-05-31 22:36 UTC (permalink / raw)
  To: Charles C. Berry; +Cc: emacs-orgmode

> This is what filters are for.  In your case `:filter-link' needs to
> have a function that changes `includegraphics' to `simplesvg', if I
> get what you want.

Oh! Thanks! I was unaware of this. I'll try :) .


Edgar

-------------------------------------------------

ONLY AT VFEmail! - Use our Metadata Mitigator to keep your email out of the NSA's hands!
$24.95 ONETIME Lifetime accounts with Privacy Features!  
15GB disk! No bandwidth quotas!
Commercial and Bulk Mail Options!  

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

* Re: how to replace includegraphics?
  2017-05-31 22:35   ` edgar
@ 2017-05-31 23:29     ` John Hendy
  0 siblings, 0 replies; 6+ messages in thread
From: John Hendy @ 2017-05-31 23:29 UTC (permalink / raw)
  To: edgar; +Cc: emacs-orgmode

On Wed, May 31, 2017 at 5:35 PM,  <edgar@openmail.cc> wrote:
> Hello John,
>
>> instead of footnotes. Have you considered just changing the definition
>> in LaTeX instead? [1] [2]
>
> Yes, may be the redaction of my request was not very clear, I'm sorry. I did
> not want to do that, because I foresee that someone may think that my
> \includesvg is the \includesvg from the svg package. However, the two do not
> work in the same way, and may lead to problems.

I initially saw this:

(replace-regexp-in-string "\\`\\\\includegraphics.+\\({.+\.svg}\\)"
                                "\\\\simplesvg\1" contents))

That looked like you wanted to just swap \includegraphics with
\simplesvg. Doing that via LaTeX directly seemed like an easy way:

#+latex: \let\includegraphics\simplesvg

Now that I'm re-examining, you only want to do this for .svgs so
that's not nearly as straightforward.

> If my previous e-mail was indeed clear, may be I'm not getting what you are
> trying to say, sorry.

If the above *did* work, I don't see why you couldn't just remove the
#+latex line before publishing. Or define it in a setupfile that you
load and no one would ever know the contents to get confused. Or
perhaps it was a mandatory requirement to do zero changes to the file
you publish? The first method you showed appeared to apply elisp code
from within the file, so I'd assume an external user would see it but
have to ignore/not eval.

Filters are intimidating to me (no elisp-fu here!), but they
definitely sound like the ticket!


Good luck,
John

P.S. On a last point re. the confusion alone, I'm interpreting you to
mean users may think \simplesvg == \includesvg? Or simplesvg is your
package *name*, svg is the CTAN package, and they both provide
\includesvg? Why not rename your local version's command to a
different name? Or do \usepacakge{simplesvg} locally, and in the
published version have it commented with a note that it's special? Or
make your package available and include a link and instructions to
replicate? Just seems like an awful lot of work for a naming
convention issue!

> Thank you.
>
>
> Edgar
>
> -------------------------------------------------
>
> ONLY AT VFEmail! - Use our Metadata Mitigator to keep your email out of the
> NSA's hands!
> $24.95 ONETIME Lifetime accounts with Privacy Features!  15GB disk! No
> bandwidth quotas!
> Commercial and Bulk Mail Options!

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

end of thread, other threads:[~2017-05-31 23:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-31  3:37 how to replace includegraphics? edgar
2017-05-31 13:55 ` John Hendy
2017-05-31 22:35   ` edgar
2017-05-31 23:29     ` John Hendy
2017-05-31 17:01 ` Charles C. Berry
2017-05-31 22:36   ` edgar

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