emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Karl Voit <devnull@Karl-Voit.at>
To: emacs-orgmode@gnu.org
Subject: HowTo: Letter template method using yasnippet (was: Org/LaTeX set-up for business letters?)
Date: Fri, 6 Jul 2012 21:08:24 +0200	[thread overview]
Message-ID: <2012-07-06T20-54-34@devnull.Karl-Voit.at> (raw)
In-Reply-To: 8762a2l6f7.fsf@googlemail.com

* Thorsten Jolitz <tjolitz@googlemail.com> wrote:
>
> Hi List, 

Hi Thorsten!

> although using Emacs/Org-mode for almost everything, I still write my
> "official" correspondence with a (quite nice) OpenOffice template. It
> would be so much easier and faster to just use Org mode for that too.

I accomplished this by using yasnippet and Org-mode. It is quite
convenient :-)

1. install, configure, and learn yasnippet for your Emacs
   - a must; independent of this one here!

2. put «newletter» (below) into your snippet directory so that it can be
   invoked when you're in a Org-mode buffer
   - usually, this means storing as something similar to
     «~/.emacs.d/snippets/text-mode/org-mode/newletter»
   - adopt my dummy entries for your name, address, and so forth


So far for the initial setup.


3. create a new (empty) folder

4. enter the new folder

5. create and open a new Org-mode file in Emacs
   - it is only temporary
   - you might want to use «emacsclient init.org»

6. within this open Emacs buffer, type «newletter» followed by TAB
   - this invokes the yasnippet template

7. fill out all fields, take default values or change them, switch to
   the next field by using TAB

8. when you end up at the line «cat  >Kopf.tex <<EOF»: press C-c C-c
   in order to get the template generated

9. exit the temporary Org-mode buffer
   - you can even delete the Org-mode file now that the template was generated

10. start typing your letter within «letter.tex» and compile with «make
    pdf» as you want


This is the file «newletter»: 
  - please do exclude my email signature below :-)
  - please note that the Makefile requires tabstops before each
    indented command line - probably you have to fix this once 
    while creating «newletter»

===========================================================================

# -*- mode: snippet -*-
# name: LaTeX KOMA scrlttr2
# key: newletter
# contributor: Karl Voit
# --

From/Name:       ${1:Your Name}
From/Street:     ${2:Your street and house number}
From/Postal No.: ${3:1234}
From/City:       ${4:Yourcity}
From/Signature:	 ${5:\\usekomavar{fromname}}
From/Email:      ${6:Youremail}
From/Phone:      ${7:0043/664/12\\,34\\,56}

To/Company:    $8
To/Name:       $9
To/Street:     $10
To/Postal No.: $11
To/City:       $12

Subject:  $13
Filename: $14

#+BEGIN_SRC sh
cat  >letter.tex <<EOF
\documentclass[%
%DIV=14,% viel mehr Platz auf einer Seite
%enlargefirstpage,% mehr Platz (bringt nicht viel)
fontsize=12pt,%
parskip=half,%
subject=titled,% 'Betrifft: ' hinschreiben
backaddress=false,% Absenderadresse nochmal (klein, einzeilig) ueber Empfaenger
fromalign=left,%
fromemail=true,%
fromphone=true%
]{scrlttr2}

\usepackage{ucs}             %% UTF8 as input characters
\usepackage[utf8x]{inputenc} %% UTF8 as input characters

\usepackage[ngerman]{babel}

\setkomavar{fromname}{$1}
\setkomavar{fromaddress}{$2\\newline{}$3~$4}
\setkomavar{signature}{$5}
\setkomavar{fromemail}{$6}
\setkomavar{fromphone}{$7}

\begin{document}

% -------------------------------------------------------------

\setkomavar{subject}{$13}

\begin{letter}{%
$8\\newline
$9\\newline
$10\\newline
$11~$12}

\LoadLetterOption{DINmtext} %% Adressfeld ist weiter oben -> mehr Text

\opening{Sehr geehrtXX NAME!}

TEXT

\closing{Mit freundlichen Grüßen}

%\encl{Lebenslauf}% Anhang

\end{letter}

% -------------------------------------------------------------

\end{document}

EOF
cat -T >Makefile_temp <<EOF
## ein aussagekraeftiger Name zum Benennen der Endprodukte (PDFs, ZIPs, ...)
PROJECTNAME = "$14"

## -----------------------------------------
##       DO NOT EDIT BELOW THIS LINE
## -----------------------------------------

## Makefile von Karl Voit (Karl@Voit.net)

