emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Russell Adams <RLAdams@AdamsInfoServ.Com>
To: emacs-orgmode@gnu.org
Subject: Re: Latex exporting
Date: Wed, 6 Aug 2008 16:32:41 -0500	[thread overview]
Message-ID: <20080806213241.GG24521@thinkpad.adamsinfoserv.com> (raw)
In-Reply-To: <20080729234636.GA9366@thinkpad.adamsinfoserv.com>


[-- Attachment #1.1.1: Type: text/plain, Size: 3477 bytes --]

On Tue, Jul 29, 2008 at 06:46:37PM -0500, Russell Adams wrote:
> I've finally embarked upon a journey of exploration, attempting to
> publish quality PDF's via org and latex.
> 

As a follow up to my command line tricks, I want to share how to get
headers and footers into Latex exports.

First, the default latex exporter uses A4 paper, I need letter. To
change that I use the following in my .emacs to add a custom export
type, "myarticle". 

This includes expanding the default margins via the geometry package,
and sets up packages I will use later like fancyhdr and lastpage. I
also include a default footer on my work, which includes the filename
and date, page numbering, and copyright statement with current year.

~/.emacs ------------------------------------------------------------

(setq org-export-latex-classes (cons '("myarticle"
     "% BEGIN My Article Defaults
\\documentclass[10pt,letterpaper]{article}
\\usepackage[letterpaper,includeheadfoot,top=0.5in,bottom=0.5in,left=0.75in,right=0.75in]{geometry}
\\usepackage[utf8]{inputenc}
\\usepackage[T1]{fontenc}
\\usepackage{hyperref}
\\usepackage{lastpage}
\\usepackage{fancyhdr}
\\pagestyle{fancy}
\\renewcommand{\\headrulewidth}{1pt}
\\renewcommand{\\footrulewidth}{0.5pt}

% Default footer
\\fancyfoot[L]{\\small \\jobname \\\\ \\today}
\\fancyfoot[C]{\\small Page \\thepage\\ of \\pageref{LastPage}}
\\fancyfoot[R]{\\small \\copyright \\the\\year\\  Me}
% END My Article Defaults

"
     ("\\section{%s}" . "\\section*{%s}")
     ("\\subsection{%s}" . "\\subsection*{%s}")
     ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
     ("\\paragraph{%s}" . "\\paragraph*{%s}")
     ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
									 org-export-latex-classes))

------------------------------------------------------------

To use this custom type I add this as the first line in my Org file:

#+LaTeX_CLASS: myarticle

Further customization is easy using a local variables block at the end
of my file.

End of file.org --------------------------------------------------

#+ Local Variables:
#+ org-export-latex-title-command: ""
#+ org-export-latex-append-header: "\
#+ \\usepackage{graphicx}
#+ \\usepackage{multicol}
#+ \\geometry{headheight=47pt}
#+ \\fancyhead[L]{\\LARGE This is the header title}
#+ \\fancyfoot[L]{\\small Overridden filename\\\\ \\today}
#+ "
#+ End:
------------------------------------------------------------

Changing the title command means no title page is created, so I must
make my own. Omitting that line will create the normal title page.

Other packages I include via the append header variable are graphicx
for PNG support, multicol for two columns, overriding the page header
height in case I get a warning its too tall, and new headers to
override the defaults (ie: I want something better than a filename).

I'm exporting to latex via a Makefile, using the command line tricks I
posted earlier. The Makefile is attached.

I've attached a sample org file and its output PDF using these
settings, because one of my frustrations learning latex has been the
lack of finished output for examples. ;]

Enjoy!

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

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

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

