[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Orgmode] Re: export (as latex) a large number of org files in a directo
From: |
Sébastien Vauban |
Subject: |
[Orgmode] Re: export (as latex) a large number of org files in a directory |
Date: |
Wed, 02 Sep 2009 17:21:36 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) |
Hi Nick and the others,
Nick Dokos wrote:
> Stephen Tucker <address@hidden> wrote:
>
>> Hi, I am trying to export a bunch of .org files stored in a directory as
>> latex files.
>
> The following script (I call it org-to-latex) works fine on linux:
>
> #! /bin/bash
>
> orglib=$HOME/elisp/org-mode/lisp
> emacs --batch \
> --load=$orglib/org.elc \
> --eval "(setq org-export-headline-levels 2)" \
> --visit=$1 --funcall org-export-as-latex-batch
Another solution is a Makefile, such as this one:
--8<---------------cut here---------------start------------->8---
## Makefile for Web site (+ PDF equivalent)
# Time-stamp: <2009-09-02 Wed 16:43 sva on mundaneum>
# Defined rules for users:
#
# - (make called without parameter)
# Generate all PDF
#
# - clean
# Delete all temporary files
#
# - realclean
# Do `make clean' plus remove all generated files
# where to find a recent version of Org-mode
ORGLIB = $(HOME)/Downloads/emacs/site-lisp/org-mode/lisp
# publish HTML directory
DISTDIR = ../public_html
# platform-specific setup (to override ORGLIB and/or DISTDIR)
-include Make.params
PDFLATEX = pdflatex --interaction=batchmode
RM = rm -f
RMEXT = *.log *.aux *.toc *.lot *.lof *.out *.ilg *.idx *.ind *.blg *.bbl \
*.glg *.glx *.glo *.gls *.tex
RMOUT = *.pdf $(DISTDIR)/*.html
# all source files
ORG=$(wildcard *.org)
# all exported PDF files
PDF=$(patsubst %.org, %.pdf, $(ORG))
# all TEX files
TEX=$(patsubst %.org, %.tex, $(ORG))
# all published HTML files
HTML=$(patsubst %.org, $(DISTDIR)/%.html, $(ORG))
.PHONY: all html pdf clean realclean
# avoid make to delete intermediate `%.tex' target
.PRECIOUS: %.tex
.DEFAULT_GOAL := all
all: html pdf
html: $(HTML)
pdf: $(PDF) clean
tex: $(TEX)
$(DISTDIR)/%.html: %.org
@echo
@emacs --batch \
--eval "(add-to-list 'load-path \"$(ORGLIB)\")" \
--load ./Org2HTML.el \
--visit=$^ \
--funcall org-publish-current-file
%.pdf: %.tex
# Runs LaTeX once, then reruns LaTeX as many times as necessary to get rid of
# the "Rerun to get cross-references right" warning message
@echo
@echo "* Running \`pdfLaTeX $^' *"
@$(RM) *.log
@$(PDFLATEX) $^
@while ( grep -e "Rerun .* cross-references" *.log > /dev/null ); \
do \
echo; \
echo "* Re-running \`pdfLaTeX $^' *"; \
$(RM) *.log; \
$(PDFLATEX) $^; \
done
%.tex: %.org
# Pay attention that `--batch' implies `-q', so `.emacs' is *not* loaded and
# you don't get your `load-path' customizations. Hence, this loads the Emacs
# built-in version of Org-mode.
@echo
@emacs --batch \
--eval "(add-to-list 'load-path \"$(ORGLIB)\")" \
--eval "(require 'org)" \
--eval "(require 'org-exp)" \
--eval "(setq org-export-headline-levels 2)" \
--load ./Org2LaTeX.el \
--visit=$^ \
--funcall org-export-as-latex-batch
clean:
-$(RM) $(RMEXT)
realclean: clean
-$(RM) $(RMOUT)
## Makefile ends here
--8<---------------cut here---------------end--------------->8---
It has the advantage of running only the required compilation for the modified
files, and generates both HTML and PDF versions...
A nice thing would be to be able to even merge all the PDF files into one --
but here come questions like in which order, with or without title page, and
so on.
Comments (more than) welcome!
Seb
--
Sébastien Vauban
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Orgmode] Re: export (as latex) a large number of org files in a directory,
Sébastien Vauban <=