5

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?

3

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.

  • Shouldn't the # characters be % instead? – egreg Feb 24 '14 at 10:32
  • 1
    @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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.