emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Myles English <mylesenglish@gmail.com>
To: Suvayu Ali <fatkasuvayu+linux@gmail.com>
Cc: emacs-orgmode@gnu.org, "Thomas S. Dye" <tsd@tsdye.com>
Subject: Re: Latex export of tables
Date: Wed, 17 Apr 2013 11:21:55 +0100	[thread overview]
Message-ID: <87bo9dzccc.fsf@gmail.com> (raw)
In-Reply-To: <20130416213917.GA9183@kuru.dyndns-at-home.com>


Hi Suvayu,

Suvayu Ali writes:

> Actually, I am working on a workflow for large writing projects, my PhD
> thesis in this case :-p.  What I have in mind is have a Makefile based
> build system that uses `emacs --batch' to export to LaTeX and html.  The
> images are generated separately using babel blocks or standalone TeX
> files with TikZ code.  I intend to make pdf images for LaTeX and convert
> them to png/svg with imagemagick/inkscape.  Of course all of this is
> still a pipe dream; if I get it working, I'll definitely write a Worg
> page on it.  Of course it will be great if people with interesting ideas
> pitch in :).  I expect to have an early working environment in a couple
> of months.

I am looking forward to seeing what you come up with.  (I have mentioned
this before, however) I have been using a CMake system for LaTeX export:

http://cmake.org/Wiki/images/8/80/UseLATEX.cmake

This allows (amongst other things) generating graphics from stand alone
R scripts that get their own data from a database.  I believe the new
version has some kind of support for SVG.  I used this system for
several papers and my thesis and it has three main advantages:

1) out-of-source builds, so my working dir doesn't get cluttered with
LaTeX files

2) asynchronous export of org to LaTeX (although this is now available
with the new exporter)

3) the graphics are regenerated every time so I know it all still
works

I tangle a CMakeList.txt from every org file that I want to export, then
run cmake ~/path; make from the commandline.

(Version control as part of this workflow is possibly another topic: I
have been using git subtrees to make project-local copies of files such
as mystyle.sty and mybiblatex.bib and then update the main git repo with
the changes, and pull the changes down to another project.)

I'll just paste the whole CMakeList.txt so you can see what it looks
like, but the most interesting part is the emacs --batch command:

#+BEGIN_SRC sh :tangle CMakeLists.txt
  cmake_minimum_required(VERSION 2.8)
    
  project(relk NONE)
    
  include(/usr/share/cmake-2.8/Modules/UseLATEX.cmake)
    
  # export the .tex file from the .org file
  # using the emacs orgmode exporter
  latex_get_output_path(OUTPUT_DIR)
    
  file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/relkpaper.org DESTINATION ${OUTPUT_DIR}/ )
  file(COPY /home/myles/lib/lisp/my-export.el DESTINATION ${OUTPUT_DIR}/ )
  
  add_custom_target( orgfile ALL
      DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/relkpaper.org )
  
  add_custom_target( elfile ALL
      DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/my-export.el )
  
  add_custom_command(
      OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/relkpaper.tex
      COMMAND emacs --batch --eval \"(progn
          (add-to-list 'load-path
          (expand-file-name \\"~/.emacs.d/plugins/org-mode/lisp/\\"))
        (add-to-list 'load-path
              (expand-file-name \\"~/.emacs.d/plugins/org-mode/contrib/lisp/\\" t))
          (require 'org)
        (require 'ox)
          (require 'org-exp)
        (require 'org-inlinetask)
          (org-babel-do-load-languages
              'org-babel-load-languages
          '((emacs-lisp . t)
              (sh . t)))
          (setq org-confirm-babel-evaluate nil)
          (setq org-export-with-todo-keywords nil)
          (setq org-export-babel-evaluate nil)
          (load-file \\"my-export.el\\")
          (add-to-list 'org-export-before-parsing-hook 'my-export-delete-headlines-tagged-noheading)
          (add-to-list 'org-export-filter-link-functions
          'my-autoref-filter-link-func)
          (find-file \\"${CMAKE_CURRENT_BINARY_DIR}/relkpaper.org\\")
          (org-latex-export-to-latex))\"
      DEPENDS orgfile elfile
      COMMENT "Exporting orgmode file to LaTeX using emacs")
  
  add_custom_target( mainfile ALL
      DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/relkpaper.tex )
    
  # Set R executable
  set(R_COMPILE "/usr/bin/Rscript")
  # Set the location of data files
  ##set(DATA_DIR data)
  # Set the location of the directory for image files
  set(IMAGE_DIR graphicsauto)
    
  # Get a list of R files
  file(GLOB_RECURSE R_FILES "*.R")
    
  # Copy over all R scripts
  # add_custom_command(
  #   OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/R
  #   DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/R
  #   COMMAND ${CMAKE_COMMAND} -E copy_directory
  #     ${CMAKE_CURRENT_SOURCE_DIR}/R
  #     ${CMAKE_CURRENT_BINARY_DIR}/R
  # )
  file( COPY ${CMAKE_CURRENT_SOURCE_DIR}/R
      DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
  file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${IMAGE_DIR})
    
  foreach(file ${R_FILES})
      message("processing ${file}")
      get_filename_component(basename "${file}" NAME_WE)
      #file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/R/${file} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/R/${file})
      # # Replace strings in R files so data files can be found
      # file(READ
      # ${CMAKE_CURRENT_SOURCE_DIR}/${IMAGE_DIR}/${basename}.R
      # file_contents
      # )
      # string(REPLACE "${DATA_DIR}" "${IMAGE_DIR}/${DATA_DIR}"
      # changed_file_contents ${file_contents}
      # )
      # file(WRITE
      # ${CMAKE_CURRENT_BINARY_DIR}/${IMAGE_DIR}/${basename}.R
      # ${changed_file_contents}
      # )
    
        # Command to run R
        if(R_COMPILE)
          message("Adding ........... ${CMAKE_CURRENT_BINARY_DIR}/R/${basename}.R")
    
          add_custom_command(
            OUTPUT
              ${CMAKE_CURRENT_BINARY_DIR}/${IMAGE_DIR}/${basename}.eps
            DEPENDS
              ${CMAKE_CURRENT_BINARY_DIR}/R/${basename}.R
              #      ${CMAKE_CURRENT_BINARY_DIR}/${IMAGE_DIR}/${DATA_DIR}
            COMMAND
              ${R_COMPILE}
            ARGS
              ${CMAKE_CURRENT_BINARY_DIR}/R/${basename}.R
              ${CMAKE_CURRENT_BINARY_DIR}/${IMAGE_DIR}/${basename}.eps
          )
    message("Running ${R_COMPILE} ${CMAKE_CURRENT_BINARY_DIR}/R/${basename}.R ${CMAKE_CURRENT_BINARY_DIR}/${IMAGE_DIR}/${basename}.eps")
    
       # add_dependencies( ${CMAKE_CURRENT_BINARY_DIR}/R/${basename}.R
     # ${CMAKE_CURRENT_BINARY_DIR}/${IMAGE_DIR}/${basename}.eps
    #)
    endif(R_COMPILE)
    
        # Make a list of all R files (for ADD_LATEX_DOCUMENT depend)
        set(ALL_R_FILES ${ALL_R_FILES}
          ${CMAKE_CURRENT_BINARY_DIR}/${IMAGE_DIR}/${basename}.eps
        )
  endforeach(file)
    
  # # Copy over all data files needed to generate R graphs
  # add_custom_command(
  #   OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${IMAGE_DIR}/${DATA_DIR}
  #   DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${IMAGE_DIR}/${DATA_DIR}
  #   COMMAND ${CMAKE_COMMAND} -E copy_directory
  #     ${CMAKE_CURRENT_SOURCE_DIR}/${IMAGE_DIR}/${DATA_DIR}
  #     ${CMAKE_CURRENT_BINARY_DIR}/${IMAGE_DIR}/${DATA_DIR}
  # )
    
  add_latex_document( a.tex
      INPUTS texlib/mystyle.sty
      IMAGE_DIRS img/scans ${IMAGE_DIR} img
      DEPENDS ${ALL_R_FILES}
              mainfile
      BIBFILES texlib/mybiblatex.bib
      DEFAULT_PDF
      USE_NOMENCL
  )
    
#+END_SRC

Myles

  parent reply	other threads:[~2013-04-17 10:20 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-12  8:06 Latex export of tables Vikas Rawal
2013-04-14 23:29 ` Suvayu Ali
2013-04-16 11:56   ` Vikas Rawal
2013-04-16 13:13     ` Thomas Alexander Gerds
2013-04-16 17:39     ` Suvayu Ali
2013-04-16 20:07       ` Thomas S. Dye
2013-04-16 21:39         ` Suvayu Ali
2013-04-16 23:45           ` Thomas S. Dye
2013-04-17 10:21           ` Myles English [this message]
2013-04-16 22:10         ` Best practices for literate programming [was: Latex export of tables] Vikas Rawal
2013-04-17  0:06           ` Thomas S. Dye
2013-04-18 16:53             ` Rasmus
2013-04-18 17:59               ` Aaron Ecay
2013-04-18 18:25                 ` Rasmus
2013-04-18 19:48                 ` Achim Gratz
2013-04-18 19:42               ` Thomas S. Dye
2013-04-21 17:25                 ` Rasmus Pank Roulund
2013-04-17  6:39           ` Suvayu Ali
2013-04-17  9:55             ` Rainer M. Krug
2013-04-17 10:10               ` Suvayu Ali
  -- strict thread matches above, loose matches on Subject: below --
2009-10-13 10:35 LaTeX export of tables Francesco Pizzolante
     [not found] ` <873a5nr379.fsf-djc/iPCCuDYQheJpep6IedvLeJWuRmrY@public.gmane.org>
2009-10-19 11:58   ` Francesco Pizzolante
2009-10-19 18:05     ` Darlan Cavalcante Moreira
2009-10-20  8:17     ` Carsten Dominik

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=87bo9dzccc.fsf@gmail.com \
    --to=mylesenglish@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=fatkasuvayu+linux@gmail.com \
    --cc=tsd@tsdye.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 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).