[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Latex export of tables
From: |
Myles English |
Subject: |
Re: [O] Latex export of tables |
Date: |
Wed, 17 Apr 2013 11:21:55 +0100 |
User-agent: |
mu4e 0.9.9.5-dev6; emacs 24.3.1 |
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
- [O] Latex export of tables, Vikas Rawal, 2013/04/12
- Re: [O] Latex export of tables, Suvayu Ali, 2013/04/14
- Re: [O] Latex export of tables, Vikas Rawal, 2013/04/16
- Re: [O] Latex export of tables, Thomas Alexander Gerds, 2013/04/16
- Re: [O] Latex export of tables, Suvayu Ali, 2013/04/16
- Re: [O] Latex export of tables, Thomas S. Dye, 2013/04/16
- Re: [O] Latex export of tables, Suvayu Ali, 2013/04/16
- Re: [O] Latex export of tables, Thomas S. Dye, 2013/04/16
- Re: [O] Latex export of tables,
Myles English <=
- [O] Best practices for literate programming [was: Latex export of tables], Vikas Rawal, 2013/04/16
- Re: [O] Best practices for literate programming [was: Latex export of tables], Thomas S. Dye, 2013/04/16
- Re: [O] Best practices for literate programming [was: Latex export of tables], Rasmus, 2013/04/18
- Re: [O] Best practices for literate programming [was: Latex export of tables], Aaron Ecay, 2013/04/18
- Re: [O] Best practices for literate programming [was: Latex export of tables], Rasmus, 2013/04/18
- Re: [O] Best practices for literate programming [was: Latex export of tables], Achim Gratz, 2013/04/18
- Re: [O] Best practices for literate programming [was: Latex export of tables], Thomas S. Dye, 2013/04/18
- Re: [O] Best practices for literate programming [was: Latex export of tables], Rasmus Pank Roulund, 2013/04/21
- Re: [O] Best practices for literate programming [was: Latex export of tables], Suvayu Ali, 2013/04/17
- Re: [O] Best practices for literate programming [was: Latex export of tables], Rainer M. Krug, 2013/04/17