Is it possible to customize emacs (with AucTeX) so that new templates can be added for quicker typesetting. For example, If I want to prepare a letter that has a particular format, then I would like to create a sample letter tex file and save it as a macro or environment and call it and just pass the required parameters like the date, the name , the content and so on and generate the pdf?
-
I wrote a patch to add templates in AUCTeX but there wasn't a follow-up. Anyway, for an external solution take a look at stackoverflow.com/q/19335434/2442087 – giordano Feb 24 '14 at 9:21
-
For the specific case of the letter see also tex.stackexchange.com/q/117155/31416 – giordano Feb 24 '14 at 9:45
After quite some time I was very happy to find this: https://github.com/capitaomorte/yasnippet
I'm using templates, e.g. for letters, but for inserting code as well. A part of this letter snippet follows:
# -*- mode: snippet -*-
# contributor: XX
# key: YXZ-let
# group: skeleton
# name: \documentclass{scrlettr2} ...
# --
\documentclass[12pt,ngerman,zippelius8]{scrlttr2}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\setkomavar{Sachbearbeiter}{my secretary...}
\begin{document}
\begin{letter}{${1:Name}\\\
${2:Strasse}\\\
${3:PLZ Ort}\\\[1.5cm]
${4:$$(yas/choose-value '("Vorab per Telefax: " "Per Telefax: " "Vorab per E-mail: " "Per E-mail: " " "))}
\emph{${5: }}
}
But beware, there are many things that can be inserted fast using the build-in AUCTeX commands. E.g. the fastest way to insert an environment ist C-c C-e.
The code above is the beginning of a snippet. So the syntax is the syntax of yassnippet and not LaTeX. The part after the initial lines beginning with a # will be inserted as template.
-
-
2@egreg -- the number sign is an internal code used by Yasnippet -- the lines of code beginning with the number sign are not inserted into the LaTeX document. – lawlist Feb 24 '14 at 17:19