emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Russell Adams <RLAdams@AdamsInfoServ.Com>
To: emacs-orgmode@gnu.org
Subject: Re: Best way of including tikz into latex (pdf and beamer) export with preview?
Date: Thu, 19 May 2016 15:07:58 +0200	[thread overview]
Message-ID: <20160519130757.GD30134@cardamom.adamsinfoserv.com> (raw)
In-Reply-To: <87mvnmcscq.fsf@gmail.com>

On Thu, May 19, 2016 at 10:25:09AM +0100, Myles English wrote:
> > What is the best way of including tikz into org for latex export
> > (beamer and pdf), and to have preview as well?

I have used R in the past to generate two outputs for a given graph,
one PNG and one PDF from a source block in my Org file.

Then immediately under the source block I would put a commented out
file link so that Org's inline image display would show it to me. Then
I used the latex include command beneath to include the PDF for the
final output.

This let me preview and have high quality output.

Sample code:

#+BEGIN_SRC R :session *R-Buffer* :tangle myfile.R :exports none :results none silent :var basename="playerAging"
  doublePlot = function (base, plotFunc,
                         pngopts = c( width = 1024, height = 500 ),
                         pdfopts = c( width = 10, height = 7.5, paper =
                         'usr')
                         ) {

    # basename from org-babel
    myPng = paste(base,"png",sep=".")
    myPdf = paste(base,"pdf",sep=".")

    png(myPng, pngopts )
    plotFunc()
    dev.off()
    pdf(myPdf, pdfopts)
    plotFunc()
    dev.off()
  }

  doublePlot(base=basename, plotFunc = function() {
    plot(players$last_save,players$age,main="Player Age vs Last Login")
    grid(col="gray",lty=2)
  })
#+END_SRC

# [[file:playerAging.png]]

#+LATEX: \includegraphics[width=\textwidth]{playerAging.pdf}\newpage




------------------------------------------------------------------
Russell Adams                            RLAdams@AdamsInfoServ.com

PGP Key ID:     0x1160DCB3           http://www.adamsinfoserv.com/

Fingerprint:    1723 D8CA 4280 1EC9 557F  66E8 1154 E018 1160 DCB3

      reply	other threads:[~2016-05-19 13:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-12  8:45 Best way of including tikz into latex (pdf and beamer) export with preview? Rainer M Krug
2016-05-17 10:30 ` Rasmus
2016-05-17 21:44 ` briangpowell .
2016-05-19  9:25 ` Myles English
2016-05-19 13:07   ` Russell Adams [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

  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=20160519130757.GD30134@cardamom.adamsinfoserv.com \
    --to=rladams@adamsinfoserv.com \
    --cc=emacs-orgmode@gnu.org \
    /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).