Skip to content

Instantly share code, notes, and snippets.

@novoid
Created December 23, 2015 09:11
Show Gist options
  • Save novoid/e79d005e2729e991294f to your computer and use it in GitHub Desktop.
Save novoid/e79d005e2729e991294f to your computer and use it in GitHub Desktop.
# -*- mode: snippet -*-
# name: LaTeX KOMA scrlttr2
# key: tletter
# contributor: Karl Voit
# --
From/Name: ${1:Firstname~Lastname}
From/Street: ${2:My~Street~23}
From/Postal No.: ${3:1234}
From/City: ${4:Graz}
From/Signature: ${5:\\usekomavar{fromname}}
From/Email: ${6:email\@Firstname-Lastname.at}
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 :eval no-export
cat >letter.tex <<EOF
\documentclass[%
%DIV=14,% more space
%enlargefirstpage,% a bit more space
fontsize=12pt,%
parskip=half,%
subject=untitled,%
backaddress=false,%
fromalign=left,%
fromemail=true,%
fromphone=true%
]{scrlttr2}
\usepackage{ucs} %% UTF8 as input characters
\usepackage[utf8x]{inputenc} %% UTF8 as input characters
\usepackage[ngerman]{babel}
\usepackage{enumitem} %%
\setlist{noitemsep} %% kills the space between items
\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}
\opening{Dear NAME,}
TEXT
\closing{Sincerely}
%\encl{CV}
\end{letter}
% -------------------------------------------------------------
\end{document}
%% Local Variables:
%% mode: auto-fill
%% mode: flyspell
%% eval: (ispell-change-dictionary "en_US")
%% End:
EOF
cat -T >Makefile_temp <<EOF
## a good name for end result files (PDFs, ZIPs, ...)
PROJECTNAME = "$14"
## -----------------------------------------
## DO NOT EDIT BELOW THIS LINE
## -----------------------------------------
## Makefile by Karl Voit
## 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment