Permalink
Browse files

We have PDF!

  • Loading branch information...
1 parent aaf9354 commit 5ad6db1c5b0acedf35aa15ba0cea33f62c5e3d69 Avdi Grimm committed Mar 5, 2012
Showing with 121 additions and 10 deletions.
  1. +21 −0 figure.org
  2. +18 −0 init.el
  3. +22 −10 orgpress.mk
  4. +53 −0 orgpress_headers.tex
  5. +7 −0 skeleton.org.m4
View
@@ -0,0 +1,21 @@
+# An experiment kept around for posterity
+
+#+name: figure
+#+BEGIN_SRC emacs-lisp :exports none
+ (concat
+ "\n#+BEGIN_LaTeX:\n"
+ "\\begin{figure}[htb]\n"
+ "\\centering\n"
+ "\\includegraphics[width=0.90\\textwidth]{" path "}\n"
+ "\\caption{" caption "}\n"
+ "\\end{figure}\n"
+ "#+END_LaTeX\n"
+ "#+BEGIN_HTML:\n"
+ "<figure>\n"
+ "<img alt='" caption "' src='" path "' />\n"
+ " <figcaption>" caption "</figcaption>\n"
+ "</figure>\n"
+ "#+END_HTML\n")
+#+END_SRC
+
+#+MACRO: figure #+call: figure(path="$1",caption="$2") :results value raw
View
18 init.el
@@ -1,3 +1,16 @@
+(setq org-export-latex-listings 'minted)
+(setq org-export-latex-minted t)
+(setq org-export-latex-minted-langs
+ '((html "rhtml")
+ (emacs-lisp "common-lisp")
+ (cc "c++")
+ (cperl "perl")
+ (shell-script "bash")
+ (caml "ocaml")))
+(setq org-latex-to-pdf-process
+ '("pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
+ "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
+ "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"))
(setq org-export-html-style-extra
(concat "\n<style type='text/css'>\n"
(with-temp-buffer
@@ -7,3 +20,8 @@
(error "No $STYLESHEET set")))
(buffer-string))
"\n</style>\n"))
+(setq org-babel-load-languages
+ (quote ((emacs-lisp . t) (ruby . t) (sh . t))))
+(setq org-confirm-babel-evaluate nil)
+(setq org-export-htmlize-output-type (quote css))
+(setq org-export-htmlized-org-css-url nil)
View
@@ -36,7 +36,7 @@ M4_INIT_FILE = $(abspath $(ORGPRESS_ROOT)/init.m4)
M4FLAGS = --prefix-builtins $(M4_INIT_FILE)
ifdef DEBUG
- EMACSFLAGS += --debug-init
+ EMACSFLAGS += --debug-init --eval '(setq debug-on-error t)'
endif
# The Calibre conversion command
@@ -76,6 +76,9 @@ CALIBRE_INPUT = $(call flavor_file,calibre.html)
AWK = gawk
AWKFLAGS =
+# LaTeX search path
+export TEXINPUTS = .:$(BUILD_DIR):$(ORGPRESS_ROOT):
+
# Strip out figures and listings, replace with placeholders
skeletonize_file = $(realpath $(ORGPRESS_ROOT)/skeletonize.awk)
skel = $(AWK) $(AWKFLAGS) -f $(skeletonize_file)
@@ -110,6 +113,12 @@ PUBLISHER = $(AUTHORS)
# The publication date
PUBDATE = $(shell ls -ldc $(CURDIR) | cut -d' ' -f6)
+# The revision number
+BOOK_REVISION = 1
+
+# The publication year
+PUBYEAR = $(firstword $(subst -, ,$(PUBDATE)))
+
# Org export customizations
HEADLINE_LEVELS := 5
TABLE_OF_CONTENTS := nil
@@ -145,14 +154,16 @@ STANDARD_DEPS = $(ORGPRESS_MAKEFILE) $(BOOK_MAKEFILE) $(build_assets)
all_targets = $(addprefix $(BOOK_NAME).,$(ALL_FLAVORS))
export_target = $(BUILD_DIR)/$(BOOK_NAME).$(FLAVOR)
master = $(BUILD_DIR)/master.org
-master_vars = BOOK_TITLE AUTHORS SOURCE_FILES sections_file listings_dir figures_dir
+master_vars = BOOK_TITLE AUTHORS BOOK_REVISION PUBYEAR SOURCE_FILES sections_file listings_dir figures_dir latex_headers_file
define master_defs
$(strip $(foreach varname,$(master_vars),-D ORGPRESS_$(varname)="$($(varname))"))
endef
sections_file = $(BUILD_DIR)/sections.org.m4
skeletons = $(SOURCE_FILES:$(CURDIR)/%.org=$(BUILD_DIR)/%.skeleton)
listings_dir = $(BUILD_DIR)/listings
figures_dir = $(BUILD_DIR)/figures_dir
+latex_headers_file = $(realpath $(ORGPRESS_ROOT)/headers.tex)
+minted_file = $(abspath $(BUILD_DIR)/minted.sty)
### FUNCTIONS ###
@@ -172,23 +183,21 @@ endef
define export_elisp
(progn
- (cd "$(CURDIR)")
(org-export-as-$(FLAVOR)
$(HEADLINE_LEVELS)
nil
- (quote ($(export_plist)))
- "*orgpress-export*")
- (with-current-buffer "*orgpress-export*"
- (write-file "$@")))
+ (quote ($(export_plist)))))
endef
-
$(info OrgPress version $(ORGPRESS_VERSION))
ifdef DEBUG
$(info Debug mode enabled)
DEBUG_PRECIOUS_FILES = $(master)
endif
+ifndef DEBUG
+ EMACSFLAGS += --batch
+endif
include $(BOOK_MAKEFILE)
@@ -214,11 +223,10 @@ $(CALIBRE_TARGETS): flavorflags = $($(call uppercase,$(FLAVOR))FLAGS)
$(CALIBRE_TARGETS): $(CALIBRE_INPUT) $(CURDIR)/book.mk $(STANDARD_DEPS)
$(CONVERT) $< $@ $(strip $(CONVERTFLAGS)) $(strip $(flavorflags))
-%.pdf %.html %.calibre.html %.txt: %.org $(EMACS_LOAD) $(STANDARD_DEPS) $(STYLESHEET)
+%.pdf %.html %.calibre.html %.txt: %.org $(EMACS_LOAD) $(STANDARD_DEPS) $(STYLESHEET) $(minted_file)
$(EMACS) $(EMACSFLAGS) \
$(EMACS_LOAD:%=-l %) \
--user $(USER) \
- --batch \
--file "$<" \
--eval '$(strip $(export_elisp))'
@@ -246,6 +254,10 @@ $(build_assets):
$(BUILD_DIR)/%.skeleton: $(CURDIR)/%.org $(listings_dir) $(figures_dir) $(skeletonize_file) $(STANDARD_DEPS)
$(skel) $(skelflags) $< > $@
+$(minted_file):
+ cd $(@D) && \
+ wget "http://minted.googlecode.com/files/minted.sty"
+
.PRECIOUS: $(DEBUG_PRECIOUS_FILES)
# Targets that aren't files and never will be
View
@@ -0,0 +1,53 @@
+\setcounter{secnumdepth}{-2}
+\usepackage{minted}
+
+% reduce verticle space after listings
+% See http://stackoverflow.com/questions/2318598/how-to-reduce-the-seperation-from-other-text-using-latex-minted
+% \setlength\partopsep{-\topsep}
+
+\usemintedstyle{default}
+\usepackage[small,it]{caption}
+\usepackage{framed}
+\usepackage{xcolor}
+\hypersetup{colorlinks=true}
+\hypersetup{hyperindex=true}
+\hypersetup{linkcolor=blue}
+\hypersetup{urlcolor=blue}
+
+\usepackage{pdfpages}
+
+\usepackage{fancyvrb}
+\usepackage[T1]{fontenc}
+\usepackage[scaled]{beraserif}
+\usepackage[scaled]{berasans}
+\usepackage[scaled]{beramono}
+
+% Get rid of blank pages between chapters
+\let\cleardoublepage\clearpage
+
+\setlength{\parindent}{0pt}
+\setlength{\parskip}{1ex plus 0.5ex minus 0.2ex}
+
+\definecolor{codeframecolor}{rgb}{0.95,0.95,0.95}
+% \definecolor{codebgcolor}{RGB}{255,244,204}
+\definecolor{codebgcolor}{rgb}{0.97,0.97,0.97}
+\definecolor{shadecolor}{gray}{.95}
+\usepackage{epstopdf}
+\usepackage{calc}
+\usepackage{fancyhdr}
+\pagestyle{fancy}
+\fancyheadoffset[RO,LE]{\marginparsep+\marginparwidth}
+\fancyhead{} % clear header fields
+\fancyhead[LO,RE]{\leftmark}
+\fancyhead[RO,LE]{\thepage}
+\fancyfoot{}
+\fancyfoot[C]{\thepage}
+\definecolor{exceptionalred}{RGB}{232,0,40}
+\renewcommand\headrule
+{{\color{exceptionalred}%
+ \hrule height 2pt
+ width\headwidth
+ \vspace{1pt}%
+ \hrule height 1pt
+ width\headwidth
+ \vspace{-4pt}}}
View
@@ -1,4 +1,11 @@
#+TITLE: ORGPRESS_BOOK_TITLE
#+AUTHOR: ORGPRESS_AUTHORS
+#+LaTeX_HEADER: \input{orgpress_headers}
+
+* About
+
+ *ORGPRESS_BOOK_TITLE Revision ORGPRESS_BOOK_REVISION*
+
+ Copyright \copy ORGPRESS_PUBYEAR by ORGPRESS_AUTHORS. All rights reserved.
m4_include(ORGPRESS_sections_file)

0 comments on commit 5ad6db1

Please sign in to comment.