## COMMANDS:
#PDFVIEWER = xpdf
PDFVIEWER = acroread
PDFLATEX_CMD = pdflatex
TIMESTAMP = \\\`/bin/date +%Y-%m-%dT%H.%M\\\`
FILENAME = "\\\${TIMESTAMP}_\\\${PROJECTNAME}.pdf"

#help
#helpThe main targets of this Makefile are:
#help	help	this help
.PHONY: help
help:
§@sed -n 's/^#help//p' < Makefile

# --------------------------------------------------------

#help	all	create PDF
.PHONY: all
all: main

.PHONY: main
main: pdf

# --------------------------------------------------------

#help	pdf	generate PDF
.PHONY: pdf
pdf: letter.pdf

letter.pdf: letter.tex
§TEXINPUTS=\\\$(TEXINPUTS) \\\${PDFLATEX_CMD} letter.tex
§TEXINPUTS=\\\$(TEXINPUTS) \\\${PDFLATEX_CMD} letter.tex
§-mv letter.pdf "\\\${FILENAME}"
§touch letter.pdf

# --------------------------------------------------------

#help	view	view the PDF
.PHONY: view
view: pdf
§\\\${PDFVIEWER} "\\\${FILENAME}"

# --------------------------------------------------------

#help	clean	clean up temporary files
.PHONY: clean
clean:
§-rm *~ *.aux *.bbl main.dvi main.ps main.pdf *.dvi *.blg *.idx *.ilg *.ind *.toc *.log *.log *.brf *.out *.lof *.lot *.gxg *.glx *.gxs *.glo *.gls -f

#help	purge	cleaner than clean ;-)
.PHONY: purge
purge: clean
§-rm *.pdf *.ps -f

#help	force	force rebuild next run
.PHONY: force
force:
§touch *tex

# TOOLS:

#help	zip	create ZIP-file
.PHONY: zip
zip: clean
§zip -r ../\\\${PROJECTNAME}_\\\${TIMESTAMP}.zip *

#end
EOF
# OK, this is somewhat dirty but it's a workaround to the problem that TABs do not get into Makefile
tr '§' '\t' <Makefile_temp >Makefile
rm Makefile_temp
#+END_SRC


===========================================================================

-- 
Karl Voit

  parent reply	other threads:[~2012-07-06 19:23 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-05 12:49 Org/LaTeX set-up for business letters? Thorsten Jolitz
2012-07-05 13:12 ` suvayu ali
2012-07-05 19:00   ` Thorsten Jolitz
2012-07-05 22:00     ` suvayu ali
2012-07-05 22:47       ` Thorsten Jolitz
2012-07-06  8:47         ` Michael Strey
2012-07-06 16:35           ` Thorsten Jolitz
2012-07-06 18:11             ` suvayu ali
2012-07-06 19:11               ` Thorsten Jolitz
2012-07-06 19:23                 ` Bastien
2012-07-06 19:44                   ` Nicolas Goaziou
2012-07-07  2:42             ` Mehul Sanghvi
2012-07-07 11:48               ` Thorsten Jolitz
2012-07-07  1:55         ` Vikas Rawal
2012-07-07 11:58           ` Thorsten Jolitz
2012-07-08 10:34             ` Sebastien Vauban
2012-07-06 19:08 ` Karl Voit [this message]
2012-07-06 22:35   ` HowTo: Letter template method using yasnippet Nicolas Goaziou
2012-07-07  0:34     ` Thorsten Jolitz
2012-07-07  9:35     ` Karl Voit
2012-07-08  9:08     ` AW
2012-07-08 13:34       ` Nicolas Goaziou
2012-07-08 14:57         ` AW
2012-07-27 16:24     ` Extending org-koma-letter.el (was: HowTo: Letter template method using yasnippet) Rasmus
2012-07-29 18:31       ` Extending org-koma-letter.el Nicolas Goaziou
2012-07-31 10:14         ` Luis Anaya
2012-08-03  8:19           ` Nicolas Goaziou
2012-08-03 14:23             ` Luis Anaya
2012-08-03 16:24               ` Bastien
2012-08-04  0:40                 ` Luis Anaya
2012-11-06 15:31                 ` Alan Schmitt
2012-11-13 22:56                   ` Nicolas Goaziou
2012-11-14 16:48                     ` Alan Schmitt
2012-11-20  3:14                       ` Luis Anaya
2012-11-22 16:07                     ` Alan Schmitt
2012-11-22 16:32                       ` Rasmus
2012-11-22 16:40                       ` Nicolas Goaziou
2012-11-23  8:34                         ` Alan Schmitt
2012-11-23 11:51                           ` Nicolas Goaziou
2012-11-26  8:01                             ` Alan Schmitt
2012-11-26 12:48                               ` Bastien

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=2012-07-06T20-54-34@devnull.Karl-Voit.at \
    --to=devnull@karl-voit.at \
    --cc=emacs-orgmode@gnu.org \
    --cc=news1142@Karl-Voit.at \
    /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).