[-- Attachment #1.1.2: Makefile --]
[-- Type: text/plain, Size: 677 bytes --]

.PHONY: all clean

# All org files convert to PDF
OBJS := $(patsubst %.org, %.pdf, $(wildcard *.org))

# TeX output and logs
CRAP := $(patsubst %.org, %.pdf, $(wildcard *.org))
CRAP += $(patsubst %.org, %.aux, $(wildcard *.org))
CRAP += $(patsubst %.org, %.log, $(wildcard *.org))
CRAP += $(patsubst %.org, %.out, $(wildcard *.org))
CRAP += $(patsubst %.org, %.toc, $(wildcard *.org))

all: $(OBJS)

clean:
	rm -f $(CRAP)

# Convert the orgs
%.tex: %.org
	emacs --eval '(setq enable-local-variables :all)' \
		$< \
		-f org-export-as-latex \
		-f save-buffers-kill-emacs

# Always run twice in case the TOC generation & lastpage complain
%.pdf: %.tex
	pdflatex $<
	pdflatex $<

[-- Attachment #1.1.3: Example.org --]
[-- Type: text/plain, Size: 5011 bytes --]

#+LaTeX_CLASS: myarticle
#+TITLE:     Not used because I've disabled the title page
#+AUTHOR:    Russell Adams
#+EMAIL:     rladams@adamsinfoserv.com
#+DATE:      <2008-08-06 Wed>
#+LANGUAGE:  en
#+OPTIONS:   H:3 num:t toc:t \n:t @:t ::t |:t ^:t -:t f:t *:t TeX:t LaTeX:nil skip:nil d:nil tags:not-in-toc

* Example

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas
venenatis. Morbi sem erat, facilisis a, molestie ut, fringilla id,
eros. Mauris nec elit sed lorem faucibus scelerisque. Morbi
fringilla. Nullam pellentesque facilisis sapien. Curabitur laoreet
fringilla nisl. Morbi id eros vitae ligula laoreet tincidunt. Integer
semper, tellus ut luctus sagittis, diam sem condimentum leo, in
consectetuer risus tellus eu enim. Proin leo nulla, consequat nec,
varius sit amet, tincidunt non, velit. Suspendisse potenti. Morbi
mollis, nunc luctus porta sagittis, mauris orci euismod nibh, ut
ultricies tellus elit eu mi. Nulla odio. Class aptent taciti sociosqu
ad litora torquent per conubia nostra, per inceptos himenaeos. Nullam
vitae neque. Etiam tellus nulla, semper at, elementum ut, interdum in,
odio. Maecenas sit amet leo. Nulla facilisi. Pellentesque vestibulum
dui in mauris. Sed sollicitudin purus ornare nunc. Praesent aliquam,
libero sit amet rutrum molestie, pede dolor tincidunt odio, et auctor
nisi nisl vel elit.

** Subsection One

Curabitur nulla ipsum, porta ut, tincidunt ut, tincidunt vel,
ipsum. Integer nec lacus at orci placerat placerat. Donec egestas
cursus elit. Sed euismod facilisis orci. Sed id ligula. Vestibulum
tincidunt mollis diam. Nulla velit ipsum, commodo condimentum, aliquam
vitae, sollicitudin quis, lacus. Nullam condimentum ornare nibh. Ut a
orci eu arcu rutrum laoreet. Maecenas egestas.

** Subsection Two

Mauris eleifend. Etiam aliquam magna iaculis tortor. Sed
molestie. Class aptent taciti sociosqu ad litora torquent per conubia
nostra, per inceptos himenaeos. Integer eu justo eu risus ultricies
pellentesque. In pellentesque tincidunt neque. Pellentesque a arcu nec
urna porta sagittis. Cras turpis purus, tristique et, imperdiet id,
commodo nec, eros. Etiam posuere scelerisque tellus. Sed sit amet
justo. Donec elementum leo a sapien. Ut porttitor orci euismod
eros. Ut faucibus. Proin condimentum. Pellentesque id ligula. Nullam
ullamcorper. Cras porta fermentum est. In eu mi. Aenean hendrerit
lacus vitae enim.

* Summary

Vestibulum sodales. Pellentesque habitant morbi tristique senectus et
netus et malesuada fames ac turpis egestas. Nunc scelerisque, justo id
tincidunt pellentesque, nunc velit rhoncus nibh, in congue pede diam
at turpis. Nullam porta orci nec felis. Nam ullamcorper vulputate
risus. Nulla nec massa. Sed dignissim elit vitae elit. Praesent
tristique lobortis turpis. Fusce nisl. Aliquam nibh pede, faucibus
non, cursus a, consequat sit amet, erat. Pellentesque lectus. Maecenas
felis. Maecenas tincidunt. Nam eleifend justo sed massa. Curabitur
quam. Integer tincidunt metus. Morbi convallis dapibus arcu. Praesent
et augue a enim hendrerit consequat.

\pagebreak

* Index

\begin{multicols}{2}

 - Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
	 - Pellentesque vehicula porttitor libero.
	 - Duis volutpat turpis at magna.
 - Nunc tincidunt massa at enim.
 - Mauris aliquet molestie nulla.
 - Sed ullamcorper nunc sit amet massa.
	 - Proin dignissim fermentum dolor.
	 - Sed viverra cursus pede.
	 - Nulla molestie dolor a turpis.
 - Etiam sodales libero nec tellus facilisis sollicitudin.
 - Vestibulum lacinia erat in felis.
 - Cras lacinia faucibus massa.
 - Pellentesque aliquet mollis neque.
 - Sed blandit nibh ut lorem.
	 - Sed suscipit augue ac arcu.
 - Ut tempus volutpat lorem.
 - Sed ac elit eget mauris rutrum rhoncus.
 - In pellentesque facilisis dolor.
	 - Fusce eu sapien lobortis nibh blandit ultrices.
	 - Nulla auctor urna sed erat.
	 - Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
	 - Pellentesque vehicula porttitor libero.
 - Duis volutpat turpis at magna.
 - Nunc tincidunt massa at enim.
 - Mauris aliquet molestie nulla.
 - Sed ullamcorper nunc sit amet massa.
 - Proin dignissim fermentum dolor.
 - Sed viverra cursus pede.
 - Nulla molestie dolor a turpis.
	 - Etiam sodales libero nec tellus facilisis sollicitudin.
		 - Vestibulum lacinia erat in felis.
	 - Cras lacinia faucibus massa.
		 - Pellentesque aliquet mollis neque.
		 - Sed blandit nibh ut lorem.
 - Sed suscipit augue ac arcu.
 - Ut tempus volutpat lorem.
 - Sed ac elit eget mauris rutrum rhoncus.
 - In pellentesque facilisis dolor.
 - Fusce eu sapien lobortis nibh blandit ultrices.
 - Nulla auctor urna sed erat.

\end{multicols}

\begin{center}\rule{0.5\linewidth}{0.1pt}\end{center}

#+ Local Variables:
#+ org-export-latex-title-command: ""
#+ org-export-latex-append-header: "\
#+ \\usepackage{graphicx}
#+ \\usepackage{multicol}
#+ \\geometry{headheight=47pt}
#+ \\fancyhead[L]{\\LARGE This is the header title}
#+ \\fancyfoot[L]{\\small Overridden filename\\\\ \\today}
#+ "
#+ End:


[-- Attachment #1.1.4: Example.pdf --]
[-- Type: application/pdf, Size: 64750 bytes --]

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

[-- Attachment #2: Type: text/plain, Size: 204 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

  reply	other threads:[~2008-08-06 21:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-29 23:46 Latex exporting Russell Adams
2008-08-06 21:32 ` Russell Adams [this message]
2008-08-07  4:08   ` Daniel Goldin
2008-09-10 18:54   ` Frank Dekens
2008-09-10 22:32     ` Russell Adams
2008-09-24  0:52       ` Frank Dekens
2008-09-25  5:42         ` Russell Adams

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=20080806213241.GG24521@thinkpad.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).