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?


1 Answer 1


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} ...
# --

\setkomavar{Sachbearbeiter}{my secretary...}


    ${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
    Commented Feb 24, 2014 at 10:32
  • 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
    Commented Feb 24, 2014 at 17:19
  • yasnippet sounds goo, but the docs for it do not tell you how to use its functionality. So I want to write a paper in auctex. How do I open a template file, how do I make sure when the template is copied, LaTeX mode loads, etc. Commented May 3, 2023 at 18:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .